public class DefaultEntryCache extends EntryCache<EntryCacheCfg> implements ConfigurationChangeListener<EntryCacheCfg>, LocalBackendInitializationListener
This class records total-tries and misses metrics globaly:
registry
Constructor and Description |
---|
DefaultEntryCache()
Creates a new instance of this default entry cache.
|
Modifier and Type | Method and Description |
---|---|
ConfigChangeResult |
applyConfigurationChange(EntryCacheCfg configuration)
Applies the configuration changes to this change listener.
|
void |
clear()
Removes all entries from the cache.
|
void |
clearBackend(String backendID)
Removes all entries from the cache that are associated with the provided backend.
|
protected Dn |
computeMonitorInstanceDn()
Returns the monitor instance DN for this monitor provider.
|
boolean |
containsEntry(Dn entryDN)
Indicates whether the entry cache currently contains the entry with the specified DN.
|
void |
finalizeEntryCache()
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.
|
Entry |
getEntry(Dn entryDN)
Retrieves the entry with the specified DN from the cache.
|
Entry |
getEntry(String backendID,
long entryID)
Retrieves the requested entry if it is present in the cache.
|
long |
getEntryCount()
Retrieves the current number of entries stored within the cache.
|
Dn |
getEntryDN(String backendID,
long entryID)
Retrieves the entry DN for the entry with the specified ID on the specific backend from the cache.
|
long |
getEntryID(Dn entryDN)
Retrieves the entry ID for the entry with the specified DN from the cache.
|
void |
handleLowMemory()
Attempts to react to a scenario in which it is determined that the system is running low on available memory.
|
boolean |
isConfigurationChangeAcceptable(EntryCacheCfg configuration,
List<LocalizableMessage> unacceptableReasons)
Indicates whether the proposed change to the configuration is acceptable
to this change listener.
|
protected MeterRegistryHolder |
newMeterRegistryHolder(MeterRegistry parent)
Creates a
MeterRegistryHolder with the appropriate name prefixes and tags. |
void |
performBackendPostFinalizationProcessing(LocalBackend<?> backend)
Performs any processing that may be required whenever a backend is finalized.
|
void |
putEntry(Entry entry,
String backendID,
long entryID)
Stores the provided entry in the cache.
|
boolean |
putEntryIfAbsent(Entry 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 void |
recordMiss()
Records a failure to retrieve an entry from this cache.
|
protected void |
recordTry()
Records an attempt to retrieve an entry from this cache.
|
void |
removeEntry(Dn entryDN)
Removes the specified entry from the cache.
|
static void |
setCacheOrder(SortedMap<Integer,EntryCache<? extends EntryCacheCfg>> cacheOrderMap)
Sets the current cache order array.
|
String |
toVerboseString()
Return a verbose string representation of the current cache maps.
|
addMonitorObjectClassNames, bindTo, filtersAllowCaching, initializeEntryCache, isConfigurationAcceptable, setIncludeExcludeFilters
configurationDnToMonitorDn, deregisterAll, getMonitorEntry, getMonitorInstanceDn, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
performBackendPostInitializationProcessing, performBackendPreFinalizationProcessing, performBackendPreInitializationProcessing
public DefaultEntryCache()
public boolean containsEntry(Dn entryDN)
EntryCache
containsEntry
in class EntryCache<EntryCacheCfg>
entryDN
- The DN for which to make the determination.true
if the entry cache currently contains the entry with the specified DN, or false
if
not.public Entry getEntry(String backendID, long entryID)
EntryCache
getEntry
in class EntryCache<EntryCacheCfg>
backendID
- ID of the backend associated with the entry to retrieve.entryID
- The entry ID within the provided backend for the specified entry.null
if it is not present.public Entry getEntry(Dn entryDN)
EntryCache
getEntry
in class EntryCache<EntryCacheCfg>
entryDN
- The DN of the entry to retrieve.null
if it is not present.public long getEntryID(Dn entryDN)
EntryCache
getEntryID
in class EntryCache<EntryCacheCfg>
entryDN
- The DN of the entry for which to retrieve the entry ID.public Dn getEntryDN(String backendID, long entryID)
EntryCache
getEntryDN
in class EntryCache<EntryCacheCfg>
backendID
- ID of the backend associated with the entry for which to retrieve the entry DN.entryID
- The entry ID within the provided backend for which to retrieve the entry DN.null
if it is not present in the cache.public void putEntry(Entry entry, String backendID, long entryID)
EntryCache
putEntry
in class EntryCache<EntryCacheCfg>
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.public boolean putEntryIfAbsent(Entry entry, String backendID, long entryID)
EntryCache
putEntryIfAbsent
in class EntryCache<EntryCacheCfg>
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.false
if an existing entry or some other problem prevented the method from completing
successfully, or true
if there was no conflict and the entry was either stored or the cache
determined that this entry should never be cached for some reason.public void removeEntry(Dn entryDN)
EntryCache
removeEntry
in class EntryCache<EntryCacheCfg>
entryDN
- The DN of the entry to remove from the cache.public void clear()
EntryCache
clear
in class EntryCache<EntryCacheCfg>
public void clearBackend(String backendID)
EntryCache
clearBackend
in class EntryCache<EntryCacheCfg>
backendID
- ID of the backend for which to flush the associated entries.public void handleLowMemory()
EntryCache
handleLowMemory
in class EntryCache<EntryCacheCfg>
public boolean isConfigurationChangeAcceptable(EntryCacheCfg configuration, List<LocalizableMessage> unacceptableReasons)
ConfigurationChangeListener
isConfigurationChangeAcceptable
in interface ConfigurationChangeListener<EntryCacheCfg>
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.true
if the proposed change is acceptable,
or false
if it is not.public ConfigChangeResult applyConfigurationChange(EntryCacheCfg configuration)
ConfigurationChangeListener
applyConfigurationChange
in interface ConfigurationChangeListener<EntryCacheCfg>
configuration
- The new configuration containing the changes.public long getEntryCount()
EntryCache
getEntryCount
in class EntryCache<EntryCacheCfg>
public String toVerboseString()
EntryCache
This method is invoked by unit tests for debugging.
toVerboseString
in class EntryCache<EntryCacheCfg>
null
if all maps are empty.public static final void setCacheOrder(SortedMap<Integer,EntryCache<? extends EntryCacheCfg>> cacheOrderMap)
cacheOrderMap
- The current cache order array.public void performBackendPostFinalizationProcessing(LocalBackend<?> backend)
LocalBackendInitializationListener
performBackendPostFinalizationProcessing
in interface LocalBackendInitializationListener
backend
- The backend that has been taken out of service and is about to be finalized.protected Dn computeMonitorInstanceDn()
MonitorProvider
computeMonitorInstanceDn
in class EntryCache<EntryCacheCfg>
protected MeterRegistryHolder newMeterRegistryHolder(MeterRegistry parent)
EntryCache
MeterRegistryHolder
with the appropriate name prefixes and tags.newMeterRegistryHolder
in class EntryCache<EntryCacheCfg>
parent
- The meter registry to be decorated.public void finalizeEntryCache()
EntryCache
finalizeEntryCache
in class EntryCache<EntryCacheCfg>
protected void recordTry()
EntryCache
recordTry
in class EntryCache<EntryCacheCfg>
protected void recordMiss()
EntryCache
recordMiss
in class EntryCache<EntryCacheCfg>
Copyright 2010-2022 ForgeRock AS.