Package org.graylog2.cluster.leader
Class StaticLeaderElectionService
java.lang.Object
com.google.common.util.concurrent.AbstractIdleService
org.graylog2.cluster.leader.StaticLeaderElectionService
- All Implemented Interfaces:
com.google.common.util.concurrent.Service
,LeaderElectionService
@Singleton
public class StaticLeaderElectionService
extends com.google.common.util.concurrent.AbstractIdleService
implements LeaderElectionService
Leader election based on the static
Configuration.isLeader()
setting in the configuration file. After node
startup, the leader status is static and will not change.
If the value of Configuration.isLeader()
is false, the node will not be a leader, if the value is true, the
node will be a leader, unless the node notices upon startup that there is another leader present in the cluster
already. In that case the value will be set to false and the node will act as a follower.
-
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
-
Constructor Summary
-
Method Summary
Methods inherited from class com.google.common.util.concurrent.AbstractIdleService
addListener, awaitRunning, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, awaitTerminated, executor, failureCause, isRunning, serviceName, startAsync, state, stopAsync, toString
-
Constructor Details
-
StaticLeaderElectionService
-
-
Method Details
-
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
-
startUp
- Specified by:
startUp
in classcom.google.common.util.concurrent.AbstractIdleService
- Throws:
Exception
-
shutDown
- Specified by:
shutDown
in classcom.google.common.util.concurrent.AbstractIdleService
- Throws:
Exception
-