use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class LinearizableQueryTest method when_leaderDemotesToFollowerWhileThereIsOngoingQuery_then_queryFails.
@Test(timeout = 300_000)
public void when_leaderDemotesToFollowerWhileThereIsOngoingQuery_then_queryFails() throws Exception {
group = newGroup();
group.start();
RaftNodeImpl oldLeader = group.waitUntilLeaderElected();
final int[] split = group.createMajoritySplitIndexes(false);
group.split(split);
InternalCompletableFuture queryFuture = oldLeader.query(new QueryRaftRunnable(), LINEARIZABLE);
assertTrueEventually(() -> {
for (int ix : split) {
RaftEndpoint newLeader = getLeaderMember(group.getNode(ix));
assertNotNull(newLeader);
assertNotEquals(oldLeader.getLocalMember(), newLeader);
}
});
RaftNodeImpl newLeader = group.getNode(getLeaderMember(group.getNode(split[0])));
newLeader.replicate(new ApplyRaftRunnable("value1")).get();
group.merge();
group.waitUntilLeaderElected();
assertEquals(oldLeader.getLeader(), newLeader.getLocalMember());
try {
queryFuture.joinInternal();
fail();
} catch (LeaderDemotedException ignored) {
}
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class LocalRaftTest method when_leaderStaysInMinority_then_itDemotesItselfToFollower.
@Test
public void when_leaderStaysInMinority_then_itDemotesItselfToFollower() {
group = newGroup(3);
group.start();
RaftNodeImpl leader = group.waitUntilLeaderElected();
group.split(leader.getLocalMember());
InternalCompletableFuture f = leader.replicate(new ApplyRaftRunnable("val"));
try {
f.joinInternal();
fail();
} catch (StaleAppendRequestException ignored) {
}
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class LeadershipTransferTest method testCannotTransferLeadershipToInvalidEndpoint.
@Test
public void testCannotTransferLeadershipToInvalidEndpoint() throws Exception {
group = newGroup(3);
group.start();
RaftNodeImpl leader = group.waitUntilLeaderElected();
RaftEndpoint invalidEndpoint = newRaftMember(1000);
InternalCompletableFuture future = leader.transferLeadership(invalidEndpoint);
exceptionRule.expect(IllegalArgumentException.class);
future.joinInternal();
}
use of com.hazelcast.spi.impl.InternalCompletableFuture 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.spi.impl.InternalCompletableFuture 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();
}
Aggregations