use of com.hazelcast.cp.internal.raft.impl.dataservice.QueryRaftRunnable in project hazelcast by hazelcast.
the class LinearizableQueryTest method when_multipleQueryLimitIsReachedBeforeHeartbeatAcks_then_noNewQueryIsAccepted.
@Test(timeout = 300_000)
public void when_multipleQueryLimitIsReachedBeforeHeartbeatAcks_then_noNewQueryIsAccepted() throws Exception {
RaftAlgorithmConfig config = new RaftAlgorithmConfig().setUncommittedEntryCountToRejectNewAppends(1);
group = new LocalRaftGroupBuilder(5, config).setAppendNopEntryOnLeaderElection(true).build();
group.start();
RaftNodeImpl leader = group.waitUntilLeaderElected();
assertTrueEventually(() -> assertThat(getCommitIndex(leader), greaterThanOrEqualTo(1L)));
RaftNodeImpl[] followers = group.getNodesExcept(leader.getLocalMember());
group.dropMessagesToMember(leader.getLocalMember(), followers[0].getLocalMember(), AppendRequest.class);
group.dropMessagesToMember(leader.getLocalMember(), followers[1].getLocalMember(), AppendRequest.class);
group.dropMessagesToMember(leader.getLocalMember(), followers[2].getLocalMember(), AppendRequest.class);
InternalCompletableFuture queryFuture1 = leader.query(new QueryRaftRunnable(), LINEARIZABLE);
InternalCompletableFuture queryFuture2 = leader.query(new QueryRaftRunnable(), LINEARIZABLE);
try {
queryFuture2.joinInternal();
fail();
} catch (CannotReplicateException ignored) {
}
group.resetAllRulesFrom(leader.getLocalMember());
queryFuture1.get();
}
use of com.hazelcast.cp.internal.raft.impl.dataservice.QueryRaftRunnable in project hazelcast by hazelcast.
the class LinearizableQueryTest method when_multipleQueriesAreIssuedBeforeHeartbeatAcksReceived_then_allQueriesExecutedAtOnce.
@Test(timeout = 300_000)
public void when_multipleQueriesAreIssuedBeforeHeartbeatAcksReceived_then_allQueriesExecutedAtOnce() throws Exception {
group = newGroup();
group.start();
RaftNodeImpl leader = group.waitUntilLeaderElected();
leader.replicate(new ApplyRaftRunnable("value1")).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);
group.dropMessagesToMember(leader.getLocalMember(), followers[2].getLocalMember(), AppendRequest.class);
InternalCompletableFuture queryFuture1 = leader.query(new QueryRaftRunnable(), LINEARIZABLE);
InternalCompletableFuture queryFuture2 = leader.query(new QueryRaftRunnable(), LINEARIZABLE);
group.resetAllRulesFrom(leader.getLocalMember());
assertEquals("value1", queryFuture1.get());
assertEquals("value1", queryFuture2.get());
}
use of com.hazelcast.cp.internal.raft.impl.dataservice.QueryRaftRunnable in project hazelcast by hazelcast.
the class LinearizableQueryTest method when_newCommitIsDoneWhileThereAreMultipleQueries_then_allQueriesRunAfterCommit.
@Test(timeout = 300_000)
public void when_newCommitIsDoneWhileThereAreMultipleQueries_then_allQueriesRunAfterCommit() throws Exception {
group = newGroup();
group.start();
RaftNodeImpl leader = group.waitUntilLeaderElected();
leader.replicate(new ApplyRaftRunnable("value1")).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);
group.dropMessagesToMember(leader.getLocalMember(), followers[2].getLocalMember(), AppendRequest.class);
InternalCompletableFuture replicateFuture = leader.replicate(new ApplyRaftRunnable("value2"));
InternalCompletableFuture queryFuture1 = leader.query(new QueryRaftRunnable(), LINEARIZABLE);
InternalCompletableFuture queryFuture2 = leader.query(new QueryRaftRunnable(), LINEARIZABLE);
group.resetAllRulesFrom(leader.getLocalMember());
replicateFuture.get();
assertEquals("value2", queryFuture1.get());
assertEquals("value2", queryFuture2.get());
}
use of com.hazelcast.cp.internal.raft.impl.dataservice.QueryRaftRunnable 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.cp.internal.raft.impl.dataservice.QueryRaftRunnable in project hazelcast by hazelcast.
the class LinearizableQueryTest method when_newCommitIsDoneWhileThereIsWaitingQuery_then_queryRunsAfterNewCommit.
@Test(timeout = 300_000)
public void when_newCommitIsDoneWhileThereIsWaitingQuery_then_queryRunsAfterNewCommit() throws Exception {
group = newGroup();
group.start();
RaftNodeImpl leader = group.waitUntilLeaderElected();
leader.replicate(new ApplyRaftRunnable("value1")).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);
group.dropMessagesToMember(leader.getLocalMember(), followers[2].getLocalMember(), AppendRequest.class);
InternalCompletableFuture replicateFuture = leader.replicate(new ApplyRaftRunnable("value2"));
InternalCompletableFuture queryFuture = leader.query(new QueryRaftRunnable(), LINEARIZABLE);
group.resetAllRulesFrom(leader.getLocalMember());
replicateFuture.get();
Object o = queryFuture.get();
assertEquals("value2", o);
}
Aggregations