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
  • Field Details

    • RM_APP_ROOT

      @VisibleForTesting public static final String RM_APP_ROOT
      See Also:
    • RM_DT_SECRET_MANAGER_ROOT

      protected static final String RM_DT_SECRET_MANAGER_ROOT
      See Also:
    • RM_DELEGATION_TOKENS_ROOT_ZNODE_NAME

      protected static final String RM_DELEGATION_TOKENS_ROOT_ZNODE_NAME
      See Also:
    • DELEGATION_KEY_PREFIX

      protected static final String DELEGATION_KEY_PREFIX
      See Also:
    • DELEGATION_TOKEN_PREFIX

      protected static final String DELEGATION_TOKEN_PREFIX
      See Also:
    • DELEGATION_TOKEN_SEQUENCE_NUMBER_PREFIX

      protected static final String DELEGATION_TOKEN_SEQUENCE_NUMBER_PREFIX
      See Also:
    • AMRMTOKEN_SECRET_MANAGER_ROOT

      protected static final String AMRMTOKEN_SECRET_MANAGER_ROOT
      See Also:
    • RESERVATION_SYSTEM_ROOT

      protected static final String RESERVATION_SYSTEM_ROOT
      See Also:
    • PROXY_CA_ROOT

      protected static final String PROXY_CA_ROOT
      See Also:
    • PROXY_CA_CERT_NODE

      protected static final String PROXY_CA_CERT_NODE
      See Also:
    • PROXY_CA_PRIVATE_KEY_NODE

      protected static final String PROXY_CA_PRIVATE_KEY_NODE
      See Also:
    • VERSION_NODE

      protected static final String VERSION_NODE
      See Also:
    • EPOCH_NODE

      protected static final String EPOCH_NODE
      See Also:
    • baseEpoch

      protected long baseEpoch
    • resourceManager

      protected ResourceManager 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

      protected void serviceInit(org.apache.hadoop.conf.Configuration conf) throws Exception
      Overrides:
      serviceInit in class org.apache.hadoop.service.AbstractService
      Throws:
      Exception
    • serviceStart

      protected void serviceStart() throws Exception
      Overrides:
      serviceStart in class org.apache.hadoop.service.AbstractService
      Throws:
      Exception
    • initInternal

      protected abstract void initInternal(org.apache.hadoop.conf.Configuration conf) throws Exception
      Derived classes initialize themselves using this method.
      Parameters:
      conf - Configuration.
      Throws:
      Exception - error occur.
    • startInternal

      protected abstract void startInternal() throws Exception
      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

      protected void serviceStop() throws Exception
      Overrides:
      serviceStop in class org.apache.hadoop.service.AbstractService
      Throws:
      Exception
    • closeInternal

      protected abstract void closeInternal() throws Exception
      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

      public void checkVersion() throws Exception
      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

      protected abstract org.apache.hadoop.yarn.server.records.Version loadVersion() throws Exception
      Derived class use this method to load the version information from state store.
      Returns:
      current version.
      Throws:
      Exception - error occur.
    • storeVersion

      protected abstract void storeVersion() throws Exception
      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

      public abstract long getAndIncrementEpoch() throws Exception
      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

      public abstract RMStateStore.RMState loadState() throws Exception
      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

      public void storeNewApplication(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.
      Parameters:
      app - rmApp.
    • updateApplicationState

      public void updateApplicationState(ApplicationStateData appState)
    • updateApplicationState

      public void updateApplicationState(ApplicationStateData appState, boolean notifyApp)
    • 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

      public void storeNewApplicationAttempt(RMAppAttempt appAttempt)
    • updateApplicationAttemptState

      public void updateApplicationAttemptState(ApplicationAttemptStateData attemptState)
    • 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

      public void removeReservation(String planName, String reservationIdName)
    • 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

      public void removeApplication(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.
      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

      public org.apache.hadoop.security.Credentials getCredentialsFromAppAttempt(RMAppAttempt appAttempt)
    • isFencedState

      @VisibleForTesting protected boolean isFencedState()
    • handleStoreEvent

      protected void handleStoreEvent(RMStateStoreEvent event)
    • notifyStoreOperationFailed

      protected void notifyStoreOperationFailed(Exception failureCause)
      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

      public abstract void deleteStore() throws Exception
      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

      public void setResourceManager(ResourceManager rm)
    • getRMStateStoreState

      public RMStateStore.RMStateStoreState getRMStateStoreState()
    • getRMStateStoreEventHandler

      protected org.apache.hadoop.yarn.event.EventHandler getRMStateStoreEventHandler()
    • storeProxyCACert

      public void storeProxyCACert(X509Certificate caCert, PrivateKey caPrivateKey)
      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.