Class CachedRecordStore<R extends BaseRecord>

java.lang.Object
org.apache.hadoop.hdfs.server.federation.store.RecordStore<R>
org.apache.hadoop.hdfs.server.federation.store.CachedRecordStore<R>
Type Parameters:
R - Record to store by this interface.
All Implemented Interfaces:
StateStoreCache
Direct Known Subclasses:
DisabledNameserviceStore, MembershipStore, MountTableStore, RouterStore

public abstract class CachedRecordStore<R extends BaseRecord> extends RecordStore<R> implements StateStoreCache
Record store that takes care of caching the records in memory.
  • Constructor Details

    • CachedRecordStore

      protected CachedRecordStore(Class<R> clazz, StateStoreDriver driver)
      Create a new cached record store.
      Parameters:
      clazz - Class of the record to store.
      driver - State Store driver.
    • CachedRecordStore

      protected CachedRecordStore(Class<R> clazz, StateStoreDriver driver, boolean over)
      Create a new cached record store.
      Parameters:
      clazz - Class of the record to store.
      driver - State Store driver.
      over - If the entries should be overridden if they expire
  • Method Details

    • loadCache

      public boolean loadCache(boolean force) throws IOException
      Description copied from interface: StateStoreCache
      Load the cache from the State Store. Called by the cache update service when the data has been reloaded.
      Specified by:
      loadCache in interface StateStoreCache
      Parameters:
      force - If we force the load.
      Returns:
      If the cache was loaded successfully.
      Throws:
      IOException - If there was an error loading the cache.
    • overrideExpiredRecords

      public void overrideExpiredRecords(QueryResult<R> query) throws IOException
      Updates the state store with any record overrides we detected, such as an expired state. If an expired record exists beyond deletion time, it is removed.
      Parameters:
      query - RecordQueryResult containing the data to be inspected.
      Throws:
      IOException - If the values cannot be updated.
    • overrideExpiredRecord

      public void overrideExpiredRecord(R record) throws IOException
      Updates the state store with any record overrides we detected, such as an expired state.
      Parameters:
      record - record to be updated.
      Throws:
      IOException - If the values cannot be updated.
    • getCachedRecords

      public List<R> getCachedRecords() throws StateStoreUnavailableException
      Get all the cached records.
      Returns:
      Copy of the cached records.
      Throws:
      StateStoreUnavailableException - If the State store is not available.
    • getCachedRecordsAndTimeStamp

      protected QueryResult<R> getCachedRecordsAndTimeStamp() throws StateStoreUnavailableException
      Get all the cached records and the time stamp of the cache.
      Returns:
      Copy of the cached records and the time stamp.
      Throws:
      StateStoreUnavailableException - If the State store is not available.