Class LocalLeader

java.lang.Object
com.netflix.genie.web.tasks.leader.LocalLeader

@ThreadSafe public class LocalLeader extends Object
A class to control leadership activities when remote leadership isn't enabled and this node has been forcibly elected as the leader.
Since:
3.0.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    LocalLeader(GenieEventBus genieEventBus, boolean isLeader)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Whether local node is leader.
    boolean
    Whether this module is active.
    void
    If configured to be leader, activate and send a leadership acquired notification.
    void
    startLeadership(org.springframework.context.event.ContextRefreshedEvent event)
    Auto-start once application is up and running.
    void
    If configured to be leader and previously started, deactivate and send a leadership lost notification.
    void
    stopLeadership(org.springframework.context.event.ContextClosedEvent event)
    Auto-stop once application is shutting down.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LocalLeader

      public LocalLeader(GenieEventBus genieEventBus, boolean isLeader)
      Constructor.
      Parameters:
      genieEventBus - The spring application event publisher to use to invoke that this node is a leader
      isLeader - Whether this node should be the leader or not. Should only be one in a cluster but not enforced by Genie at this time
  • Method Details

    • startLeadership

      @EventListener public void startLeadership(org.springframework.context.event.ContextRefreshedEvent event)
      Auto-start once application is up and running.
      Parameters:
      event - The Spring Boot application ready event to startup on
    • stopLeadership

      @EventListener public void stopLeadership(org.springframework.context.event.ContextClosedEvent event)
      Auto-stop once application is shutting down.
      Parameters:
      event - The application context closing event
    • stop

      public void stop()
      If configured to be leader and previously started, deactivate and send a leadership lost notification. NOOP if not running or if this node is not configured to be leader.
    • start

      public void start()
      If configured to be leader, activate and send a leadership acquired notification. NOOP if already running or if this node is not configured to be leader.
    • isRunning

      public boolean isRunning()
      Whether this module is active.
      Returns:
      true if start() was called.
    • isLeader

      public boolean isLeader()
      Whether local node is leader.
      Returns:
      true if this module is active and the node is configured to be leader