Class LocalLeader
java.lang.Object
com.netflix.genie.web.tasks.leader.LocalLeader
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 -
Method Summary
Modifier and TypeMethodDescriptionbooleanisLeader()Whether local node is leader.booleanWhether this module is active.voidstart()If configured to be leader, activate and send a leadership acquired notification.voidstartLeadership(org.springframework.context.event.ContextRefreshedEvent event) Auto-start once application is up and running.voidstop()If configured to be leader and previously started, deactivate and send a leadership lost notification.voidstopLeadership(org.springframework.context.event.ContextClosedEvent event) Auto-stop once application is shutting down.
-
Constructor Details
-
LocalLeader
Constructor.- Parameters:
genieEventBus- The spring application event publisher to use to invoke that this node is a leaderisLeader- 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
-