Class ContainerCache
java.lang.Object
java.util.AbstractMap
org.apache.commons.collections4.map.AbstractHashedMap
org.apache.commons.collections4.map.AbstractLinkedMap
org.apache.commons.collections4.map.LRUMap
org.apache.hadoop.ozone.container.common.utils.ContainerCache
- All Implemented Interfaces:
Serializable,Cloneable,Map,org.apache.commons.collections4.BoundedMap,org.apache.commons.collections4.Get,org.apache.commons.collections4.IterableGet,org.apache.commons.collections4.IterableMap,org.apache.commons.collections4.OrderedMap,org.apache.commons.collections4.Put
public final class ContainerCache
extends org.apache.commons.collections4.map.LRUMap
container cache is a LRUMap that maintains the DB handles.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.commons.collections4.map.AbstractLinkedMap
org.apache.commons.collections4.map.AbstractLinkedMap.EntrySetIterator<K,V>, org.apache.commons.collections4.map.AbstractLinkedMap.KeySetIterator<K>, org.apache.commons.collections4.map.AbstractLinkedMap.LinkEntry<K, V>, org.apache.commons.collections4.map.AbstractLinkedMap.LinkIterator<K, V>, org.apache.commons.collections4.map.AbstractLinkedMap.LinkMapIterator<K, V>, org.apache.commons.collections4.map.AbstractLinkedMap.ValuesIterator<V> Nested classes/interfaces inherited from class org.apache.commons.collections4.map.AbstractHashedMap
org.apache.commons.collections4.map.AbstractHashedMap.EntrySet<K,V>, org.apache.commons.collections4.map.AbstractHashedMap.HashEntry<K, V>, org.apache.commons.collections4.map.AbstractHashedMap.HashIterator<K, V>, org.apache.commons.collections4.map.AbstractHashedMap.HashMapIterator<K, V>, org.apache.commons.collections4.map.AbstractHashedMap.KeySet<K>, org.apache.commons.collections4.map.AbstractHashedMap.Values<V> Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
Fields inherited from class org.apache.commons.collections4.map.LRUMap
DEFAULT_MAX_SIZEFields inherited from class org.apache.commons.collections4.map.AbstractHashedMap
DEFAULT_CAPACITY, DEFAULT_LOAD_FACTOR, DEFAULT_THRESHOLD, GETKEY_INVALID, GETVALUE_INVALID, MAXIMUM_CAPACITY, NO_NEXT_ENTRY, NO_PREVIOUS_ENTRY, NULL, REMOVE_INVALID, SETVALUE_INVALID -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDB(String containerDBPath, ReferenceCountedDB db) Add a DB handler into cache.getDB(long containerID, String containerDBType, String containerDBPath, String schemaVersion, org.apache.hadoop.hdds.conf.ConfigurationSource conf) Returns a DB handle if available, create the handler otherwise.static ContainerCachegetInstance(org.apache.hadoop.hdds.conf.ConfigurationSource conf) Return a singleton instance ofContainerCachethat holds the DB handlers.voidRemove a DB handler from cache.protected booleanremoveLRU(org.apache.commons.collections4.map.AbstractLinkedMap.LinkEntry entry) voidCloses all the db instances and resets the cache.Methods inherited from class org.apache.commons.collections4.map.LRUMap
addMapping, clone, doReadObject, doWriteObject, get, get, isFull, isScanUntilRemovable, maxSize, moveToMRU, reuseMapping, updateEntryMethods inherited from class org.apache.commons.collections4.map.AbstractLinkedMap
addEntry, clear, containsValue, createEntry, createEntrySetIterator, createKeySetIterator, createValuesIterator, entryAfter, entryBefore, firstKey, getEntry, getEntry, init, lastKey, mapIterator, nextKey, previousKey, removeEntryMethods inherited from class org.apache.commons.collections4.map.AbstractHashedMap
calculateNewCapacity, calculateThreshold, checkCapacity, containsKey, convertKey, destroyEntry, ensureCapacity, entryHashCode, entryKey, entryNext, entrySet, entryValue, equals, hash, hashCode, hashIndex, isEmpty, isEqualKey, isEqualValue, keySet, put, putAll, remove, removeMapping, reuseEntry, size, toString, valuesMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.commons.collections4.Get
containsKey, containsValue, entrySet, isEmpty, keySet, remove, size, valuesMethods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesMethods inherited from interface org.apache.commons.collections4.Put
clear, put, putAll
-
Method Details
-
getMetrics
-
getInstance
Return a singleton instance ofContainerCachethat holds the DB handlers.- Parameters:
conf- - Configuration.- Returns:
- A instance of
ContainerCache.
-
shutdownCache
public void shutdownCache()Closes all the db instances and resets the cache. -
removeLRU
protected boolean removeLRU(org.apache.commons.collections4.map.AbstractLinkedMap.LinkEntry entry) - Overrides:
removeLRUin classorg.apache.commons.collections4.map.LRUMap
-
getDB
public ReferenceCountedDB getDB(long containerID, String containerDBType, String containerDBPath, String schemaVersion, org.apache.hadoop.hdds.conf.ConfigurationSource conf) throws IOException Returns a DB handle if available, create the handler otherwise.- Parameters:
containerID- - ID of the container.containerDBType- - DB type of the container.containerDBPath- - DB path of the container.schemaVersion- - Schema version of the container.conf- - Hadoop Configuration.- Returns:
- ReferenceCountedDB.
- Throws:
IOException
-
removeDB
Remove a DB handler from cache.- Parameters:
containerDBPath- - path of the container db file.
-
addDB
Add a DB handler into cache.- Parameters:
containerDBPath- - DB path of the container.db- - DB handler
-