consensus-raft/src/test/java/com/mboysan/consensus/RaftNodeTest.java
/**
     * Tests cancellation of a command append event.
     */
Tests cancellation of a command append event.
Tests cancellation of a command append event .
@Test
    void testAppendFutureCancellation() throws Exception {
        int numServers = 3;
        init(numServers);
        int leaderId = assertOneLeader();
        disconnect((leaderId + 1) % numServers);
        disconnect((leaderId + 2) % numServers);
        Future<Boolean> result0 = getNode(leaderId).append("cmd0");
        assertThrows(TimeoutException.class, () -> result0.get(1, TimeUnit.SECONDS));
        result0.cancel(true);
        assertThrows(CancellationException.class, result0::get);
    }
@ Test void testAppendFutureCancellation ( ) throws Exception { int numServers = 3 ; init ( numServers ) ; int leaderId = assertOneLeader ( ) ; disconnect ( ( leaderId + 1 ) % numServers ) ; disconnect ( ( leaderId + 2 ) % numServers ) ; Future < Boolean > result0 = getNode ( leaderId ) . append ( "cmd0" ) ; assertThrows ( TimeoutException . class , ( ) -> result0 . get ( 1 , TimeUnit . SECONDS ) ) ; result0 . cancel ( true ) ; assertThrows ( CancellationException . class , result0 :: get ) ; }
Tests cancellation of a command append event.
Tests cancellation of a command append event .
// break the quorum and try to append a command, progress cannot be made hence, we need to cancel the // future received.