Class YarnConfigurationStore
java.lang.Object
org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.conf.YarnConfigurationStore
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
FSSchedulerConfigurationStore,InMemoryConfigurationStore,LeveldbConfigurationStore,ZKConfigurationStore
YarnConfigurationStore exposes the methods needed for retrieving and
persisting
CapacityScheduler configuration via key-value
using write-ahead logging. When configuration mutation is requested, caller
should first log it with logMutation, which persists this pending
mutation. This mutation is merged to the persisted configuration only after
confirmMutation is called.
On startup/recovery, caller should call retrieve to get all
confirmed mutations, then get pending mutations which were not confirmed via
getPendingMutations, and replay/confirm them via
confirmMutation as in the normal case.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classLogMutation encapsulates the fields needed for configuration mutation audit logging and recovery. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidabstract voidclose()Closes the configuration store, releasing any required resources.abstract voidconfirmMutation(YarnConfigurationStore.LogMutation pendingMutation, boolean isValid) Should be called afterlogMutation.abstract voidformat()Format the persisted configuration.abstract longGet the last updated config version.abstract List<YarnConfigurationStore.LogMutation>getConfirmedConfHistory(long fromId) Get a list of confirmed configuration mutations starting from a given id.protected abstract org.apache.hadoop.yarn.server.records.VersionGet schema version of persisted conf store, for detecting compatibility issues when changing conf store schema.protected abstract org.apache.hadoop.yarn.server.records.VersionGet the hard-coded schema version, for comparison against the schema version currently persisted.protected abstract LinkedList<YarnConfigurationStore.LogMutation>getLogs()Get a list of configuration mutations.abstract voidinitialize(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.conf.Configuration schedConf, RMContext rmContext) Initialize the configuration store, with schedConf as the initial scheduler configuration.abstract voidlogMutation(YarnConfigurationStore.LogMutation logMutation) Logs the configuration change to backing store.abstract org.apache.hadoop.conf.Configurationretrieve()Retrieve the persisted configuration.protected abstract voidPersist the hard-coded schema version to the conf store.
-
Field Details
-
LOG
public static final org.slf4j.Logger LOG
-
-
Constructor Details
-
YarnConfigurationStore
public YarnConfigurationStore()
-
-
Method Details
-
initialize
public abstract void initialize(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.conf.Configuration schedConf, RMContext rmContext) throws Exception Initialize the configuration store, with schedConf as the initial scheduler configuration. If a persisted store already exists, use the scheduler configuration stored there, and ignore schedConf.- Parameters:
conf- configuration to initialize store withschedConf- Initial key-value scheduler configuration to persist.rmContext- RMContext for this configuration store- Throws:
IOException- if initialization failsException
-
close
Closes the configuration store, releasing any required resources.- Specified by:
closein interfaceAutoCloseable- Throws:
IOException- on failure to close
-
logMutation
Logs the configuration change to backing store.- Parameters:
logMutation- configuration change to be persisted in write ahead log- Throws:
IOException- if logging failsException
-
confirmMutation
public abstract void confirmMutation(YarnConfigurationStore.LogMutation pendingMutation, boolean isValid) throws Exception Should be called afterlogMutation. Gets the pending mutation last logged bylogMutationand marks the mutation as persisted (no longer pending). If isValid is true, merge the mutation with the persisted configuration.- Parameters:
pendingMutation- the log mutation to applyisValid- if true, update persisted configuration with pending mutation.- Throws:
Exception- if mutation confirmation fails
-
retrieve
Retrieve the persisted configuration.- Returns:
- configuration as key-value
- Throws:
IOException- an I/O exception has occurred.
-
format
Format the persisted configuration.- Throws:
IOException- on failure to formatException
-
getConfigVersion
Get the last updated config version.- Returns:
- Last updated config version.
- Throws:
Exception- On version fetch failure.
-
getConfirmedConfHistory
Get a list of confirmed configuration mutations starting from a given id.- Parameters:
fromId- id from which to start getting mutations, inclusive- Returns:
- list of configuration mutations
-
getConfStoreVersion
protected abstract org.apache.hadoop.yarn.server.records.Version getConfStoreVersion() throws ExceptionGet schema version of persisted conf store, for detecting compatibility issues when changing conf store schema.- Returns:
- Schema version currently used by the persisted configuration store.
- Throws:
Exception- On version fetch failure
-
getLogs
Get a list of configuration mutations.- Returns:
- list of configuration mutations.
- Throws:
Exception- On mutation fetch failure
-
storeVersion
Persist the hard-coded schema version to the conf store.- Throws:
Exception- On storage failure
-
getCurrentVersion
protected abstract org.apache.hadoop.yarn.server.records.Version getCurrentVersion()Get the hard-coded schema version, for comparison against the schema version currently persisted.- Returns:
- Current hard-coded schema version
-
checkVersion
- Throws:
Exception
-