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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.curator.framework.CuratorFrameworkGet information about the elector's connection to Zookeeper.voidisLeader()voidvoidLeave and rejoin leader election.protected voidserviceInit(org.apache.hadoop.conf.Configuration conf) protected voidMethods 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, waitForServiceToStopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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
-
-
Method Details
-
serviceInit
- Overrides:
serviceInitin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
serviceStop
- Overrides:
serviceStopin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
rejoinElection
public void rejoinElection()Description copied from interface:EmbeddedElectorLeave and rejoin leader election.- Specified by:
rejoinElectionin interfaceEmbeddedElector
-
getZookeeperConnectionState
Description copied from interface:EmbeddedElectorGet information about the elector's connection to Zookeeper.- Specified by:
getZookeeperConnectionStatein interfaceEmbeddedElector- Returns:
- zookeeper connection state
-
isLeader
public void isLeader()- Specified by:
isLeaderin interfaceorg.apache.curator.framework.recipes.leader.LeaderLatchListener
-
notLeader
public void notLeader()- Specified by:
notLeaderin interfaceorg.apache.curator.framework.recipes.leader.LeaderLatchListener
-
getCuratorClient
@VisibleForTesting public org.apache.curator.framework.CuratorFramework getCuratorClient()
-