Class ActiveStandbyElectorBasedElectorService

java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.yarn.server.resourcemanager.ActiveStandbyElectorBasedElectorService
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.hadoop.ha.ActiveStandbyElector.ActiveStandbyElectorCallback, org.apache.hadoop.service.Service, EmbeddedElector

@Private @Unstable public class ActiveStandbyElectorBasedElectorService extends org.apache.hadoop.service.AbstractService implements EmbeddedElector, org.apache.hadoop.ha.ActiveStandbyElector.ActiveStandbyElectorCallback
Leader election implementation that uses ActiveStandbyElector.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.apache.hadoop.service.Service

    org.apache.hadoop.service.Service.STATE
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
     
    void
    When the ZK client loses contact with ZK, this method will be called to allow the RM to react.
    void
    fenceOldActive(byte[] oldActiveData)
     
    Get information about the elector's connection to Zookeeper.
    void
    notifyFatalError(String errorMessage)
     
    void
    Leave and rejoin leader election.
    protected void
    serviceInit(org.apache.hadoop.conf.Configuration conf)
     
    protected void
     
    protected void
     

    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.apache.hadoop.service.Service

    close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, registerServiceListener, start, stop, unregisterServiceListener, waitForServiceToStop
  • Method Details

    • 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
    • serviceStop

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

      public void becomeActive() throws org.apache.hadoop.ha.ServiceFailedException
      Specified by:
      becomeActive in interface org.apache.hadoop.ha.ActiveStandbyElector.ActiveStandbyElectorCallback
      Throws:
      org.apache.hadoop.ha.ServiceFailedException
    • becomeStandby

      public void becomeStandby()
      Specified by:
      becomeStandby in interface org.apache.hadoop.ha.ActiveStandbyElector.ActiveStandbyElectorCallback
    • enterNeutralMode

      public void enterNeutralMode()
      When the ZK client loses contact with ZK, this method will be called to allow the RM to react. Because the loss of connection can be noticed before the session timeout happens, it is undesirable to transition immediately. Instead the method starts a timer that will wait YarnConfiguration.RM_ZK_TIMEOUT_MS milliseconds before initiating the transition into standby state.
      Specified by:
      enterNeutralMode in interface org.apache.hadoop.ha.ActiveStandbyElector.ActiveStandbyElectorCallback
    • notifyFatalError

      public void notifyFatalError(String errorMessage)
      Specified by:
      notifyFatalError in interface org.apache.hadoop.ha.ActiveStandbyElector.ActiveStandbyElectorCallback
    • fenceOldActive

      public void fenceOldActive(byte[] oldActiveData)
      Specified by:
      fenceOldActive in interface org.apache.hadoop.ha.ActiveStandbyElector.ActiveStandbyElectorCallback
    • rejoinElection

      public void rejoinElection()
      Description copied from interface: EmbeddedElector
      Leave and rejoin leader election.
      Specified by:
      rejoinElection in interface EmbeddedElector
    • getZookeeperConnectionState

      public String getZookeeperConnectionState()
      Description copied from interface: EmbeddedElector
      Get information about the elector's connection to Zookeeper.
      Specified by:
      getZookeeperConnectionState in interface EmbeddedElector
      Returns:
      zookeeper connection state