Package org.opends.server.core
Class EntryCacheConfigManager.EntryCacheDispatcher
- java.lang.Object
-
- org.opends.server.api.MonitorProvider
-
- org.opends.server.api.EntryCache<EntryCacheCfg>
-
- org.opends.server.core.EntryCacheConfigManager.EntryCacheDispatcher
-
- All Implemented Interfaces:
MeterBinder,ConfigurationChangeListener<EntryCacheCfg>,LocalBackendInitializationListener
- Enclosing class:
- EntryCacheConfigManager
public static final class EntryCacheConfigManager.EntryCacheDispatcher extends EntryCache<EntryCacheCfg> implements ConfigurationChangeListener<EntryCacheCfg>, LocalBackendInitializationListener
This class defines the entry cache dispatcher which acts as an arbiter for every entry cache implementation configured and installed within the Directory Server or acts an an empty cache if no implementation specific entry cache is configured. It does not actually store any entries, so all calls to the entry cache public API are routed to underlying entry cache according to the current configuration order and preferences.This class records total-tries and misses metrics globally:
- Try to retrieve an entry from multiple cache implementations: record one try.
- None of the entry cache implementations have succeeded to retrieve the entry: record one miss.
-
-
Field Summary
-
Fields inherited from class org.opends.server.api.MonitorProvider
registry
-
-
Constructor Summary
Constructors Constructor Description EntryCacheDispatcher()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConfigChangeResultapplyConfigurationChange(EntryCacheCfg configuration)Applies the configuration changes to this change listener.voidclear()Removes all entries from the cache.voidclearBackend(String backendID)Removes all entries from the cache that are associated with the provided backend.protected DncomputeMonitorInstanceDn()Returns the monitor instance DN for this monitor provider.booleancontainsEntry(Dn entryDN)Indicates whether the entry cache currently contains the entry with the specified DN.voidfinalizeEntryCache()Performs any necessary cleanup work (e.g., flushing all cached entries and releasing any other held resources) that should be performed when the server is to be shut down or the entry cache destroyed or replaced.SizedEntrygetEntry(String backendID, long entryID)Retrieves the requested entry with its size, if it is present in the cache.SizedEntrygetEntry(Dn entryDN)Retrieves the entry with its size, with the specified DN from the cache.longgetEntryCount()Retrieves the current number of entries stored within the cache.longgetMemoryUsage()Retrieves the current amount of memory used by this cache in bytes.voidinitializeEntryCache(ServerContext serverContext, EntryCacheCfg configuration)Initializes this entry cache implementation so that it will be available for storing and retrieving entries.booleanisConfigurationChangeAcceptable(EntryCacheCfg configuration, List<LocalizableMessage> unacceptableReasons)Indicates whether the proposed change to the configuration is acceptable to this change listener.protected MeterRegistryHoldernewMeterRegistryHolder(MeterRegistry parent)Creates aMeterRegistryHolderwith the appropriate name prefixes and tags.voidperformBackendPostFinalizationProcessing(String backendId, Predicate<Dn> handlesEntry)Performs any processing that may be required whenever a backend is finalized.voidputEntry(SizedEntry entry, String backendID, long entryID)Stores the provided entry in the cache.voidputEntryIfAbsent(SizedEntry entry, String backendID, long entryID)Stores the provided entry in the cache only if it does not conflict with an entry that already exists.protected voidrecordMiss()Records a failure to retrieve an entry from this cache.protected voidrecordTry()Records an attempt to retrieve an entry from this cache.voidremoveEntry(Dn entryDN)Removes the specified entry from the cache.voidsetOrderedEntryCaches(List<EntryCache<?>> orderedEntryCaches)Sets the current cache order array.StringtoVerboseString()Return a verbose string representation of the current cache maps.-
Methods inherited from class org.opends.server.api.EntryCache
addMonitorObjectClassNames, bindTo, filtersAllowCaching, getServerContext, isConfigurationAcceptable, setIncludeExcludeFilters
-
Methods inherited from class org.opends.server.api.MonitorProvider
configurationDnToMonitorDn, deregisterAll, getMonitorEntry, getMonitorInstanceDn, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.opends.server.api.LocalBackendInitializationListener
performBackendPostInitializationProcessing, performBackendPreFinalizationProcessing, performBackendPreInitializationProcessing
-
-
-
-
Method Detail
-
initializeEntryCache
public void initializeEntryCache(ServerContext serverContext, EntryCacheCfg configuration) throws ConfigException, InitializationException
Description copied from class:EntryCacheInitializes this entry cache implementation so that it will be available for storing and retrieving entries.- Overrides:
initializeEntryCachein classEntryCache<EntryCacheCfg>- Parameters:
serverContext- The server context.configuration- The configuration to use to initialize the entry cache.- Throws:
ConfigException- If there is a problem with the provided configuration entry that would prevent this entry cache from being used.InitializationException- If a problem occurs during the initialization process that is not related to the configuration.
-
containsEntry
public boolean containsEntry(Dn entryDN)
Description copied from class:EntryCacheIndicates whether the entry cache currently contains the entry with the specified DN. This method may be called without holding any locks if a point-in-time check is all that is required. Note that this method is called from @see #getEntry(DN entryDN, LockType lockType, List lockList)- Specified by:
containsEntryin classEntryCache<EntryCacheCfg>- Parameters:
entryDN- The DN for which to make the determination.- Returns:
trueif the entry cache currently contains the entry with the specified DN, orfalseif not.
-
getEntry
public SizedEntry getEntry(String backendID, long entryID)
Description copied from class:EntryCacheRetrieves the requested entry with its size, if it is present in the cache.- Specified by:
getEntryin classEntryCache<EntryCacheCfg>- Parameters:
backendID- ID of the backend associated with the entry to retrieve.entryID- The entry ID within the provided backend for the specified entry.- Returns:
- The requested entry if it is present in the cache, or
nullif it is not present.
-
getEntry
public SizedEntry getEntry(Dn entryDN)
Description copied from class:EntryCacheRetrieves the entry with its size, with the specified DN from the cache.- Specified by:
getEntryin classEntryCache<EntryCacheCfg>- Parameters:
entryDN- The DN of the entry to retrieve.- Returns:
- The requested entry with its size if it is present in the cache, or
nullif it is not present.
-
putEntry
public void putEntry(SizedEntry entry, String backendID, long entryID)
Description copied from class:EntryCacheStores the provided entry in the cache. Note that the mechanism that it uses to achieve this is implementation-dependent, and it is acceptable for the entry to not actually be stored in any cache.- Specified by:
putEntryin classEntryCache<EntryCacheCfg>- Parameters:
entry- The entry to store in the cache.backendID- ID of the backend with which the entry is associated.entryID- The entry ID within the provided backend that uniquely identifies the specified entry.
-
putEntryIfAbsent
public void putEntryIfAbsent(SizedEntry entry, String backendID, long entryID)
Description copied from class:EntryCacheStores the provided entry in the cache only if it does not conflict with an entry that already exists. Note that the mechanism that it uses to achieve this is implementation-dependent, and it is acceptable for the entry to not actually be stored in any cache. However, this method must not overwrite an existing version of the entry.- Specified by:
putEntryIfAbsentin classEntryCache<EntryCacheCfg>- Parameters:
entry- The entry to store in the cache.backendID- ID of the backend with which the entry is associated.entryID- The entry ID within the provided backend that uniquely identifies the specified entry.
-
removeEntry
public void removeEntry(Dn entryDN)
Description copied from class:EntryCacheRemoves the specified entry from the cache.- Specified by:
removeEntryin classEntryCache<EntryCacheCfg>- Parameters:
entryDN- The DN of the entry to remove from the cache.
-
clear
public void clear()
Description copied from class:EntryCacheRemoves all entries from the cache. The cache should still be available for future use.- Specified by:
clearin classEntryCache<EntryCacheCfg>
-
clearBackend
public void clearBackend(String backendID)
Description copied from class:EntryCacheRemoves all entries from the cache that are associated with the provided backend.- Specified by:
clearBackendin classEntryCache<EntryCacheCfg>- Parameters:
backendID- ID of the backend for which to flush the associated entries.
-
isConfigurationChangeAcceptable
public boolean isConfigurationChangeAcceptable(EntryCacheCfg configuration, List<LocalizableMessage> unacceptableReasons)
Description copied from interface:ConfigurationChangeListenerIndicates whether the proposed change to the configuration is acceptable to this change listener.- Specified by:
isConfigurationChangeAcceptablein interfaceConfigurationChangeListener<EntryCacheCfg>- Parameters:
configuration- The new configuration containing the changes.unacceptableReasons- A list that can be used to hold messages about why the provided configuration is not acceptable.- Returns:
- Returns
trueif the proposed change is acceptable, orfalseif it is not.
-
applyConfigurationChange
public ConfigChangeResult applyConfigurationChange(EntryCacheCfg configuration)
Description copied from interface:ConfigurationChangeListenerApplies the configuration changes to this change listener.- Specified by:
applyConfigurationChangein interfaceConfigurationChangeListener<EntryCacheCfg>- Parameters:
configuration- The new configuration containing the changes.- Returns:
- Returns information about the result of changing the configuration.
-
getEntryCount
public long getEntryCount()
Description copied from class:EntryCacheRetrieves the current number of entries stored within the cache.- Specified by:
getEntryCountin classEntryCache<EntryCacheCfg>- Returns:
- The current number of entries stored within the cache.
-
getMemoryUsage
public long getMemoryUsage()
Description copied from class:EntryCacheRetrieves the current amount of memory used by this cache in bytes.- Specified by:
getMemoryUsagein classEntryCache<EntryCacheCfg>- Returns:
- The current amount of memory used by this cache in bytes.
-
toVerboseString
public String toVerboseString()
Description copied from class:EntryCacheReturn a verbose string representation of the current cache maps. This is useful primary for debugging and diagnostic purposes such as in the entry cache unit tests.This method is invoked by unit tests for debugging.
- Specified by:
toVerboseStringin classEntryCache<EntryCacheCfg>- Returns:
- String verbose string representation of the current cache maps in the following format: dn:id:backend one
cache entry map representation per line or
nullif all maps are empty.
-
setOrderedEntryCaches
public void setOrderedEntryCaches(List<EntryCache<?>> orderedEntryCaches)
Sets the current cache order array.- Parameters:
orderedEntryCaches- The current cache order array.
-
performBackendPostFinalizationProcessing
public void performBackendPostFinalizationProcessing(String backendId, Predicate<Dn> handlesEntry)
Description copied from interface:LocalBackendInitializationListenerPerforms any processing that may be required whenever a backend is finalized. This method will be invoked after the backend has been taken out of service and after it has been finalized.- Specified by:
performBackendPostFinalizationProcessingin interfaceLocalBackendInitializationListener- Parameters:
backendId- The backend ID of the backend that has been taken out of service.handlesEntry- A predicate which can be used for determining whether the finalized backend contained an entry.
-
computeMonitorInstanceDn
protected Dn computeMonitorInstanceDn()
Description copied from class:MonitorProviderReturns the monitor instance DN for this monitor provider.- Overrides:
computeMonitorInstanceDnin classEntryCache<EntryCacheCfg>- Returns:
- the monitor instance DN.
-
newMeterRegistryHolder
protected MeterRegistryHolder newMeterRegistryHolder(MeterRegistry parent)
Description copied from class:EntryCacheCreates aMeterRegistryHolderwith the appropriate name prefixes and tags.- Overrides:
newMeterRegistryHolderin classEntryCache<EntryCacheCfg>- Parameters:
parent- The meter registry to be decorated.- Returns:
- The meter registry holder.
-
finalizeEntryCache
public void finalizeEntryCache()
Description copied from class:EntryCachePerforms any necessary cleanup work (e.g., flushing all cached entries and releasing any other held resources) that should be performed when the server is to be shut down or the entry cache destroyed or replaced.- Specified by:
finalizeEntryCachein classEntryCache<EntryCacheCfg>
-
recordTry
protected void recordTry()
Description copied from class:EntryCacheRecords an attempt to retrieve an entry from this cache.- Overrides:
recordTryin classEntryCache<EntryCacheCfg>
-
recordMiss
protected void recordMiss()
Description copied from class:EntryCacheRecords a failure to retrieve an entry from this cache.- Overrides:
recordMissin classEntryCache<EntryCacheCfg>
-
-