Examples of Replica


Examples of org.robotninjas.barge.Replica

      .setLastLogIndex(1)
      .setLastLogTerm(2)
      .setTerm(2)
      .build();

    Replica otherCandidate = config.getReplica("other");
    when(mockRaftLog.votedFor()).thenReturn(Optional.of(otherCandidate));
    boolean shouldVote = state.shouldVoteFor(mockRaftLog, requestVote);

    assertFalse(shouldVote);
  }
View Full Code Here

Examples of org.robotninjas.barge.Replica

      .setLastLogIndex(3)
      .setLastLogTerm(2)
      .setTerm(2)
      .build();

    Replica otherCandidate = config.getReplica("other");
    when(mockRaftLog.votedFor()).thenReturn(Optional.of(otherCandidate));
    boolean shouldVote = state.shouldVoteFor(mockRaftLog, requestVote);

    assertTrue(shouldVote);
  }
View Full Code Here

Examples of org.robotninjas.barge.Replica

  public void testRequestVoteWithNewerTerm() throws Exception {

    Candidate candidate = new Candidate(mockRaftLog, scheduler, 150, mockRaftClient);
    candidate.init(mockRaftStateContext);

    Replica mockCandidate = config.getReplica("other");

    RequestVote request =
      RequestVote.newBuilder()
        .setCandidateId(mockCandidate.toString())
        .setLastLogIndex(1L)
        .setLastLogTerm(1L)
        .setTerm(4L)
        .build();
View Full Code Here

Examples of org.robotninjas.barge.Replica

  @Test
  public void testRequestVoteWithOlderTerm() throws Exception {
    Candidate candidate = new Candidate(mockRaftLog, scheduler, 150, mockRaftClient);
    candidate.init(mockRaftStateContext);

    Replica mockCandidate = config.getReplica("other");

    RequestVote request =
      RequestVote.newBuilder()
        .setCandidateId(mockCandidate.toString())
        .setLastLogIndex(1L)
        .setLastLogTerm(1L)
        .setTerm(1L)
        .build();
View Full Code Here

Examples of org.robotninjas.barge.Replica

  @Test
  public void testRequestVoteWithSameTerm() throws Exception {
    Candidate candidate = new Candidate(mockRaftLog, scheduler, 150, mockRaftClient);
    candidate.init(mockRaftStateContext);

    Replica mockCandidate = config.getReplica("other");

    RequestVote request =
      RequestVote.newBuilder()
        .setCandidateId(mockCandidate.toString())
        .setLastLogIndex(1L)
        .setLastLogTerm(1L)
        .setTerm(2L)
        .build();
View Full Code Here

Examples of org.robotninjas.barge.Replica

  public void testAppendEntriesWithNewerTerm() throws Exception {

    Candidate candidate = new Candidate(mockRaftLog, scheduler, 1, mockRaftClient);
    candidate.init(mockRaftStateContext);

    Replica mockLeader = config.getReplica("other");

    AppendEntries request =
      AppendEntries.newBuilder()
        .setTerm(4L)
        .setLeaderId(mockLeader.toString())
        .setPrevLogIndex(1L)
        .setPrevLogTerm(1L)
        .setCommitIndex(1L)
        .build();
View Full Code Here

Examples of org.robotninjas.barge.Replica

  public void testAppendEntriesWithOlderTerm() throws Exception {

    Candidate candidate = new Candidate(mockRaftLog, scheduler, 1, mockRaftClient);
    candidate.init(mockRaftStateContext);

    Replica mockLeader = config.getReplica("other");

    AppendEntries request =
      AppendEntries.newBuilder()
        .setTerm(1L)
        .setLeaderId(mockLeader.toString())
        .setPrevLogIndex(1L)
        .setPrevLogTerm(1L)
        .setCommitIndex(1L)
        .build();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.