Class StateStoreDriver
java.lang.Object
org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreDriver
- All Implemented Interfaces:
StateStoreRecordOperations
- Direct Known Subclasses:
StateStoreBaseImpl
@Public
@Evolving
public abstract class StateStoreDriver
extends Object
implements StateStoreRecordOperations
Driver class for an implementation of a
StateStoreService
provider. Driver implementations will extend this class and implement some of
the default methods.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the State Store driver connection.protected org.apache.hadoop.conf.ConfigurationgetConf()Get the State Store configuration.Gets a unique identifier for the running task/process.Get the metrics for the State Store.longgetTime()Returns the current time synchronization from the underlying store.<R extends BaseRecord>
List<R>handleOverwriteAndDelete(List<R> commitRecords, List<R> deleteRecords) Try to overwrite records in commitRecords and remove records in deleteRecords.booleaninit(org.apache.hadoop.conf.Configuration config, String id, Collection<Class<? extends BaseRecord>> records, StateStoreMetrics stateStoreMetrics) Initialize the state store connection.abstract booleanPrepare the driver to access data storage.abstract <T extends BaseRecord>
booleaninitRecordStorage(String className, Class<T> clazz) Initialize storage for a single record class.abstract booleanCheck if the driver is currently running and the data store connection is valid.voidCheck if the driver is ready to be used and throw an exception otherwise.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreRecordOperations
get, get, getMultiple, put, putAll, remove, remove, remove, removeAll, removeMultiple
-
Constructor Details
-
StateStoreDriver
public StateStoreDriver()
-
-
Method Details
-
init
public boolean init(org.apache.hadoop.conf.Configuration config, String id, Collection<Class<? extends BaseRecord>> records, StateStoreMetrics stateStoreMetrics) Initialize the state store connection.- Parameters:
config- Configuration for the driver.id- Identifier for the driver.records- Records that are supported.stateStoreMetrics- State store metrics.- Returns:
- If initialized and ready, false if failed to initialize driver.
-
getConf
protected org.apache.hadoop.conf.Configuration getConf()Get the State Store configuration.- Returns:
- Configuration for the State Store.
-
getIdentifier
Gets a unique identifier for the running task/process. Typically, the router address.- Returns:
- Unique identifier for the running task.
-
getMetrics
Get the metrics for the State Store.- Returns:
- State Store metrics.
-
initDriver
public abstract boolean initDriver()Prepare the driver to access data storage.- Returns:
- True if the driver was successfully initialized. If false is returned, the state store will periodically attempt to re-initialize the driver and the router will remain in safe mode until the driver is initialized.
-
initRecordStorage
Initialize storage for a single record class.- Type Parameters:
T- Type of the state store record.- Parameters:
className- String reference of the record class to initialize, used to construct paths and file names for the record. Determined by configuration settings for the specific driver.clazz- Record type corresponding to the provided name.- Returns:
- True if successful, false otherwise.
-
isDriverReady
public abstract boolean isDriverReady()Check if the driver is currently running and the data store connection is valid.- Returns:
- True if the driver is initialized and the data store is ready.
-
verifyDriverReady
Check if the driver is ready to be used and throw an exception otherwise.- Throws:
StateStoreUnavailableException- If the driver is not ready.
-
close
Close the State Store driver connection.- Throws:
Exception- if something goes wrong while closing the state store driver connection.
-
getTime
public long getTime()Returns the current time synchronization from the underlying store. Override for stores that supply a current date. The data store driver is responsible for maintaining the official synchronization time/date for all distributed components.- Returns:
- Current time stamp, used for all synchronization dates.
-
handleOverwriteAndDelete
public <R extends BaseRecord> List<R> handleOverwriteAndDelete(List<R> commitRecords, List<R> deleteRecords) throws IOException Try to overwrite records in commitRecords and remove records in deleteRecords. Should return null if async mode is used. Else return removed records.- Type Parameters:
R- record class- Parameters:
commitRecords- records to overwrite in state storedeleteRecords- records to remove from state store- Returns:
- null if async mode is used, else removed records
- Throws:
IOException- when there is a failure during overwriting or deletion
-