Exemplo n.º 1
0
  /** Transitions to a new state. */
  protected void transition(RaftServer.State state) {
    if (state == type()) return;

    switch (state) {
      case INACTIVE:
        context.transition(InactiveState.class);
        break;
      case PASSIVE:
        context.transition(PassiveState.class);
        break;
      case FOLLOWER:
        context.transition(FollowerState.class);
        break;
      case CANDIDATE:
        context.transition(CandidateState.class);
        break;
      case LEADER:
        context.transition(LeaderState.class);
        break;
      default:
        throw new IllegalStateException();
    }
  }
Exemplo n.º 2
0
 @Override
 public CompletableFuture<AbstractState> open() {
   context.checkThread();
   open = true;
   return CompletableFuture.completedFuture(null);
 }
Exemplo n.º 3
0
 /** Logs a request. */
 protected final <R extends Request> R logRequest(R request) {
   LOGGER.debug("{} - Received {}", context.getMember().id(), request);
   return request;
 }
Exemplo n.º 4
0
 /** Logs a response. */
 protected final <R extends Response> R logResponse(R response) {
   LOGGER.debug("{} - Sent {}", context.getMember().id(), response);
   return response;
 }
Exemplo n.º 5
0
 @Override
 public CompletableFuture<Void> close() {
   context.checkThread();
   open = false;
   return CompletableFuture.completedFuture(null);
 }