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
    Modifier and Type
    Field
    Description
    static final Duration
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    AutomaticLeaderElectionService(Configuration configuration, LockService lockService, com.google.common.eventbus.EventBus eventBus, NodePingThread nodePingThread)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Check if the current node is the leader of the cluster.
    protected void
    run()
     
    protected void
     
    protected void
     
    protected void
     

    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • DEFAULT_POLLING_INTERVAL

      public static final Duration DEFAULT_POLLING_INTERVAL
  • Constructor Details

    • AutomaticLeaderElectionService

      @Inject public AutomaticLeaderElectionService(Configuration configuration, LockService lockService, com.google.common.eventbus.EventBus eventBus, NodePingThread nodePingThread)
  • Method Details

    • startUp

      protected void startUp() throws Exception
      Overrides:
      startUp in class com.google.common.util.concurrent.AbstractExecutionThreadService
      Throws:
      Exception
    • triggerShutdown

      protected void triggerShutdown()
      Overrides:
      triggerShutdown in class com.google.common.util.concurrent.AbstractExecutionThreadService
    • shutDown

      protected void shutDown()
      Overrides:
      shutDown in class com.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 interface LeaderElectionService
      Returns:
      true if the current node is the leader, false if it is not
    • run

      protected void run() throws Exception
      Specified by:
      run in class com.google.common.util.concurrent.AbstractExecutionThreadService
      Throws:
      Exception