Search in sources :

Example 36 with InternalCompletableFuture

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();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) Accessors.getOperationService(com.hazelcast.test.Accessors.getOperationService) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 37 with InternalCompletableFuture

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();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) Accessors.getOperationService(com.hazelcast.test.Accessors.getOperationService) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 38 with InternalCompletableFuture

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();
}
Also used : RaftAlgorithmConfig(com.hazelcast.config.cp.RaftAlgorithmConfig) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) QueryRaftRunnable(com.hazelcast.cp.internal.raft.impl.dataservice.QueryRaftRunnable) 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 39 with InternalCompletableFuture

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());
}
Also used : ApplyRaftRunnable(com.hazelcast.cp.internal.raft.impl.dataservice.ApplyRaftRunnable) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) QueryRaftRunnable(com.hazelcast.cp.internal.raft.impl.dataservice.QueryRaftRunnable) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 40 with InternalCompletableFuture

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());
}
Also used : ApplyRaftRunnable(com.hazelcast.cp.internal.raft.impl.dataservice.ApplyRaftRunnable) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) QueryRaftRunnable(com.hazelcast.cp.internal.raft.impl.dataservice.QueryRaftRunnable) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

InternalCompletableFuture (com.hazelcast.spi.impl.InternalCompletableFuture)90 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)47 QuickTest (com.hazelcast.test.annotation.QuickTest)47 Test (org.junit.Test)47 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)19 HazelcastInstance (com.hazelcast.core.HazelcastInstance)17 Accessors.getOperationService (com.hazelcast.test.Accessors.getOperationService)15 Data (com.hazelcast.internal.serialization.Data)10 ArrayList (java.util.ArrayList)10 Map (java.util.Map)10 Operation (com.hazelcast.spi.impl.operationservice.Operation)9 UUID (java.util.UUID)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8 Member (com.hazelcast.cluster.Member)7 ApplyRaftRunnable (com.hazelcast.cp.internal.raft.impl.dataservice.ApplyRaftRunnable)7 Future (java.util.concurrent.Future)7 Address (com.hazelcast.cluster.Address)6 List (java.util.List)6 BiConsumer (java.util.function.BiConsumer)6 Nonnull (javax.annotation.Nonnull)6