Package org.graylog2.cluster.leader
Class AutomaticLeaderElectionService
java.lang.Object
com.google.common.util.concurrent.AbstractExecutionThreadService
org.graylog2.cluster.leader.AutomaticLeaderElectionService
- All Implemented Interfaces:
com.google.common.util.concurrent.Service,LeaderElectionService
@Singleton
public class AutomaticLeaderElectionService
extends com.google.common.util.concurrent.AbstractExecutionThreadService
implements LeaderElectionService
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.google.common.util.concurrent.Service
com.google.common.util.concurrent.Service.Listener, com.google.common.util.concurrent.Service.State -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAutomaticLeaderElectionService(Configuration configuration, LockService lockService, com.google.common.eventbus.EventBus eventBus, NodePingThread nodePingThread) -
Method Summary
Methods inherited from class com.google.common.util.concurrent.AbstractExecutionThreadService
addListener, awaitRunning, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, awaitTerminated, executor, failureCause, isRunning, serviceName, startAsync, state, stopAsync, toString
-
Field Details
-
DEFAULT_POLLING_INTERVAL
-
-
Constructor Details
-
AutomaticLeaderElectionService
@Inject public AutomaticLeaderElectionService(Configuration configuration, LockService lockService, com.google.common.eventbus.EventBus eventBus, NodePingThread nodePingThread)
-
-
Method Details
-
startUp
- Overrides:
startUpin classcom.google.common.util.concurrent.AbstractExecutionThreadService- Throws:
Exception
-
triggerShutdown
protected void triggerShutdown()- Overrides:
triggerShutdownin classcom.google.common.util.concurrent.AbstractExecutionThreadService
-
shutDown
protected void shutDown()- Overrides:
shutDownin classcom.google.common.util.concurrent.AbstractExecutionThreadService
-
isLeader
public boolean isLeader()Description copied from interface:LeaderElectionServiceCheck if the current node is the leader of the cluster.This method might be called frequently. Implementations should be performant and resource-friendly.
- Specified by:
isLeaderin interfaceLeaderElectionService- Returns:
- true if the current node is the leader, false if it is not
-
run
- Specified by:
runin classcom.google.common.util.concurrent.AbstractExecutionThreadService- Throws:
Exception
-