Package org.apache.hadoop.hdfs.server.federation.store.driver.impl

Class StateStoreBaseImpl

java.lang.Object
org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreDriver
org.apache.hadoop.hdfs.server.federation.store.driver.impl.StateStoreBaseImpl
All Implemented Interfaces:
org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreRecordOperations
Direct Known Subclasses:
StateStoreSerializableImpl

@Public @Evolving public abstract class StateStoreBaseImpl extends StateStoreDriver
Base implementation of a State Store driver. It contains default implementations for the optional functions. These implementations use an uncached read/write all algorithm for all changes. In most cases it is recommended to override the optional functions.

Drivers may optionally override additional routines for performance optimization, such as custom get/put/remove queries, depending on the capabilities of the data store.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <T extends org.apache.hadoop.hdfs.server.federation.store.records.BaseRecord>
    T
    get(Class<T> clazz, org.apache.hadoop.hdfs.server.federation.store.records.Query<T> query)
    Get a single record from the store that matches the query.
    <T extends org.apache.hadoop.hdfs.server.federation.store.records.BaseRecord>
    List<T>
    getMultiple(Class<T> clazz, org.apache.hadoop.hdfs.server.federation.store.records.Query<T> query)
    Get multiple records from the store that match a query.
    <T extends org.apache.hadoop.hdfs.server.federation.store.records.BaseRecord>
    boolean
    put(T record, boolean allowUpdate, boolean errorIfExists)
    Creates a single record.
    <T extends org.apache.hadoop.hdfs.server.federation.store.records.BaseRecord>
    Map<org.apache.hadoop.hdfs.server.federation.store.records.Query<T>,Integer>
    remove(Class<T> clazz, List<org.apache.hadoop.hdfs.server.federation.store.records.Query<T>> queries)
    Remove all records of a specific class that match any query in a list of queries.
    <T extends org.apache.hadoop.hdfs.server.federation.store.records.BaseRecord>
    boolean
    remove(T record)
    Remove a single record.
    <T extends org.apache.hadoop.hdfs.server.federation.store.records.BaseRecord>
    Map<T,Boolean>
    removeMultiple(List<T> records)
    Remove multiple records.

    Methods inherited from class org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreDriver

    close, getConf, getIdentifier, getMetrics, getTime, handleOverwriteAndDelete, init, initDriver, initRecordStorage, isDriverReady, verifyDriverReady

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreRecordOperations

    get, putAll, remove, removeAll
  • Constructor Details

    • StateStoreBaseImpl

      public StateStoreBaseImpl()
  • Method Details

    • get

      public <T extends org.apache.hadoop.hdfs.server.federation.store.records.BaseRecord> T get(Class<T> clazz, org.apache.hadoop.hdfs.server.federation.store.records.Query<T> query) throws IOException
      Description copied from interface: org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreRecordOperations
      Get a single record from the store that matches the query.
      Type Parameters:
      T - Record class of the records.
      Parameters:
      clazz - Class of record to fetch.
      query - Query to filter results.
      Returns:
      A single record matching the query. Null if there are no matching records.
      Throws:
      IOException - If multiple records match or if the data store cannot be queried.
    • getMultiple

      public <T extends org.apache.hadoop.hdfs.server.federation.store.records.BaseRecord> List<T> getMultiple(Class<T> clazz, org.apache.hadoop.hdfs.server.federation.store.records.Query<T> query) throws IOException
      Description copied from interface: org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreRecordOperations
      Get multiple records from the store that match a query. This method assumes the underlying driver does not support filtering. If the driver supports filtering it should overwrite this method.
      Type Parameters:
      T - Record class of the records.
      Parameters:
      clazz - Class of record to fetch.
      query - Query to filter results.
      Returns:
      Records of type class that match the query or empty list if none are found.
      Throws:
      IOException - Throws exception if unable to query the data store.
    • put

      public <T extends org.apache.hadoop.hdfs.server.federation.store.records.BaseRecord> boolean put(T record, boolean allowUpdate, boolean errorIfExists) throws IOException
      Description copied from interface: org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreRecordOperations
      Creates a single record. Optionally updates an existing record with same primary key.
      Type Parameters:
      T - Record class of the records.
      Parameters:
      record - The record to insert or update.
      allowUpdate - True if update of exiting record is allowed.
      errorIfExists - True if an error should be returned when inserting an existing record. Only used if allowUpdate = false.
      Returns:
      True if the operation was successful.
      Throws:
      IOException - Throws exception if unable to query the data store.
    • remove

      public <T extends org.apache.hadoop.hdfs.server.federation.store.records.BaseRecord> boolean remove(T record) throws IOException
      Description copied from interface: org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreRecordOperations
      Remove a single record.
      Type Parameters:
      T - Record class of the records.
      Parameters:
      record - Record to be removed.
      Returns:
      true If the record was successfully removed. False if the record could not be removed or not stored.
      Throws:
      IOException - Throws exception if unable to query the data store.
    • removeMultiple

      public <T extends org.apache.hadoop.hdfs.server.federation.store.records.BaseRecord> Map<T,Boolean> removeMultiple(List<T> records) throws IOException
      Description copied from interface: org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreRecordOperations
      Remove multiple records.
      Type Parameters:
      T - Record class of the records.
      Parameters:
      records - Records to be removed.
      Returns:
      Map of record to a boolean indicating if the record has being removed successfully.
      Throws:
      IOException - Throws exception if unable to query the data store.
    • remove

      public <T extends org.apache.hadoop.hdfs.server.federation.store.records.BaseRecord> Map<org.apache.hadoop.hdfs.server.federation.store.records.Query<T>,Integer> remove(Class<T> clazz, List<org.apache.hadoop.hdfs.server.federation.store.records.Query<T>> queries) throws IOException
      Description copied from interface: org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreRecordOperations
      Remove all records of a specific class that match any query in a list of queries. Requires the getAll implementation to fetch fresh records on each call.
      Type Parameters:
      T - Record class of the records.
      Parameters:
      clazz - The class to match the records with.
      queries - Queries (logical OR) to filter what to remove.
      Returns:
      Map of query to number of records removed by that query.
      Throws:
      IOException - Throws exception if unable to query the data store.