Search in sources :

Example 26 with OperationService

use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.

the class Invocation_NestedLocalTest method invokeOnTarget_outerGeneric_innerGeneric.

@Test
public void invokeOnTarget_outerGeneric_innerGeneric() {
    HazelcastInstance local = createHazelcastInstance();
    OperationService operationService = getOperationService(local);
    InnerOperation innerOperation = new InnerOperation(RESPONSE, GENERIC_OPERATION);
    OuterOperation outerOperation = new OuterOperation(innerOperation, GENERIC_OPERATION);
    InternalCompletableFuture future = operationService.invokeOnTarget(null, outerOperation, getAddress(local));
    assertEquals(RESPONSE, future.join());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) InternalCompletableFuture(com.hazelcast.spi.InternalCompletableFuture) OperationService(com.hazelcast.spi.OperationService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 27 with OperationService

use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.

the class Invocation_NestedLocalTest method invokeOnPartition_outerLocal_innerSameInstance_callsDifferentPartition_mappedToSameThread.

@Test
public void invokeOnPartition_outerLocal_innerSameInstance_callsDifferentPartition_mappedToSameThread() throws Exception {
    Config config = new Config();
    config.setProperty(GroupProperty.PARTITION_COUNT.getName(), "2");
    config.setProperty(GroupProperty.PARTITION_OPERATION_THREAD_COUNT.getName(), "1");
    HazelcastInstance local = createHazelcastInstance(config);
    final OperationService operationService = getOperationService(local);
    int outerPartitionId = 1;
    int innerPartitionId = 0;
    InnerOperation innerOperation = new InnerOperation(RESPONSE, innerPartitionId);
    OuterOperation outerOperation = new OuterOperation(innerOperation, outerPartitionId);
    InternalCompletableFuture future = operationService.invokeOnPartition(null, outerOperation, outerOperation.getPartitionId());
    expected.expect(IllegalThreadStateException.class);
    expected.expectMessage("cannot make remote call");
    future.join();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) InternalCompletableFuture(com.hazelcast.spi.InternalCompletableFuture) OperationService(com.hazelcast.spi.OperationService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 28 with OperationService

use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.

the class Invocation_NestedRemoteTest method invokeOnPartition_outerRemote_innerSameInstance_callsDifferentPartition_mappedToSameThread.

@Test
public void invokeOnPartition_outerRemote_innerSameInstance_callsDifferentPartition_mappedToSameThread() throws Exception {
    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(IllegalThreadStateException.class);
    expected.expectMessage("cannot make remote call");
    future.join();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) InternalCompletableFuture(com.hazelcast.spi.InternalCompletableFuture) OperationService(com.hazelcast.spi.OperationService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 29 with OperationService

use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.

the class Invocation_NestedRemoteTest method invokeOnTarget_outerGeneric_innerGeneric.

@Test
public void invokeOnTarget_outerGeneric_innerGeneric() {
    HazelcastInstance[] cluster = createHazelcastInstanceFactory(2).newInstances();
    HazelcastInstance local = cluster[0];
    HazelcastInstance remote = cluster[1];
    OperationService operationService = getOperationService(local);
    InnerOperation innerOperation = new InnerOperation(RESPONSE, GENERIC_OPERATION);
    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.InternalCompletableFuture) OperationService(com.hazelcast.spi.OperationService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 30 with OperationService

use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.

the class Invocation_NestedRemoteTest method invokeOnPartition_outerRemote_innerDifferentInstance_forbidden.

@Test
public void invokeOnPartition_outerRemote_innerDifferentInstance_forbidden() {
    HazelcastInstance[] cluster = createHazelcastInstanceFactory(2).newInstances();
    HazelcastInstance local = cluster[0];
    HazelcastInstance remote = cluster[1];
    OperationService operationService = getOperationService(local);
    int outerPartitionId = getPartitionId(remote);
    int innerPartitionId = getPartitionId(local);
    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(IllegalThreadStateException.class);
    expected.expectMessage("cannot make remote call");
    future.join();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) InternalCompletableFuture(com.hazelcast.spi.InternalCompletableFuture) OperationService(com.hazelcast.spi.OperationService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

OperationService (com.hazelcast.spi.OperationService)135 Test (org.junit.Test)49 QuickTest (com.hazelcast.test.annotation.QuickTest)48 ParallelTest (com.hazelcast.test.annotation.ParallelTest)46 HazelcastInstance (com.hazelcast.core.HazelcastInstance)45 Operation (com.hazelcast.spi.Operation)39 NodeEngine (com.hazelcast.spi.NodeEngine)30 Address (com.hazelcast.nio.Address)26 Future (java.util.concurrent.Future)26 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)24 Config (com.hazelcast.config.Config)21 InternalCompletableFuture (com.hazelcast.spi.InternalCompletableFuture)21 Member (com.hazelcast.core.Member)19 Data (com.hazelcast.nio.serialization.Data)14 ArrayList (java.util.ArrayList)11 Node (com.hazelcast.instance.Node)7 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)7 ExecutionException (java.util.concurrent.ExecutionException)7 TimeoutException (java.util.concurrent.TimeoutException)7 OperationTimeoutException (com.hazelcast.core.OperationTimeoutException)6