use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class Invocation_NestedRemoteTest method invokeOnPartition_outerLocal_innerDifferentInstance_forbidden.
@Test
public void invokeOnPartition_outerLocal_innerDifferentInstance_forbidden() {
HazelcastInstance[] cluster = createHazelcastInstanceFactory(2).newInstances();
HazelcastInstance local = cluster[0];
HazelcastInstance remote = cluster[1];
OperationService operationService = getOperationService(local);
int outerPartitionId = getPartitionId(local);
int innerPartitionId = getPartitionId(remote);
assertNotEquals("partitions should be different", innerPartitionId, outerPartitionId);
InnerOperation innerOperation = new InnerOperation(RESPONSE, innerPartitionId);
OuterOperation outerOperation = new OuterOperation(innerOperation, outerPartitionId);
InternalCompletableFuture future = operationService.invokeOnPartition(null, outerOperation, outerPartitionId);
expected.expect(CompletionException.class);
expected.expect(new RootCauseMatcher(IllegalThreadStateException.class));
expected.expectMessage("cannot make remote call");
future.join();
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class Invocation_NestedRemoteTest method invokeOnPartition_outerRemote_innerSameInstance_callsDifferentPartition_mappedToSameThread.
@Test
public void invokeOnPartition_outerRemote_innerSameInstance_callsDifferentPartition_mappedToSameThread() {
HazelcastInstance[] cluster = createHazelcastInstanceFactory(2).newInstances();
HazelcastInstance local = cluster[0];
HazelcastInstance remote = cluster[1];
OperationService operationService = getOperationService(local);
int outerPartitionId = getPartitionId(remote);
int innerPartitionId = randomPartitionIdMappedToSameThreadAsGivenPartitionIdOnInstance(outerPartitionId, remote, operationService);
InnerOperation innerOperation = new InnerOperation(RESPONSE, innerPartitionId);
OuterOperation outerOperation = new OuterOperation(innerOperation, outerPartitionId);
InternalCompletableFuture future = operationService.invokeOnPartition(null, outerOperation, outerPartitionId);
expected.expect(CompletionException.class);
expected.expect(new RootCauseMatcher(IllegalThreadStateException.class));
expected.expectMessage("cannot make remote call");
future.join();
}
use of com.hazelcast.spi.impl.InternalCompletableFuture 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.spi.impl.InternalCompletableFuture 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.spi.impl.InternalCompletableFuture 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());
}
Aggregations