Class CuratorBasedElectorService

java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.yarn.server.resourcemanager.CuratorBasedElectorService
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.curator.framework.recipes.leader.LeaderLatchListener, org.apache.hadoop.service.Service, EmbeddedElector

@Private @Unstable public class CuratorBasedElectorService extends org.apache.hadoop.service.AbstractService implements EmbeddedElector, org.apache.curator.framework.recipes.leader.LeaderLatchListener
Leader election implementation that uses Curator.
  • Nested Class Summary

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

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

    Fields
    Modifier and Type
    Field
    Description
    static final org.slf4j.Logger
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.curator.framework.CuratorFramework
     
    Get information about the elector's connection to Zookeeper.
    void
     
    void
     
    void
    Leave and rejoin leader election.
    protected void
    serviceInit(org.apache.hadoop.conf.Configuration conf)
     
    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, serviceStart, 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
  • Field Details

    • LOG

      public static final org.slf4j.Logger LOG
  • Constructor Details

    • CuratorBasedElectorService

      public CuratorBasedElectorService(ResourceManager rm)
  • 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
    • serviceStop

      protected void serviceStop() throws Exception
      Overrides:
      serviceStop in class org.apache.hadoop.service.AbstractService
      Throws:
      Exception
    • 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
    • isLeader

      public void isLeader()
      Specified by:
      isLeader in interface org.apache.curator.framework.recipes.leader.LeaderLatchListener
    • notLeader

      public void notLeader()
      Specified by:
      notLeader in interface org.apache.curator.framework.recipes.leader.LeaderLatchListener
    • getCuratorClient

      @VisibleForTesting public org.apache.curator.framework.CuratorFramework getCuratorClient()