Exemplo n.º 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;
     }
   };
 }
Exemplo n.º 2
0
 @Override
 public void onDefeated() {
   LOG.error("Lost leadership, committing suicide.");
   stateMachine.transition(State.DEAD);
 }
Exemplo n.º 3
0
 @Override
 public void onLeading(LeaderControl control) {
   leaderControl.set(control);
   stateMachine.transition(State.LEADER_AWAITING_REGISTRATION);
 }
Exemplo n.º 4
0
 @Subscribe
 public void registered(DriverRegistered event) {
   stateMachine.transition(State.ACTIVE);
 }
Exemplo n.º 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;
 }