@ThreadSafe
public class LocalLeader
extends java.lang.Object
Constructor and Description |
---|
LocalLeader(GenieEventBus genieEventBus,
boolean isLeader)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isLeader()
Whether local node is leader.
|
boolean |
isRunning()
Whether this module is active.
|
void |
start()
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 |
stop()
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.
|
public LocalLeader(GenieEventBus genieEventBus, boolean isLeader)
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@EventListener public void startLeadership(org.springframework.context.event.ContextRefreshedEvent event)
event
- The Spring Boot application ready event to startup on@EventListener public void stopLeadership(org.springframework.context.event.ContextClosedEvent event)
event
- The application context closing eventpublic void stop()
public void start()
public boolean isRunning()
start()
was called.public boolean isLeader()