use of com.hazelcast.cp.internal.raft.impl.testing.NopEntry in project hazelcast by hazelcast.
the class LeadershipTransferTest method testTransferLeadershipWhenEntriesAppended.
@Test
public void testTransferLeadershipWhenEntriesAppended() throws Exception {
group = newGroup(3);
group.start();
RaftNodeImpl leader = group.waitUntilLeaderElected();
int term1 = getTerm(leader);
leader.replicate(new NopEntry()).get();
RaftNodeImpl follower = group.getNodesExcept(leader.getLocalMember())[0];
Future f = leader.transferLeadership(follower.getLocalMember());
f.get();
RaftNodeImpl newLeader = group.waitUntilLeaderElected();
int term2 = getTerm(newLeader);
assertNotSame(leader, newLeader);
assertTrue(term2 > term1);
assertEquals(RaftRole.FOLLOWER, getRole(leader));
}
use of com.hazelcast.cp.internal.raft.impl.testing.NopEntry in project hazelcast by hazelcast.
the class LeadershipTransferTest method testNewLeaderCommitsAfterLeadershipTransfer.
@Test
public void testNewLeaderCommitsAfterLeadershipTransfer() throws Exception {
group = newGroup(3);
group.start();
RaftNodeImpl leader = group.waitUntilLeaderElected();
RaftNodeImpl follower = group.getNodesExcept(leader.getLocalMember())[0];
leader.transferLeadership(follower.getLocalMember()).get();
RaftNodeImpl newLeader = group.waitUntilLeaderElected();
assertNotSame(leader, newLeader);
Future f = newLeader.replicate(new NopEntry());
f.get();
}
use of com.hazelcast.cp.internal.raft.impl.testing.NopEntry in project hazelcast by hazelcast.
the class LeadershipTransferTest method testCannotTransferLeadershipWhileChangingMemberList.
@Test
public void testCannotTransferLeadershipWhileChangingMemberList() throws Exception {
RaftAlgorithmConfig config = new RaftAlgorithmConfig().setLeaderHeartbeatPeriodInMillis(SECONDS.toMillis(30));
group = new LocalRaftGroupBuilder(3, config).build();
group.start();
RaftNodeImpl leader = group.waitUntilLeaderElected();
leader.replicate(new NopEntry()).get();
RaftNodeImpl[] followers = group.getNodesExcept(leader.getLocalMember());
group.dropMessagesToMember(leader.getLocalMember(), followers[0].getLocalMember(), AppendRequest.class);
group.dropMessagesToMember(leader.getLocalMember(), followers[1].getLocalMember(), AppendRequest.class);
leader.replicateMembershipChange(followers[0].getLocalMember(), MembershipChangeMode.REMOVE);
InternalCompletableFuture f = leader.transferLeadership(followers[0].getLocalMember());
exceptionRule.expect(IllegalStateException.class);
f.joinInternal();
}
use of com.hazelcast.cp.internal.raft.impl.testing.NopEntry in project hazelcast by hazelcast.
the class LeadershipTransferTest method testCannotReplicateNewEntryDuringLeadershipTransfer.
@Test
public void testCannotReplicateNewEntryDuringLeadershipTransfer() throws Exception {
group = newGroup(3);
group.start();
RaftNodeImpl leader = group.waitUntilLeaderElected();
RaftNodeImpl follower = group.getNodesExcept(leader.getLocalMember())[0];
group.dropMessagesToMember(leader.getLocalMember(), follower.getLocalMember(), AppendRequest.class);
leader.replicate(new NopEntry()).get();
leader.transferLeadership(follower.getLocalMember());
InternalCompletableFuture f = leader.replicate(new NopEntry());
exceptionRule.expect(CannotReplicateException.class);
f.joinInternal();
}
use of com.hazelcast.cp.internal.raft.impl.testing.NopEntry in project hazelcast by hazelcast.
the class LeadershipTransferTest method testOldLeaderCannotReplicateAfterLeadershipTransfer.
@Test
public void testOldLeaderCannotReplicateAfterLeadershipTransfer() throws Exception {
group = newGroup(3);
group.start();
RaftNodeImpl leader = group.waitUntilLeaderElected();
RaftNodeImpl follower = group.getNodesExcept(leader.getLocalMember())[0];
leader.transferLeadership(follower.getLocalMember()).get();
RaftNodeImpl newLeader = group.waitUntilLeaderElected();
assertNotSame(leader, newLeader);
InternalCompletableFuture f = leader.replicate(new NopEntry());
exceptionRule.expect(NotLeaderException.class);
f.joinInternal();
}
Aggregations