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 TypeMethodDescriptionvoidvoidvoidWhen the ZK client loses contact with ZK, this method will be called to allow the RM to react.voidfenceOldActive(byte[] oldActiveData) Get information about the elector's connection to Zookeeper.voidnotifyFatalError(String errorMessage) voidLeave and rejoin leader election.protected voidserviceInit(org.apache.hadoop.conf.Configuration conf) protected voidprotected 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, 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
-
Method Details
-
serviceInit
- Overrides:
serviceInitin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
serviceStart
- Overrides:
serviceStartin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
serviceStop
- Overrides:
serviceStopin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
becomeActive
public void becomeActive() throws org.apache.hadoop.ha.ServiceFailedException- Specified by:
becomeActivein interfaceorg.apache.hadoop.ha.ActiveStandbyElector.ActiveStandbyElectorCallback- Throws:
org.apache.hadoop.ha.ServiceFailedException
-
becomeStandby
public void becomeStandby()- Specified by:
becomeStandbyin interfaceorg.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 waitYarnConfiguration.RM_ZK_TIMEOUT_MSmilliseconds before initiating the transition into standby state.- Specified by:
enterNeutralModein interfaceorg.apache.hadoop.ha.ActiveStandbyElector.ActiveStandbyElectorCallback
-
notifyFatalError
- Specified by:
notifyFatalErrorin interfaceorg.apache.hadoop.ha.ActiveStandbyElector.ActiveStandbyElectorCallback
-
fenceOldActive
public void fenceOldActive(byte[] oldActiveData) - Specified by:
fenceOldActivein interfaceorg.apache.hadoop.ha.ActiveStandbyElector.ActiveStandbyElectorCallback
-
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
-