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>

    Nested classes/interfaces inherited from interface java.util.Map

    Map.Entry<K,V>
  • Field Summary

    Fields inherited from class org.apache.commons.collections4.map.LRUMap

    DEFAULT_MAX_SIZE

    Fields 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 Type
    Method
    Description
    void
    addDB(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.
    getInstance(org.apache.hadoop.hdds.conf.ConfigurationSource conf)
    Return a singleton instance of ContainerCache that holds the DB handlers.
     
    void
    removeDB(String containerDBPath)
    Remove a DB handler from cache.
    protected boolean
    removeLRU(org.apache.commons.collections4.map.AbstractLinkedMap.LinkEntry entry)
    void
    Closes 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, updateEntry

    Methods 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, removeEntry

    Methods 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, values

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.apache.commons.collections4.Get

    containsKey, containsValue, entrySet, isEmpty, keySet, remove, size, values

    Methods inherited from interface org.apache.commons.collections4.Put

    clear, put, putAll
  • Method Details

    • getMetrics

      public ContainerCacheMetrics getMetrics()
    • getInstance

      public static ContainerCache getInstance(org.apache.hadoop.hdds.conf.ConfigurationSource conf)
      Return a singleton instance of ContainerCache that 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:
      removeLRU in class org.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

      public void removeDB(String containerDBPath)
      Remove a DB handler from cache.
      Parameters:
      containerDBPath - - path of the container db file.
    • addDB

      public void addDB(String containerDBPath, ReferenceCountedDB db)
      Add a DB handler into cache.
      Parameters:
      containerDBPath - - DB path of the container.
      db - - DB handler