public class LeaderElector extends Object
Constructor and Description |
---|
LeaderElector(LeaderElectionConfig config) |
LeaderElector(LeaderElectionConfig config,
Consumer<Throwable> exceptionHandler) |
Modifier and Type | Method and Description |
---|---|
void |
run(Runnable startLeadingHook,
Runnable stopLeadingHook)
Runs the leader election in foreground.
|
void |
run(Runnable startLeadingHook,
Runnable stopLeadingHook,
Consumer<String> onNewLeaderHook)
Runs the leader election in foreground.
|
public LeaderElector(LeaderElectionConfig config)
public LeaderElector(LeaderElectionConfig config, Consumer<Throwable> exceptionHandler)
public void run(Runnable startLeadingHook, Runnable stopLeadingHook)
startLeadingHook
- called when a LeaderElector client starts leadingstopLeadingHook
- called when a LeaderElector client stops leadingpublic void run(Runnable startLeadingHook, Runnable stopLeadingHook, Consumer<String> onNewLeaderHook)
startLeadingHook
- called when a LeaderElector client starts leadingstopLeadingHook
- called when a LeaderElector client stops leadingonNewLeaderHook
- called when the client observes a leader that is not the previously
observed leader. This includes the first observed leader when the client starts.Copyright © 2020. All rights reserved.