Class LeaderTasksCoordinator
java.lang.Object
com.netflix.genie.web.tasks.leader.LeaderTasksCoordinator
Class which handles coordinating leadership related tasks. Listens for leadership grant and revoke events and starts
tasks associated with being the cluster leader.
- Since:
- 3.0.0
-
Constructor Summary
ConstructorDescriptionLeaderTasksCoordinator
(org.springframework.scheduling.TaskScheduler taskScheduler, Collection<LeaderTask> tasks) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
onLeaderEvent
(org.springframework.integration.leader.event.AbstractLeaderEvent leaderEvent) Leadership event listener.void
Make sure any threads are taken care of before this object is destroyed.
-
Constructor Details
-
LeaderTasksCoordinator
public LeaderTasksCoordinator(org.springframework.scheduling.TaskScheduler taskScheduler, Collection<LeaderTask> tasks) Constructor.- Parameters:
taskScheduler
- The task executor to use.tasks
- The leadership tasks to run
-
-
Method Details
-
preDestroy
@PreDestroy public void preDestroy()Make sure any threads are taken care of before this object is destroyed. -
onLeaderEvent
@EventListener public void onLeaderEvent(org.springframework.integration.leader.event.AbstractLeaderEvent leaderEvent) Leadership event listener. Starts and stop processes when this Genie node is elected the leader of the cluster.Synchronized to ensure no race conditions between threads trying to start and stop leadership tasks.
- Parameters:
leaderEvent
- The leader grant or revoke event- See Also:
-
OnGrantedEvent
OnRevokedEvent
-