Class StateStoreService
java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.service.CompositeService
org.apache.hadoop.hdfs.server.federation.store.StateStoreService
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.hadoop.service.Service
@Private
@Evolving
public class StateStoreService
extends org.apache.hadoop.service.CompositeService
A service to initialize a
StateStoreDriver and maintain the connection to the data store. There are
multiple state store driver connections supported:
- File
StateStoreFileImpl - FileSystem
StateStoreFileSystemImpl - MySQL
StateStoreMySQLImpl - ZooKeeper
StateStoreZooKeeperImpl
The service also supports the dynamic registration of record stores like:
MembershipStore: state of the Namenodes in the federation.MountTableStore: Mount table between to subclusters. SeeViewFs.RouterStore: Router state in the federation.DisabledNameserviceStore: Disabled name services.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.service.CompositeService
org.apache.hadoop.service.CompositeService.CompositeServiceShutdownHookNested classes/interfaces inherited from interface org.apache.hadoop.service.Service
org.apache.hadoop.service.Service.STATE -
Field Summary
Fields inherited from class org.apache.hadoop.service.CompositeService
STOP_ONLY_STARTED_SERVICES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidManually shuts down the driver.longThe last time the state store cache was fully updated.Get the state store driver.Fetch a unique identifier for this state store instance.Get the metrics for the State Store.<T extends RecordStore<? extends BaseRecord>>
List<T>Get the list of all RecordStores.<T extends RecordStore<?>>
TgetRegisteredRecordStore(Class<T> recordStoreClass) Get the record store in this State Store for a given interface.Collection<Class<? extends BaseRecord>>List of records supported by this State Store.booleanCheck if the driver is ready to be used.booleanUpdate the cache for a specific record store.booleanUpdate the cache for a specific record store.voidLoad the State Store driver.voidRefresh the cache with information from the State Store.voidrefreshCaches(boolean force) Refresh the cache with information from the State Store.voidregisterCacheExternal(StateStoreCache client) Register a cached record store for automatic periodic cache updates.protected voidserviceInit(org.apache.hadoop.conf.Configuration config) Initialize the State Store and the connection to the back-end.protected voidprotected voidvoidsetIdentifier(String id) Set a unique synchronization identifier for this store.voidStops the cache update service.Methods inherited from class org.apache.hadoop.service.CompositeService
addIfService, addService, getServices, removeServiceMethods inherited from class org.apache.hadoop.service.AbstractService
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStop
-
Constructor Details
-
StateStoreService
public StateStoreService()
-
-
Method Details
-
serviceInit
Initialize the State Store and the connection to the back-end.- Overrides:
serviceInitin classorg.apache.hadoop.service.CompositeService- Parameters:
config- Configuration for the State Store.- Throws:
Exception- Cannot create driver for the State Store.
-
serviceStart
- Overrides:
serviceStartin classorg.apache.hadoop.service.CompositeService- Throws:
Exception
-
serviceStop
- Overrides:
serviceStopin classorg.apache.hadoop.service.CompositeService- Throws:
Exception
-
getRegisteredRecordStore
Get the record store in this State Store for a given interface.- Type Parameters:
T- The type of the record store.- Parameters:
recordStoreClass- Class of the record store.- Returns:
- Registered record store or null if not found.
-
getRecordStores
Get the list of all RecordStores.- Type Parameters:
T- The type of the record stores that are returned.- Returns:
- a list of each RecordStore.
-
getSupportedRecords
List of records supported by this State Store.- Returns:
- List of supported record classes.
-
loadDriver
public void loadDriver()Load the State Store driver. If successful, refresh cached data tables. -
isDriverReady
public boolean isDriverReady()Check if the driver is ready to be used.- Returns:
- If the driver is ready.
-
closeDriver
Manually shuts down the driver.- Throws:
Exception- If the driver cannot be closed.
-
getDriver
Get the state store driver.- Returns:
- State store driver.
-
getIdentifier
Fetch a unique identifier for this state store instance. Typically, it is the address of the router.- Returns:
- Unique identifier for this store.
-
setIdentifier
Set a unique synchronization identifier for this store.- Parameters:
id- Unique identifier, typically the router's RPC address.
-
getCacheUpdateTime
public long getCacheUpdateTime()The last time the state store cache was fully updated.- Returns:
- Timestamp.
-
stopCacheUpdateService
@VisibleForTesting public void stopCacheUpdateService()Stops the cache update service. -
registerCacheExternal
Register a cached record store for automatic periodic cache updates.- Parameters:
client- Client to the state store.
-
refreshCaches
public void refreshCaches()Refresh the cache with information from the State Store. Called periodically by the CacheUpdateService to maintain data caches and versions. -
refreshCaches
public void refreshCaches(boolean force) Refresh the cache with information from the State Store. Called periodically by the CacheUpdateService to maintain data caches and versions.- Parameters:
force- If we force the refresh.
-
loadCache
Update the cache for a specific record store.- Parameters:
clazz- Class of the record store.- Returns:
- If the cached was loaded.
- Throws:
IOException- if the cache update failed.
-
loadCache
Update the cache for a specific record store.- Parameters:
clazz- Class of the record store.force- Force the update ignoring cached periods.- Returns:
- If the cached was loaded.
- Throws:
IOException- if the cache update failed.
-
getMetrics
Get the metrics for the State Store.- Returns:
- State Store metrics.
-