Search in sources :

Example 1 with Response

use of org.neo4j.causalclustering.core.consensus.RaftMessages.AppendEntries.Response in project neo4j by neo4j.

the class AppendEntriesRequestTest method shouldRejectDiscontinuousEntries.

@Test
public void shouldRejectDiscontinuousEntries() throws Exception {
    // given
    RaftState state = raftState().myself(myself).build();
    long leaderTerm = state.term() + leaderTermDifference;
    // when
    Outcome outcome = role.handler.handle(appendEntriesRequest().from(leader).leaderTerm(leaderTerm).prevLogIndex(state.entryLog().appendIndex() + 1).prevLogTerm(leaderTerm).logEntry(new RaftLogEntry(leaderTerm, content())).build(), state, log());
    // then
    Response response = (Response) messageFor(outcome, leader);
    assertEquals(state.entryLog().appendIndex(), response.appendIndex());
    assertFalse(response.success());
}
Also used : Response(org.neo4j.causalclustering.core.consensus.RaftMessages.AppendEntries.Response) Outcome(org.neo4j.causalclustering.core.consensus.outcome.Outcome) RaftState(org.neo4j.causalclustering.core.consensus.state.RaftState) RaftLogEntry(org.neo4j.causalclustering.core.consensus.log.RaftLogEntry) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Response (org.neo4j.causalclustering.core.consensus.RaftMessages.AppendEntries.Response)1 RaftLogEntry (org.neo4j.causalclustering.core.consensus.log.RaftLogEntry)1 Outcome (org.neo4j.causalclustering.core.consensus.outcome.Outcome)1 RaftState (org.neo4j.causalclustering.core.consensus.state.RaftState)1