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
-
Constructor Summary
ConstructorDescriptionAutomaticLeaderElectionService
(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:
startUp
in classcom.google.common.util.concurrent.AbstractExecutionThreadService
- Throws:
Exception
-
triggerShutdown
protected void triggerShutdown()- Overrides:
triggerShutdown
in classcom.google.common.util.concurrent.AbstractExecutionThreadService
-
shutDown
protected void shutDown()- Overrides:
shutDown
in classcom.google.common.util.concurrent.AbstractExecutionThreadService
-
isLeader
public boolean isLeader()Description copied from interface:LeaderElectionService
Check 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:
isLeader
in interfaceLeaderElectionService
- Returns:
- true if the current node is the leader, false if it is not
-
run
- Specified by:
run
in classcom.google.common.util.concurrent.AbstractExecutionThreadService
- Throws:
Exception
-