Package org.robotninjas.barge

Examples of org.robotninjas.barge.NotLeaderException


  @Override
  public ListenableFuture<Object> commitOperation(@Nonnull RaftStateContext ctx, @Nonnull byte[] operation) throws RaftException {
    StateType stateType = ctx.type();
    Preconditions.checkNotNull(stateType);
    if (stateType.equals(FOLLOWER)) {
      throw new NotLeaderException(leader.get());
    } else if (stateType.equals(CANDIDATE)) {
      throw new NoLeaderException();
    }
    return Futures.immediateCancelledFuture();
  }
View Full Code Here


  }

  @Test
  public void onPOSTCommitReturn302WithLeaderURIGivenRaftThrowsNotLeaderException() throws Exception {
    URI leaderURI = new URI("http://localhost:1234");
    when(raftService.commitOperation("foo".getBytes())).thenThrow(new NotLeaderException(new HttpReplica(leaderURI)));

    Response value = client().target("/commit")
        .request()
        .post(Entity.entity("foo".getBytes(), MediaType.APPLICATION_OCTET_STREAM));
View Full Code Here

TOP

Related Classes of org.robotninjas.barge.NotLeaderException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.