Search in sources :

Example 86 with InternalCompletableFuture

use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.

the class Invocation_NestedRemoteTest method invokeOnPartition_outerRemote_innerSameInstance_samePartition.

@Test
public void invokeOnPartition_outerRemote_innerSameInstance_samePartition() {
    HazelcastInstance[] cluster = createHazelcastInstanceFactory(2).newInstances();
    HazelcastInstance local = cluster[0];
    HazelcastInstance remote = cluster[1];
    OperationService operationService = getOperationService(local);
    int partitionId = getPartitionId(remote);
    InnerOperation innerOperation = new InnerOperation(RESPONSE, partitionId);
    OuterOperation outerOperation = new OuterOperation(innerOperation, partitionId);
    InternalCompletableFuture future = operationService.invokeOnPartition(null, outerOperation, partitionId);
    assertEquals(RESPONSE, 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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 87 with InternalCompletableFuture

use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.

the class Invocation_NestedRemoteTest method invokeOnPartition_outerRemote_innerGeneric.

@Test
public void invokeOnPartition_outerRemote_innerGeneric() {
    HazelcastInstance[] cluster = createHazelcastInstanceFactory(2).newInstances();
    HazelcastInstance local = cluster[0];
    HazelcastInstance remote = cluster[1];
    OperationService operationService = getOperationService(local);
    int partitionId = getPartitionId(remote);
    InnerOperation innerOperation = new InnerOperation(RESPONSE, GENERIC_OPERATION);
    OuterOperation outerOperation = new OuterOperation(innerOperation, partitionId);
    InternalCompletableFuture future = operationService.invokeOnPartition(null, outerOperation, partitionId);
    assertEquals(RESPONSE, 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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 88 with InternalCompletableFuture

use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.

the class Invocation_NestedRemoteTest method invokeOnTarget_outerGeneric_innerSameInstance.

@Test
public void invokeOnTarget_outerGeneric_innerSameInstance() {
    HazelcastInstance[] cluster = createHazelcastInstanceFactory(2).newInstances();
    HazelcastInstance local = cluster[0];
    HazelcastInstance remote = cluster[1];
    OperationService operationService = getOperationService(local);
    InnerOperation innerOperation = new InnerOperation(RESPONSE, 0);
    OuterOperation outerOperation = new OuterOperation(innerOperation, GENERIC_OPERATION);
    InternalCompletableFuture future = operationService.invokeOnTarget(null, outerOperation, getAddress(remote));
    assertEquals(RESPONSE, 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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 89 with InternalCompletableFuture

use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.

the class Invocation_NestedLocalTest method invokeOnPartition_outerLocal_innerGeneric.

@Test
public void invokeOnPartition_outerLocal_innerGeneric() {
    HazelcastInstance local = createHazelcastInstance();
    OperationService operationService = getOperationService(local);
    int partitionId = getPartitionId(local);
    InnerOperation innerOperation = new InnerOperation(RESPONSE, GENERIC_OPERATION);
    OuterOperation outerOperation = new OuterOperation(innerOperation, partitionId);
    InternalCompletableFuture future = operationService.invokeOnPartition(null, outerOperation, partitionId);
    assertEquals(RESPONSE, 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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 90 with InternalCompletableFuture

use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.

the class Invocation_NestedLocalTest method invokeOnPartition_outerLocal_innerSameInstance_callsDifferentPartition.

@Test
public void invokeOnPartition_outerLocal_innerSameInstance_callsDifferentPartition() {
    HazelcastInstance local = createHazelcastInstance();
    OperationService operationService = getOperationService(local);
    int outerPartitionId = getPartitionId(local);
    int innerPartitionId = randomPartitionIdNotMappedToSameThreadAsGivenPartitionIdOnInstance(local, outerPartitionId);
    InnerOperation innerOperation = new InnerOperation(RESPONSE, innerPartitionId);
    OuterOperation outerOperation = new OuterOperation(innerOperation, outerPartitionId);
    InternalCompletableFuture future = operationService.invokeOnPartition(null, outerOperation, outerPartitionId);
    expected.expect(IllegalThreadStateException.class);
    expected.expectMessage("cannot make remote call");
    future.joinInternal();
}
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) 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