consensus-raft/src/test/java/com/mboysan/consensus/RaftNodeTest.java
/**
     * When a follower disconnects, it will not be able to receive the append event. Instead, it will try to start
     * a new election (increasing term), and will reject all the AppendEntries requests with this new term. However,
     * other nodes will not recognize its leadership because of log inconsistencies. Therefore, eventually (after
     * enough time passes) all nodes will possibly elect a new leader and sync the logs.
     */
When a follower disconnects, it will not be able to receive the append event. Instead, it will try to start
a new election (increasing term), and will reject all the AppendEntries requests with this new term. However,
other nodes will not recognize its leadership because of log inconsistencies. Therefore, eventually (after
enough time passes) all nodes will possibly elect a new leader and sync the logs.
When a follower disconnects it will not be able to receive the append event . Instead it will try to start a new election ( increasing term ) and will reject all the AppendEntries requests with this new term . However other nodes will not recognize its leadership because of log inconsistencies . Therefore eventually ( after enough time passes ) all nodes will possibly elect a new leader and sync the logs .
@Test
    void testFollowerDisconnectsDuringAppend() throws Exception {
        int numServers = 5;
        init(numServers);
        int leaderId = assertOneLeader();
        disconnect((leaderId + 1) % numServers);
        disconnect((leaderId + 2) % numServers);
        List<String> expectedCommands = List.of("cmd0");
        getNode(leaderId).append(expectedCommands.get(0)).get();
        advanceTimeForElections();
        connect((leaderId + 1) % numServers);
        connect((leaderId + 2) % numServers);
        advanceTimeForElections();
        assertOneLeader();  
        assertLogsEquals(expectedCommands);
    }
@ Test void testFollowerDisconnectsDuringAppend ( ) throws Exception { int numServers = 5 ; init ( numServers ) ; int leaderId = assertOneLeader ( ) ; disconnect ( ( leaderId + 1 ) % numServers ) ; disconnect ( ( leaderId + 2 ) % numServers ) ; List < String > expectedCommands = List . of ( "cmd0" ) ; getNode ( leaderId ) . append ( expectedCommands . get ( 0 ) ) . get ( ) ; advanceTimeForElections ( ) ; connect ( ( leaderId + 1 ) % numServers ) ; connect ( ( leaderId + 2 ) % numServers ) ; advanceTimeForElections ( ) ; assertOneLeader ( ) ; assertLogsEquals ( expectedCommands ) ; }
When a follower disconnects, it will not be able to receive the append event.
When a follower disconnects it will not be able to receive the append event .
// leader might've changed but there must still be only one leader.