Class RMStateStore
java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.hadoop.service.Service
- Direct Known Subclasses:
FileSystemRMStateStore,LeveldbRMStateStore,MemoryRMStateStore,NullRMStateStore,ZKRMStateStore
@Private
@Unstable
public abstract class RMStateStore
extends org.apache.hadoop.service.AbstractService
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classState of the ResourceManagerstatic enumThe enum defines state of RMStateStore.Nested classes/interfaces inherited from interface org.apache.hadoop.service.Service
org.apache.hadoop.service.Service.STATE -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.apache.hadoop.io.Textstatic final org.apache.hadoop.io.Textprotected static final Stringprotected longprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringstatic final org.slf4j.Loggerprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected ResourceManagerstatic final Stringprotected static final Stringprotected static final Stringprotected org.apache.hadoop.yarn.event.EventHandlerprotected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid1) Versioning scheme: major.minor.protected abstract voidDerived classes close themselves using this method.abstract voidDerived classes must implement this method to delete the state store.abstract longGet the current epoch of RM and increment the value.org.apache.hadoop.security.CredentialsgetCredentialsFromAppAttempt(RMAppAttempt appAttempt) protected abstract org.apache.hadoop.yarn.server.records.VersionGet the current version of the underlying state store.protected org.apache.hadoop.yarn.event.EventHandlerprotected voidprotected abstract voidinitInternal(org.apache.hadoop.conf.Configuration conf) Derived classes initialize themselves using this method.protected booleanabstract RMStateStore.RMStateBlocking API The derived class must recover state from the store and return a new RMState object populated with that state This must not be called on the dispatcher thread.protected abstract org.apache.hadoop.yarn.server.records.VersionDerived class use this method to load the version information from state store.protected longnextEpoch(long epoch) Compute the next epoch value by incrementing by one.protected voidnotifyStoreOperationFailed(Exception failureCause) This method is called to notify the ResourceManager that the store operation has failed.abstract voidremoveApplication(org.apache.hadoop.yarn.api.records.ApplicationId removeAppId) Derived classes must implement this method to remove application from the state store.voidremoveApplication(RMApp app) Non-blocking API ResourceManager services call this to remove an application from the state store This does not block the dispatcher threads There is no notification of completion for this operation.voidremoveApplicationAttempt(org.apache.hadoop.yarn.api.records.ApplicationAttemptId applicationAttemptId) Non-blocking API ResourceManager services call this to remove an attempt from the state store This does not block the dispatcher threads There is no notification of completion for this operation.protected abstract voidremoveApplicationAttemptInternal(org.apache.hadoop.yarn.api.records.ApplicationAttemptId attemptId) Blocking API Derived classes must implement this method to remove the state of specified attempt.protected abstract voidBlocking API Derived classes must implement this method to remove the state of an application and its attempts.voidremoveReservation(String planName, String reservationIdName) protected abstract voidremoveReservationState(String planName, String reservationIdName) Blocking API Derived classes must implement this method to remove the state of a reservation allocation.voidremoveRMDelegationToken(org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier rmDTIdentifier) RMDTSecretManager call this to remove the state of a delegation token.protected abstract voidremoveRMDelegationTokenState(org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier rmDTIdentifier) Blocking API Derived classes must implement this method to remove the state of RMDelegationToken.voidremoveRMDTMasterKey(org.apache.hadoop.security.token.delegation.DelegationKey delegationKey) RMDTSecretManager call this to remove the state of a master key.protected abstract voidremoveRMDTMasterKeyState(org.apache.hadoop.security.token.delegation.DelegationKey delegationKey) Blocking API Derived classes must implement this method to remove the state of DelegationToken Master Key.protected voidserviceInit(org.apache.hadoop.conf.Configuration conf) protected voidprotected voidvoidvoidsetRMDispatcher(org.apache.hadoop.yarn.event.Dispatcher dispatcher) Dispatcher used to send state operation completion events to ResourceManager services.protected abstract voidDerived classes start themselves using this method.protected abstract voidstoreApplicationAttemptStateInternal(org.apache.hadoop.yarn.api.records.ApplicationAttemptId attemptId, ApplicationAttemptStateData attemptStateData) Blocking API Derived classes must implement this method to store the state of an application attempt.protected abstract voidstoreApplicationStateInternal(org.apache.hadoop.yarn.api.records.ApplicationId appId, ApplicationStateData appStateData) Blocking API Derived classes must implement this method to store the state of an application.voidstoreNewApplication(RMApp app) Non-Blocking API ResourceManager services use this to store the application's state This does not block the dispatcher threads RMAppStoredEvent will be sent on completion to notify the RMApp.voidstoreNewApplicationAttempt(RMAppAttempt appAttempt) voidstoreNewReservation(org.apache.hadoop.yarn.proto.YarnProtos.ReservationAllocationStateProto reservationAllocation, String planName, String reservationIdName) Blocking Apis to maintain reservation state.voidstoreOrUpdateAMRMTokenSecretManager(AMRMTokenSecretManagerState amrmTokenSecretManagerState, boolean isUpdate) Store or Update state of AMRMToken Master Key.protected abstract voidstoreOrUpdateAMRMTokenSecretManagerState(AMRMTokenSecretManagerState amrmTokenSecretManagerState, boolean isUpdate) Blocking API Derived classes must implement this method to store or update the state of AMRMToken Master Key.voidstoreProxyCACert(X509Certificate caCert, PrivateKey caPrivateKey) ProxyCAManager calls this to store the CA Certificate and Private Key.protected abstract voidstoreProxyCACertState(X509Certificate caCert, PrivateKey caPrivateKey) Blocking API Derived classes must implement this method to store the CA Certificate and Private Key.protected abstract voidstoreReservationState(org.apache.hadoop.yarn.proto.YarnProtos.ReservationAllocationStateProto reservationAllocation, String planName, String reservationIdName) Blocking API Derived classes must implement this method to store the state of a reservation allocation.voidstoreRMDelegationToken(org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier rmDTIdentifier, Long renewDate) RMDTSecretManager call this to store the state of a delegation token and sequence number.protected abstract voidstoreRMDelegationTokenState(org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier rmDTIdentifier, Long renewDate) Blocking API Derived classes must implement this method to store the state of RMDelegationToken and sequence number.voidstoreRMDTMasterKey(org.apache.hadoop.security.token.delegation.DelegationKey delegationKey) RMDTSecretManager call this to store the state of a master key.protected abstract voidstoreRMDTMasterKeyState(org.apache.hadoop.security.token.delegation.DelegationKey delegationKey) Blocking API Derived classes must implement this method to store the state of DelegationToken Master Key.protected abstract voidDerived class use this method to store the version information.voidupdateApplicationAttemptState(ApplicationAttemptStateData attemptState) protected abstract voidupdateApplicationAttemptStateInternal(org.apache.hadoop.yarn.api.records.ApplicationAttemptId attemptId, ApplicationAttemptStateData attemptStateData) voidupdateApplicationState(ApplicationStateData appState) voidupdateApplicationState(ApplicationStateData appState, boolean notifyApp) protected abstract voidupdateApplicationStateInternal(org.apache.hadoop.yarn.api.records.ApplicationId appId, ApplicationStateData appStateData) voidupdateApplicationStateSynchronously(ApplicationStateData appState, boolean notifyApp, org.apache.hadoop.thirdparty.com.google.common.util.concurrent.SettableFuture<Object> resultFuture) voidvoidupdateRMDelegationToken(org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier rmDTIdentifier, Long renewDate) RMDTSecretManager call this to update the state of a delegation token and sequence number.protected abstract voidupdateRMDelegationTokenState(org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier rmDTIdentifier, Long renewDate) Blocking API Derived classes must implement this method to update the state of RMDelegationToken and sequence number.Methods 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
-
Field Details
-
RM_APP_ROOT
- See Also:
-
RM_DT_SECRET_MANAGER_ROOT
- See Also:
-
RM_DELEGATION_TOKENS_ROOT_ZNODE_NAME
- See Also:
-
DELEGATION_KEY_PREFIX
- See Also:
-
DELEGATION_TOKEN_PREFIX
- See Also:
-
DELEGATION_TOKEN_SEQUENCE_NUMBER_PREFIX
- See Also:
-
AMRMTOKEN_SECRET_MANAGER_ROOT
- See Also:
-
RESERVATION_SYSTEM_ROOT
- See Also:
-
PROXY_CA_ROOT
- See Also:
-
PROXY_CA_CERT_NODE
- See Also:
-
PROXY_CA_PRIVATE_KEY_NODE
- See Also:
-
VERSION_NODE
- See Also:
-
EPOCH_NODE
- See Also:
-
baseEpoch
protected long baseEpoch -
resourceManager
-
LOG
public static final org.slf4j.Logger LOG -
rmStateStoreEventHandler
@VisibleForTesting protected org.apache.hadoop.yarn.event.EventHandler rmStateStoreEventHandler -
AM_RM_TOKEN_SERVICE
public static final org.apache.hadoop.io.Text AM_RM_TOKEN_SERVICE -
AM_CLIENT_TOKEN_MASTER_KEY_NAME
public static final org.apache.hadoop.io.Text AM_CLIENT_TOKEN_MASTER_KEY_NAME
-
-
Constructor Details
-
RMStateStore
public RMStateStore()
-
-
Method Details
-
setRMDispatcher
public void setRMDispatcher(org.apache.hadoop.yarn.event.Dispatcher dispatcher) Dispatcher used to send state operation completion events to ResourceManager services.- Parameters:
dispatcher- Dispatcher.
-
serviceInit
- Overrides:
serviceInitin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
serviceStart
- Overrides:
serviceStartin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
initInternal
Derived classes initialize themselves using this method.- Parameters:
conf- Configuration.- Throws:
Exception- error occur.
-
startInternal
Derived classes start themselves using this method. The base class is started and the event dispatcher is ready to use at this point.- Throws:
Exception- error occur.
-
serviceStop
- Overrides:
serviceStopin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
closeInternal
Derived classes close themselves using this method. The base class will be closed and the event dispatcher will be shutdown after this.- Throws:
Exception- error occur.
-
checkVersion
1) Versioning scheme: major.minor. For e.g. 1.0, 1.1, 1.2...1.25, 2.0 etc. 2) Any incompatible change of state-store is a major upgrade, and any compatible change of state-store is a minor upgrade. 3) If theres's no version, treat it as CURRENT_VERSION_INFO. 4) Within a minor upgrade, say 1.1 to 1.2: overwrite the version info and proceed as normal. 5) Within a major upgrade, say 1.2 to 2.0: throw exception and indicate user to use a separate upgrade tool to upgrade RM state.- Throws:
Exception- error occur.
-
loadVersion
Derived class use this method to load the version information from state store.- Returns:
- current version.
- Throws:
Exception- error occur.
-
storeVersion
Derived class use this method to store the version information.- Throws:
Exception- error occur.
-
getCurrentVersion
protected abstract org.apache.hadoop.yarn.server.records.Version getCurrentVersion()Get the current version of the underlying state store.- Returns:
- current version.
-
getAndIncrementEpoch
Get the current epoch of RM and increment the value.- Returns:
- current epoch.
- Throws:
Exception- error occur.
-
nextEpoch
protected long nextEpoch(long epoch) Compute the next epoch value by incrementing by one. Wraps around if the epoch range is exceeded so that when federation is enabled epoch collisions can be avoided.- Parameters:
epoch- epoch value.- Returns:
- next epoch value.
-
loadState
Blocking API The derived class must recover state from the store and return a new RMState object populated with that state This must not be called on the dispatcher thread.- Returns:
- RMState.
- Throws:
Exception- error occur.
-
storeNewApplication
Non-Blocking API ResourceManager services use this to store the application's state This does not block the dispatcher threads RMAppStoredEvent will be sent on completion to notify the RMApp.- Parameters:
app- rmApp.
-
updateApplicationState
-
updateApplicationState
-
updateApplicationStateSynchronously
public void updateApplicationStateSynchronously(ApplicationStateData appState, boolean notifyApp, org.apache.hadoop.thirdparty.com.google.common.util.concurrent.SettableFuture<Object> resultFuture) -
updateFencedState
public void updateFencedState() -
storeApplicationStateInternal
protected abstract void storeApplicationStateInternal(org.apache.hadoop.yarn.api.records.ApplicationId appId, ApplicationStateData appStateData) throws Exception Blocking API Derived classes must implement this method to store the state of an application.- Parameters:
appId- application Id.appStateData- application StateData.- Throws:
Exception- error occur.
-
updateApplicationStateInternal
protected abstract void updateApplicationStateInternal(org.apache.hadoop.yarn.api.records.ApplicationId appId, ApplicationStateData appStateData) throws Exception - Throws:
Exception
-
storeNewApplicationAttempt
-
updateApplicationAttemptState
-
storeApplicationAttemptStateInternal
protected abstract void storeApplicationAttemptStateInternal(org.apache.hadoop.yarn.api.records.ApplicationAttemptId attemptId, ApplicationAttemptStateData attemptStateData) throws Exception Blocking API Derived classes must implement this method to store the state of an application attempt.- Parameters:
attemptId- Application AttemptId.attemptStateData- Application AttemptStateData.- Throws:
Exception- error occur.
-
updateApplicationAttemptStateInternal
protected abstract void updateApplicationAttemptStateInternal(org.apache.hadoop.yarn.api.records.ApplicationAttemptId attemptId, ApplicationAttemptStateData attemptStateData) throws Exception - Throws:
Exception
-
storeRMDelegationToken
public void storeRMDelegationToken(org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier rmDTIdentifier, Long renewDate) RMDTSecretManager call this to store the state of a delegation token and sequence number.- Parameters:
rmDTIdentifier- RMDelegationTokenIdentifier.renewDate- token renew date.
-
storeRMDelegationTokenState
protected abstract void storeRMDelegationTokenState(org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier rmDTIdentifier, Long renewDate) throws Exception Blocking API Derived classes must implement this method to store the state of RMDelegationToken and sequence number.- Parameters:
rmDTIdentifier- RMDelegationTokenIdentifier.renewDate- token renew date.- Throws:
Exception- error occur.
-
removeRMDelegationToken
public void removeRMDelegationToken(org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier rmDTIdentifier) RMDTSecretManager call this to remove the state of a delegation token.- Parameters:
rmDTIdentifier- RMDelegationTokenIdentifier.
-
removeRMDelegationTokenState
protected abstract void removeRMDelegationTokenState(org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier rmDTIdentifier) throws Exception Blocking API Derived classes must implement this method to remove the state of RMDelegationToken.- Parameters:
rmDTIdentifier- RMDelegationTokenIdentifier.- Throws:
Exception- error occurs.
-
updateRMDelegationToken
public void updateRMDelegationToken(org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier rmDTIdentifier, Long renewDate) RMDTSecretManager call this to update the state of a delegation token and sequence number.- Parameters:
rmDTIdentifier- RMDelegationTokenIdentifier.renewDate- token renew date.
-
updateRMDelegationTokenState
protected abstract void updateRMDelegationTokenState(org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier rmDTIdentifier, Long renewDate) throws Exception Blocking API Derived classes must implement this method to update the state of RMDelegationToken and sequence number.- Parameters:
rmDTIdentifier- RMDelegationTokenIdentifier.renewDate- token renew date.- Throws:
Exception- error occurs.
-
storeRMDTMasterKey
public void storeRMDTMasterKey(org.apache.hadoop.security.token.delegation.DelegationKey delegationKey) RMDTSecretManager call this to store the state of a master key.- Parameters:
delegationKey- DelegationToken Master Key.
-
storeRMDTMasterKeyState
protected abstract void storeRMDTMasterKeyState(org.apache.hadoop.security.token.delegation.DelegationKey delegationKey) throws Exception Blocking API Derived classes must implement this method to store the state of DelegationToken Master Key.- Parameters:
delegationKey- DelegationToken Master Key.- Throws:
Exception- error occur.
-
removeRMDTMasterKey
public void removeRMDTMasterKey(org.apache.hadoop.security.token.delegation.DelegationKey delegationKey) RMDTSecretManager call this to remove the state of a master key.- Parameters:
delegationKey- DelegationToken Master Key.
-
storeNewReservation
public void storeNewReservation(org.apache.hadoop.yarn.proto.YarnProtos.ReservationAllocationStateProto reservationAllocation, String planName, String reservationIdName) Blocking Apis to maintain reservation state.- Parameters:
reservationAllocation- reservation Allocation.planName- plan Name.reservationIdName- reservationId Name.
-
removeReservation
-
storeReservationState
protected abstract void storeReservationState(org.apache.hadoop.yarn.proto.YarnProtos.ReservationAllocationStateProto reservationAllocation, String planName, String reservationIdName) throws Exception Blocking API Derived classes must implement this method to store the state of a reservation allocation.- Parameters:
reservationAllocation- reservation Allocation.planName- plan Name.reservationIdName- reservationId Name.- Throws:
Exception- error occurs.
-
removeReservationState
protected abstract void removeReservationState(String planName, String reservationIdName) throws Exception Blocking API Derived classes must implement this method to remove the state of a reservation allocation.- Parameters:
planName- plan Name.reservationIdName- reservationId Name.- Throws:
Exception- exception occurs.
-
removeRMDTMasterKeyState
protected abstract void removeRMDTMasterKeyState(org.apache.hadoop.security.token.delegation.DelegationKey delegationKey) throws Exception Blocking API Derived classes must implement this method to remove the state of DelegationToken Master Key.- Parameters:
delegationKey- DelegationKey.- Throws:
Exception- exception occurs.
-
storeOrUpdateAMRMTokenSecretManagerState
protected abstract void storeOrUpdateAMRMTokenSecretManagerState(AMRMTokenSecretManagerState amrmTokenSecretManagerState, boolean isUpdate) throws Exception Blocking API Derived classes must implement this method to store or update the state of AMRMToken Master Key.- Parameters:
amrmTokenSecretManagerState- amrmTokenSecretManagerState.isUpdate- true, update; otherwise not update.- Throws:
Exception- exception occurs.
-
storeOrUpdateAMRMTokenSecretManager
public void storeOrUpdateAMRMTokenSecretManager(AMRMTokenSecretManagerState amrmTokenSecretManagerState, boolean isUpdate) Store or Update state of AMRMToken Master Key.- Parameters:
amrmTokenSecretManagerState- amrmTokenSecretManagerState.isUpdate- true, update; otherwise not update.
-
removeApplication
Non-blocking API ResourceManager services call this to remove an application from the state store This does not block the dispatcher threads There is no notification of completion for this operation.- Parameters:
app- RMApp.
-
removeApplicationStateInternal
protected abstract void removeApplicationStateInternal(ApplicationStateData appState) throws Exception Blocking API Derived classes must implement this method to remove the state of an application and its attempts.- Parameters:
appState- ApplicationStateData.- Throws:
Exception- error occurs.
-
removeApplicationAttempt
public void removeApplicationAttempt(org.apache.hadoop.yarn.api.records.ApplicationAttemptId applicationAttemptId) Non-blocking API ResourceManager services call this to remove an attempt from the state store This does not block the dispatcher threads There is no notification of completion for this operation.- Parameters:
applicationAttemptId- applicationAttemptId.
-
removeApplicationAttemptInternal
protected abstract void removeApplicationAttemptInternal(org.apache.hadoop.yarn.api.records.ApplicationAttemptId attemptId) throws Exception Blocking API Derived classes must implement this method to remove the state of specified attempt.- Parameters:
attemptId- application attempt id.- Throws:
Exception- exception occurs.
-
getCredentialsFromAppAttempt
-
isFencedState
@VisibleForTesting protected boolean isFencedState() -
handleStoreEvent
-
notifyStoreOperationFailed
This method is called to notify the ResourceManager that the store operation has failed.- Parameters:
failureCause- the exception due to which the operation failed
-
deleteStore
Derived classes must implement this method to delete the state store.- Throws:
Exception- exception occurs.
-
removeApplication
public abstract void removeApplication(org.apache.hadoop.yarn.api.records.ApplicationId removeAppId) throws Exception Derived classes must implement this method to remove application from the state store.- Parameters:
removeAppId- application Id.- Throws:
Exception- exception occurs.
-
setResourceManager
-
getRMStateStoreState
-
getRMStateStoreEventHandler
protected org.apache.hadoop.yarn.event.EventHandler getRMStateStoreEventHandler() -
storeProxyCACert
ProxyCAManager calls this to store the CA Certificate and Private Key.- Parameters:
caCert- X509Certificate.caPrivateKey- PrivateKey.
-
storeProxyCACertState
protected abstract void storeProxyCACertState(X509Certificate caCert, PrivateKey caPrivateKey) throws Exception Blocking API Derived classes must implement this method to store the CA Certificate and Private Key.- Parameters:
caCert- X509Certificate.caPrivateKey- PrivateKey.- Throws:
Exception- error occurs.
-