Example #1
0
 private Consumer<Transition<State>> dieOnError(final Consumer<Transition<State>> closure) {
   return transition -> {
     try {
       closure.accept(transition);
     } catch (RuntimeException e) {
       LOG.error("Caught unchecked exception: " + e, e);
       stateMachine.transition(State.DEAD);
       throw e;
     }
   };
 }
Example #2
0
 @Override
 public void onDefeated() {
   LOG.error("Lost leadership, committing suicide.");
   stateMachine.transition(State.DEAD);
 }
Example #3
0
 @Override
 public void onLeading(LeaderControl control) {
   leaderControl.set(control);
   stateMachine.transition(State.LEADER_AWAITING_REGISTRATION);
 }
Example #4
0
 @Subscribe
 public void registered(DriverRegistered event) {
   stateMachine.transition(State.ACTIVE);
 }
Example #5
0
 /**
  * Prepares a scheduler to offer itself as a leader candidate. After this call the scheduler will
  * host a live log replica and start syncing data from the leader via the log until it gets called
  * upon to lead.
  *
  * @return A listener that can be offered for leadership of a distributed election.
  */
 public LeadershipListener prepare() {
   stateMachine.transition(State.PREPARING_STORAGE);
   return leadershipListener;
 }