Search in sources :

Example 6 with CannotReplicateException

use of com.hazelcast.cp.exception.CannotReplicateException in project hazelcast by hazelcast.

the class MembershipChangeTest method when_leaderIsSteppingDown_then_itDoesNotAcceptNewAppends.

@Test
public void when_leaderIsSteppingDown_then_itDoesNotAcceptNewAppends() throws ExecutionException, InterruptedException {
    group = new LocalRaftGroupBuilder(3).setAppendNopEntryOnLeaderElection(true).build();
    group.start();
    RaftNodeImpl leader = group.waitUntilLeaderElected();
    RaftNodeImpl[] followers = group.getNodesExcept(leader.getLocalMember());
    group.dropMessagesToMember(leader.getLocalMember(), followers[0].getLocalMember(), AppendRequest.class);
    group.dropMessagesToMember(leader.getLocalMember(), followers[1].getLocalMember(), AppendRequest.class);
    InternalCompletableFuture f1 = leader.replicateMembershipChange(leader.getLocalMember(), REMOVE);
    InternalCompletableFuture f2 = leader.replicate(new PostponedResponseRaftRunnable());
    assertFalse(f1.isDone());
    assertTrueEventually(() -> assertTrue(f2.isDone()));
    try {
        f2.joinInternal();
        fail();
    } catch (CannotReplicateException ignored) {
    }
}
Also used : InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) LocalRaftGroupBuilder(com.hazelcast.cp.internal.raft.impl.testing.LocalRaftGroup.LocalRaftGroupBuilder) CannotReplicateException(com.hazelcast.cp.exception.CannotReplicateException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with CannotReplicateException

use of com.hazelcast.cp.exception.CannotReplicateException in project hazelcast by hazelcast.

the class DestroyRaftGroupTest method when_destroyOpIsAppendedButNotCommitted_then_cannotAppendNewEntry.

@Test
public void when_destroyOpIsAppendedButNotCommitted_then_cannotAppendNewEntry() throws ExecutionException, InterruptedException {
    group = newGroup(2);
    group.start();
    RaftNodeImpl leader = group.waitUntilLeaderElected();
    RaftNodeImpl follower = group.getAnyFollowerNode();
    group.dropAllMessagesToMember(leader.getLocalMember(), follower.getLocalMember());
    leader.replicate(new DestroyRaftGroupCmd());
    try {
        leader.replicate(new ApplyRaftRunnable("val")).joinInternal();
        fail();
    } catch (CannotReplicateException ignored) {
    }
}
Also used : DestroyRaftGroupCmd(com.hazelcast.cp.internal.raft.command.DestroyRaftGroupCmd) ApplyRaftRunnable(com.hazelcast.cp.internal.raft.impl.dataservice.ApplyRaftRunnable) CannotReplicateException(com.hazelcast.cp.exception.CannotReplicateException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

CannotReplicateException (com.hazelcast.cp.exception.CannotReplicateException)7 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)5 QuickTest (com.hazelcast.test.annotation.QuickTest)5 Test (org.junit.Test)5 LocalRaftGroupBuilder (com.hazelcast.cp.internal.raft.impl.testing.LocalRaftGroup.LocalRaftGroupBuilder)3 RaftAlgorithmConfig (com.hazelcast.config.cp.RaftAlgorithmConfig)2 NotLeaderException (com.hazelcast.cp.exception.NotLeaderException)2 ApplyRaftRunnable (com.hazelcast.cp.internal.raft.impl.dataservice.ApplyRaftRunnable)2 RaftState (com.hazelcast.cp.internal.raft.impl.state.RaftState)2 InternalCompletableFuture (com.hazelcast.spi.impl.InternalCompletableFuture)2 CPSubsystemException (com.hazelcast.cp.exception.CPSubsystemException)1 DestroyRaftGroupCmd (com.hazelcast.cp.internal.raft.command.DestroyRaftGroupCmd)1 RaftEndpoint (com.hazelcast.cp.internal.raft.impl.RaftEndpoint)1 QueryRaftRunnable (com.hazelcast.cp.internal.raft.impl.dataservice.QueryRaftRunnable)1 LogEntry (com.hazelcast.cp.internal.raft.impl.log.LogEntry)1 RaftLog (com.hazelcast.cp.internal.raft.impl.log.RaftLog)1 QueryState (com.hazelcast.cp.internal.raft.impl.state.QueryState)1 UUID (java.util.UUID)1