Package org.opends.server.extensions
Class NullEntryCache
- java.lang.Object
-
- org.opends.server.api.MonitorProvider
-
- org.opends.server.api.EntryCache<EntryCacheCfg>
-
- org.opends.server.extensions.NullEntryCache
-
- All Implemented Interfaces:
MeterBinder
public final class NullEntryCache extends EntryCache<EntryCacheCfg>
Implementation of the EntryCache following the null object pattern.
-
-
Field Summary
-
Fields inherited from class org.opends.server.api.MonitorProvider
registry
-
-
Constructor Summary
Constructors Constructor Description NullEntryCache()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.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.SizedEntry
getEntry(Dn entryDN)
Retrieves the entry with its size, with the specified DN from 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.static EntryCache<?>
getInstance()
Returns the null entry cache instance.void
handleLowMemory()
Attempts to react to a scenario in which it is determined that the system is running low on available memory.void
putEntry(SizedEntry entry, String backendID, long entryID)
Stores the provided entry in the cache.boolean
putEntryIfAbsent(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.void
removeEntry(Dn entryDN)
Removes the specified entry from the cache.String
toVerboseString()
Return a verbose string representation of the current cache maps.-
Methods inherited from class org.opends.server.api.EntryCache
addMonitorObjectClassNames, bindTo, computeMonitorInstanceDn, filtersAllowCaching, getEntry, getServerContext, initializeEntryCache, isConfigurationAcceptable, newMeterRegistryHolder, recordMiss, recordTry, setIncludeExcludeFilters
-
Methods inherited from class org.opends.server.api.MonitorProvider
configurationDnToMonitorDn, deregisterAll, getMonitorEntry, getMonitorInstanceDn, toString
-
-
-
-
Method Detail
-
getInstance
public static EntryCache<?> getInstance()
Returns the null entry cache instance.- Returns:
- the null entry cache instance.
-
clear
public void clear()
Description copied from class:EntryCache
Removes all entries from the cache. The cache should still be available for future use.- Specified by:
clear
in classEntryCache<EntryCacheCfg>
-
clearBackend
public void clearBackend(String backendID)
Description copied from class:EntryCache
Removes all entries from the cache that are associated with the provided backend.- Specified by:
clearBackend
in classEntryCache<EntryCacheCfg>
- Parameters:
backendID
- ID of the backend for which to flush the associated entries.
-
containsEntry
public boolean containsEntry(Dn entryDN)
Description copied from class:EntryCache
Indicates 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:
containsEntry
in classEntryCache<EntryCacheCfg>
- Parameters:
entryDN
- The DN for which to make the determination.- Returns:
true
if the entry cache currently contains the entry with the specified DN, orfalse
if not.
-
finalizeEntryCache
public void finalizeEntryCache()
Description copied from class:EntryCache
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.- Specified by:
finalizeEntryCache
in classEntryCache<EntryCacheCfg>
-
getEntry
public SizedEntry getEntry(Dn entryDN)
Description copied from class:EntryCache
Retrieves the entry with its size, with the specified DN from the cache.- Specified by:
getEntry
in 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
null
if it is not present.
-
getEntryCount
public long getEntryCount()
Description copied from class:EntryCache
Retrieves the current number of entries stored within the cache.- Specified by:
getEntryCount
in classEntryCache<EntryCacheCfg>
- Returns:
- The current number of entries stored within the cache.
-
getEntryDN
public Dn getEntryDN(String backendID, long entryID)
Description copied from class:EntryCache
Retrieves the entry DN for the entry with the specified ID on the specific backend from the cache. The caller should have already acquired a read or write lock for the entry if such protection is needed. Note that this method is called from @see #getEntry(Backend backend, long entryID, LockType lockType, List lockList)- Specified by:
getEntryDN
in classEntryCache<EntryCacheCfg>
- Parameters:
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.- Returns:
- The entry DN for the requested entry, or
null
if it is not present in the cache.
-
handleLowMemory
public void handleLowMemory()
Description copied from class:EntryCache
Attempts to react to a scenario in which it is determined that the system is running low on available memory. In this case, the entry cache should attempt to free some memory if possible to try to avoid out of memory errors.- Specified by:
handleLowMemory
in classEntryCache<EntryCacheCfg>
-
putEntry
public void putEntry(SizedEntry entry, String backendID, long entryID)
Description copied from class:EntryCache
Stores 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:
putEntry
in 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 boolean putEntryIfAbsent(SizedEntry entry, String backendID, long entryID)
Description copied from class:EntryCache
Stores 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:
putEntryIfAbsent
in 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.- Returns:
false
if an existing entry or some other problem prevented the method from completing successfully, ortrue
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.
-
removeEntry
public void removeEntry(Dn entryDN)
Description copied from class:EntryCache
Removes the specified entry from the cache.- Specified by:
removeEntry
in classEntryCache<EntryCacheCfg>
- Parameters:
entryDN
- The DN of the entry to remove from the cache.
-
toVerboseString
public String toVerboseString()
Description copied from class:EntryCache
Return 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:
toVerboseString
in 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
null
if all maps are empty.
-
-