Class ZKRMStateStore
java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore
org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.hadoop.service.Service
RMStateStore implementation backed by ZooKeeper.
The znode structure is as follows:
ROOT_DIR_PATH
|--- VERSION_INFO
|--- EPOCH_NODE
|--- RM_ZK_FENCING_LOCK
|--- RM_APP_ROOT
| |----- HIERARCHIES
| | |----- 1
| | | |----- (#ApplicationId barring last character)
| | | | |----- (#Last character of ApplicationId)
| | | | | |----- (#ApplicationAttemptIds)
| | | ....
| | |
| | |----- 2
| | | |----- (#ApplicationId barring last 2 characters)
| | | | |----- (#Last 2 characters of ApplicationId)
| | | | | |----- (#ApplicationAttemptIds)
| | | ....
| | |
| | |----- 3
| | | |----- (#ApplicationId barring last 3 characters)
| | | | |----- (#Last 3 characters of ApplicationId)
| | | | | |----- (#ApplicationAttemptIds)
| | | ....
| | |
| | |----- 4
| | | |----- (#ApplicationId barring last 4 characters)
| | | | |----- (#Last 4 characters of ApplicationId)
| | | | | |----- (#ApplicationAttemptIds)
| | | ....
| | |
| |----- (#ApplicationId1)
| | |----- (#ApplicationAttemptIds)
| |
| |----- (#ApplicationId2)
| | |----- (#ApplicationAttemptIds)
| ....
|
|--- RM_DT_SECRET_MANAGER_ROOT
|----- RM_DT_SEQUENTIAL_NUMBER_ZNODE_NAME
|----- RM_DELEGATION_TOKENS_ROOT_ZNODE_NAME
| |----- 1
| | |----- (#TokenId barring last character)
| | | |----- (#Last character of TokenId)
| | ....
| |----- 2
| | |----- (#TokenId barring last 2 characters)
| | | |----- (#Last 2 characters of TokenId)
| | ....
| |----- 3
| | |----- (#TokenId barring last 3 characters)
| | | |----- (#Last 3 characters of TokenId)
| | ....
| |----- 4
| | |----- (#TokenId barring last 4 characters)
| | | |----- (#Last 4 characters of TokenId)
| | ....
| |----- Token_1
| |----- Token_2
| ....
|
|----- RM_DT_MASTER_KEYS_ROOT_ZNODE_NAME
| |----- Key_1
| |----- Key_2
....
|--- AMRMTOKEN_SECRET_MANAGER_ROOT
|----- currentMasterKey
|----- nextMasterKey
|-- RESERVATION_SYSTEM_ROOT
|------PLAN_1
| |------ RESERVATION_1
| |------ RESERVATION_2
| ....
|------PLAN_2
....
|-- PROXY_CA_ROOT
|----- caCert
|----- caPrivateKey
Note: Changes from 1.1 to 1.2 - AMRMTokenSecretManager state has been saved
separately. The currentMasterkey and nextMasterkey have been stored.
Also, AMRMToken has been removed from ApplicationAttemptState.
Changes from 1.2 to 1.3, Addition of ReservationSystem state.
Changes from 1.3 to 1.4 - Change the structure of application znode by
splitting it in 2 parts, depending on a configurable split index. This limits
the number of application znodes returned in a single call while loading
app state.
Changes from 1.4 to 1.5 - Change the structure of delegation token znode by
splitting it in 2 parts, depending on a configurable split index. This limits
the number of delegation token znodes returned in a single call while loading
tokens state.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore
RMStateStore.ProxyCAState, RMStateStore.RMDTSecretManagerState, RMStateStore.RMState, RMStateStore.RMStateStoreStateNested classes/interfaces inherited from interface org.apache.hadoop.service.Service
org.apache.hadoop.service.Service.STATE -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final org.apache.hadoop.yarn.server.records.Versionprotected intprotected ZKRMStateStoreOpDurationsstatic final Stringstatic final Stringprotected StringFields inherited from class org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore
AM_CLIENT_TOKEN_MASTER_KEY_NAME, AM_RM_TOKEN_SERVICE, AMRMTOKEN_SECRET_MANAGER_ROOT, baseEpoch, DELEGATION_KEY_PREFIX, DELEGATION_TOKEN_PREFIX, DELEGATION_TOKEN_SEQUENCE_NUMBER_PREFIX, EPOCH_NODE, PROXY_CA_CERT_NODE, PROXY_CA_PRIVATE_KEY_NODE, PROXY_CA_ROOT, RESERVATION_SYSTEM_ROOT, resourceManager, RM_APP_ROOT, RM_DT_SECRET_MANAGER_ROOT, rmStateStoreEventHandler, VERSION_NODE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidDerived classes close themselves using this method.protected List<org.apache.zookeeper.data.ACL>constructZkRootNodeACL(org.apache.hadoop.conf.Configuration conf, List<org.apache.zookeeper.data.ACL> sourceACLs) Given theConfigurationandACLs used (sourceACLs) for ZooKeeper access, construct theACLs for the store's root node.voidDerived classes must implement this method to delete the state store.longGet the current epoch of RM and increment the value.protected org.apache.hadoop.yarn.server.records.VersionGet the current version of the underlying state store.voidinitInternal(org.apache.hadoop.conf.Configuration conf) Derived classes initialize themselves using this method.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.protected org.apache.hadoop.yarn.server.records.VersionDerived class use this method to load the version information from state store.voidremoveApplication(org.apache.hadoop.yarn.api.records.ApplicationId removeAppId) Derived classes must implement this method to remove application from the state store.protected voidremoveApplicationAttemptInternal(org.apache.hadoop.yarn.api.records.ApplicationAttemptId appAttemptId) Blocking API Derived classes must implement this method to remove the state of specified attempt.protected voidBlocking API Derived classes must implement this method to remove the state of an application and its attempts.protected voidremoveReservationState(String planName, String reservationIdName) Blocking API Derived classes must implement this method to remove the state of a reservation allocation.protected voidremoveRMDelegationTokenState(org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier rmDTIdentifier) Blocking API Derived classes must implement this method to remove the state of RMDelegationToken.protected 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.voidsafeDeleteAndCheckNode(String path, List<org.apache.zookeeper.data.ACL> fencingACL, String fencingPath) Deletes the path more safe.voidDerived classes start themselves using this method.protected voidstoreApplicationAttemptStateInternal(org.apache.hadoop.yarn.api.records.ApplicationAttemptId appAttemptId, ApplicationAttemptStateData attemptStateDataPB) Blocking API Derived classes must implement this method to store the state of an application attempt.voidstoreApplicationStateInternal(org.apache.hadoop.yarn.api.records.ApplicationId appId, ApplicationStateData appStateDataPB) Blocking API Derived classes must implement this method to store the state of an application.protected voidstoreOrUpdateAMRMTokenSecretManagerState(AMRMTokenSecretManagerState amrmTokenSecretManagerState, boolean isUpdate) Blocking API Derived classes must implement this method to store or update the state of AMRMToken Master Key.protected voidstoreProxyCACertState(X509Certificate caCert, PrivateKey caPrivateKey) Blocking API Derived classes must implement this method to store the CA Certificate and Private Key.protected 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.protected 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.protected 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 voidDerived class use this method to store the version information.protected voidupdateApplicationAttemptStateInternal(org.apache.hadoop.yarn.api.records.ApplicationAttemptId appAttemptId, ApplicationAttemptStateData attemptStateDataPB) protected voidupdateApplicationStateInternal(org.apache.hadoop.yarn.api.records.ApplicationId appId, ApplicationStateData appStateDataPB) protected 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.yarn.server.resourcemanager.recovery.RMStateStore
checkVersion, getCredentialsFromAppAttempt, getRMStateStoreEventHandler, getRMStateStoreState, handleStoreEvent, isFencedState, nextEpoch, notifyStoreOperationFailed, removeApplication, removeApplicationAttempt, removeReservation, removeRMDelegationToken, removeRMDTMasterKey, serviceInit, serviceStart, serviceStop, setResourceManager, setRMDispatcher, storeNewApplication, storeNewApplicationAttempt, storeNewReservation, storeOrUpdateAMRMTokenSecretManager, storeProxyCACert, storeRMDelegationToken, storeRMDTMasterKey, updateApplicationAttemptState, updateApplicationState, updateApplicationState, updateApplicationStateSynchronously, updateFencedState, updateRMDelegationTokenMethods 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
-
ROOT_ZNODE_NAME
- See Also:
-
CURRENT_VERSION_INFO
protected static final org.apache.hadoop.yarn.server.records.Version CURRENT_VERSION_INFO -
RM_APP_ROOT_HIERARCHIES
- See Also:
-
znodeWorkingPath
-
delegationTokenNodeSplitIndex
@VisibleForTesting protected int delegationTokenNodeSplitIndex -
opDurations
-
-
Constructor Details
-
ZKRMStateStore
public ZKRMStateStore()
-
-
Method Details
-
constructZkRootNodeACL
@VisibleForTesting @Private @Unstable protected List<org.apache.zookeeper.data.ACL> constructZkRootNodeACL(org.apache.hadoop.conf.Configuration conf, List<org.apache.zookeeper.data.ACL> sourceACLs) throws NoSuchAlgorithmException Given theConfigurationandACLs used (sourceACLs) for ZooKeeper access, construct theACLs for the store's root node. In the constructedACL, all the users allowed by sourceACLs are given read-write-admin access, while the current RM has exclusive create-delete access. To be called only when HA is enabled and the configuration doesn't set an ACL for the root node.- Parameters:
conf- the configurationsourceACLs- the source ACLs- Returns:
- ACLs for the store's root node
- Throws:
NoSuchAlgorithmException- thrown if the digest algorithm used by Zookeeper cannot be found
-
initInternal
public void initInternal(org.apache.hadoop.conf.Configuration conf) throws IOException, NoSuchAlgorithmException Description copied from class:RMStateStoreDerived classes initialize themselves using this method.- Specified by:
initInternalin classRMStateStore- Parameters:
conf- Configuration.- Throws:
IOExceptionNoSuchAlgorithmException
-
startInternal
Description copied from class:RMStateStoreDerived classes start themselves using this method. The base class is started and the event dispatcher is ready to use at this point.- Specified by:
startInternalin classRMStateStore- Throws:
Exception- error occur.
-
closeInternal
Description copied from class:RMStateStoreDerived classes close themselves using this method. The base class will be closed and the event dispatcher will be shutdown after this.- Specified by:
closeInternalin classRMStateStore- Throws:
Exception- error occur.
-
getCurrentVersion
protected org.apache.hadoop.yarn.server.records.Version getCurrentVersion()Description copied from class:RMStateStoreGet the current version of the underlying state store.- Specified by:
getCurrentVersionin classRMStateStore- Returns:
- current version.
-
storeVersion
Description copied from class:RMStateStoreDerived class use this method to store the version information.- Specified by:
storeVersionin classRMStateStore- Throws:
Exception- error occur.
-
loadVersion
Description copied from class:RMStateStoreDerived class use this method to load the version information from state store.- Specified by:
loadVersionin classRMStateStore- Returns:
- current version.
- Throws:
Exception- error occur.
-
getAndIncrementEpoch
Description copied from class:RMStateStoreGet the current epoch of RM and increment the value.- Specified by:
getAndIncrementEpochin classRMStateStore- Returns:
- current epoch.
- Throws:
Exception- error occur.
-
loadState
Description copied from class:RMStateStoreBlocking 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.- Specified by:
loadStatein classRMStateStore- Returns:
- RMState.
- Throws:
Exception- error occur.
-
storeApplicationStateInternal
public void storeApplicationStateInternal(org.apache.hadoop.yarn.api.records.ApplicationId appId, ApplicationStateData appStateDataPB) throws Exception Description copied from class:RMStateStoreBlocking API Derived classes must implement this method to store the state of an application.- Specified by:
storeApplicationStateInternalin classRMStateStore- Parameters:
appId- application Id.appStateDataPB- application StateData.- Throws:
Exception- error occur.
-
updateApplicationStateInternal
protected void updateApplicationStateInternal(org.apache.hadoop.yarn.api.records.ApplicationId appId, ApplicationStateData appStateDataPB) throws Exception - Specified by:
updateApplicationStateInternalin classRMStateStore- Throws:
Exception
-
storeApplicationAttemptStateInternal
protected void storeApplicationAttemptStateInternal(org.apache.hadoop.yarn.api.records.ApplicationAttemptId appAttemptId, ApplicationAttemptStateData attemptStateDataPB) throws Exception Description copied from class:RMStateStoreBlocking API Derived classes must implement this method to store the state of an application attempt.- Specified by:
storeApplicationAttemptStateInternalin classRMStateStore- Parameters:
appAttemptId- Application AttemptId.attemptStateDataPB- Application AttemptStateData.- Throws:
Exception- error occur.
-
updateApplicationAttemptStateInternal
protected void updateApplicationAttemptStateInternal(org.apache.hadoop.yarn.api.records.ApplicationAttemptId appAttemptId, ApplicationAttemptStateData attemptStateDataPB) throws Exception - Specified by:
updateApplicationAttemptStateInternalin classRMStateStore- Throws:
Exception
-
removeApplicationAttemptInternal
protected void removeApplicationAttemptInternal(org.apache.hadoop.yarn.api.records.ApplicationAttemptId appAttemptId) throws Exception Description copied from class:RMStateStoreBlocking API Derived classes must implement this method to remove the state of specified attempt.- Specified by:
removeApplicationAttemptInternalin classRMStateStore- Parameters:
appAttemptId- application attempt id.- Throws:
Exception- exception occurs.
-
removeApplicationStateInternal
Description copied from class:RMStateStoreBlocking API Derived classes must implement this method to remove the state of an application and its attempts.- Specified by:
removeApplicationStateInternalin classRMStateStore- Parameters:
appState- ApplicationStateData.- Throws:
Exception- error occurs.
-
storeRMDelegationTokenState
protected void storeRMDelegationTokenState(org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier rmDTIdentifier, Long renewDate) throws Exception Description copied from class:RMStateStoreBlocking API Derived classes must implement this method to store the state of RMDelegationToken and sequence number.- Specified by:
storeRMDelegationTokenStatein classRMStateStore- Parameters:
rmDTIdentifier- RMDelegationTokenIdentifier.renewDate- token renew date.- Throws:
Exception- error occur.
-
removeRMDelegationTokenState
protected void removeRMDelegationTokenState(org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier rmDTIdentifier) throws Exception Description copied from class:RMStateStoreBlocking API Derived classes must implement this method to remove the state of RMDelegationToken.- Specified by:
removeRMDelegationTokenStatein classRMStateStore- Parameters:
rmDTIdentifier- RMDelegationTokenIdentifier.- Throws:
Exception- error occurs.
-
updateRMDelegationTokenState
protected void updateRMDelegationTokenState(org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier rmDTIdentifier, Long renewDate) throws Exception Description copied from class:RMStateStoreBlocking API Derived classes must implement this method to update the state of RMDelegationToken and sequence number.- Specified by:
updateRMDelegationTokenStatein classRMStateStore- Parameters:
rmDTIdentifier- RMDelegationTokenIdentifier.renewDate- token renew date.- Throws:
Exception- error occurs.
-
storeRMDTMasterKeyState
protected void storeRMDTMasterKeyState(org.apache.hadoop.security.token.delegation.DelegationKey delegationKey) throws Exception Description copied from class:RMStateStoreBlocking API Derived classes must implement this method to store the state of DelegationToken Master Key.- Specified by:
storeRMDTMasterKeyStatein classRMStateStore- Parameters:
delegationKey- DelegationToken Master Key.- Throws:
Exception- error occur.
-
removeRMDTMasterKeyState
protected void removeRMDTMasterKeyState(org.apache.hadoop.security.token.delegation.DelegationKey delegationKey) throws Exception Description copied from class:RMStateStoreBlocking API Derived classes must implement this method to remove the state of DelegationToken Master Key.- Specified by:
removeRMDTMasterKeyStatein classRMStateStore- Parameters:
delegationKey- DelegationKey.- Throws:
Exception- exception occurs.
-
deleteStore
Description copied from class:RMStateStoreDerived classes must implement this method to delete the state store.- Specified by:
deleteStorein classRMStateStore- Throws:
Exception- exception occurs.
-
removeApplication
public void removeApplication(org.apache.hadoop.yarn.api.records.ApplicationId removeAppId) throws Exception Description copied from class:RMStateStoreDerived classes must implement this method to remove application from the state store.- Specified by:
removeApplicationin classRMStateStore- Parameters:
removeAppId- application Id.- Throws:
Exception- exception occurs.
-
storeOrUpdateAMRMTokenSecretManagerState
protected void storeOrUpdateAMRMTokenSecretManagerState(AMRMTokenSecretManagerState amrmTokenSecretManagerState, boolean isUpdate) throws Exception Description copied from class:RMStateStoreBlocking API Derived classes must implement this method to store or update the state of AMRMToken Master Key.- Specified by:
storeOrUpdateAMRMTokenSecretManagerStatein classRMStateStore- Parameters:
amrmTokenSecretManagerState- amrmTokenSecretManagerState.isUpdate- true, update; otherwise not update.- Throws:
Exception- exception occurs.
-
removeReservationState
Description copied from class:RMStateStoreBlocking API Derived classes must implement this method to remove the state of a reservation allocation.- Specified by:
removeReservationStatein classRMStateStore- Parameters:
planName- plan Name.reservationIdName- reservationId Name.- Throws:
Exception- exception occurs.
-
storeReservationState
protected void storeReservationState(org.apache.hadoop.yarn.proto.YarnProtos.ReservationAllocationStateProto reservationAllocation, String planName, String reservationIdName) throws Exception Description copied from class:RMStateStoreBlocking API Derived classes must implement this method to store the state of a reservation allocation.- Specified by:
storeReservationStatein classRMStateStore- Parameters:
reservationAllocation- reservation Allocation.planName- plan Name.reservationIdName- reservationId Name.- Throws:
Exception- error occurs.
-
storeProxyCACertState
protected void storeProxyCACertState(X509Certificate caCert, PrivateKey caPrivateKey) throws Exception Description copied from class:RMStateStoreBlocking API Derived classes must implement this method to store the CA Certificate and Private Key.- Specified by:
storeProxyCACertStatein classRMStateStore- Parameters:
caCert- X509Certificate.caPrivateKey- PrivateKey.- Throws:
Exception- error occurs.
-
safeDeleteAndCheckNode
public void safeDeleteAndCheckNode(String path, List<org.apache.zookeeper.data.ACL> fencingACL, String fencingPath) throws Exception Deletes the path more safe. When NoNodeException is encountered, if the node does not exist, it will ignore this exception to avoid triggering a greater impact of ResourceManager failover on the cluster.- Parameters:
path- Path to be deleted.fencingACL- fencingACL.fencingPath- fencingNodePath.- Throws:
Exception- if any problem occurs while performing deletion.
-