Search in sources :

Example 51 with OperationService

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

the class Invocation_DetectHeartbeatTimeoutTest method whenCallTimeoutDisabled.

@Test
public void whenCallTimeoutDisabled() {
    Config config = new Config();
    config.setProperty(OPERATION_CALL_TIMEOUT_MILLIS.getName(), "1000");
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
    HazelcastInstance local = factory.newHazelcastInstance();
    HazelcastInstance remote = factory.newHazelcastInstance();
    OperationService opService = getOperationService(local);
    Operation operation = new VoidOperation();
    InvocationFuture future = (InvocationFuture) opService.createInvocationBuilder(null, operation, getPartitionId(remote)).setCallTimeout(Long.MAX_VALUE).invoke();
    Invocation invocation = future.invocation;
    assertEquals(Long.MAX_VALUE, invocation.op.getCallTimeout());
    assertEquals(Long.MAX_VALUE, invocation.callTimeoutMillis);
    assertEquals(NO_TIMEOUT__CALL_TIMEOUT_DISABLED, invocation.detectTimeout(SECONDS.toMillis(1)));
    assertFalse(future.isDone());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) OperationService(com.hazelcast.spi.OperationService) Operation(com.hazelcast.spi.Operation) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 52 with OperationService

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

the class Invocation_DetectHeartbeatTimeoutTest method whenCallTimeoutNotExpired.

@Test
public void whenCallTimeoutNotExpired() {
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
    HazelcastInstance local = factory.newHazelcastInstance();
    HazelcastInstance remote = factory.newHazelcastInstance();
    OperationService opService = getOperationService(local);
    Operation operation = new SlowOperation(SECONDS.toMillis(60));
    InvocationFuture future = (InvocationFuture) opService.invokeOnPartition(null, operation, getPartitionId(remote));
    Invocation invocation = future.invocation;
    assertEquals(NO_TIMEOUT__CALL_TIMEOUT_NOT_EXPIRED, invocation.detectTimeout(SECONDS.toMillis(1)));
    assertFalse(future.isDone());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) OperationService(com.hazelcast.spi.OperationService) Operation(com.hazelcast.spi.Operation) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 53 with OperationService

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

the class Invocation_DetectHeartbeatTimeoutTest method whenCallTimeoutExpired_ButOperationHeartbeatHasNot.

@Test
public void whenCallTimeoutExpired_ButOperationHeartbeatHasNot() {
    Config config = new Config();
    config.setProperty(OPERATION_CALL_TIMEOUT_MILLIS.getName(), "5000");
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
    HazelcastInstance local = factory.newHazelcastInstance(config);
    HazelcastInstance remote = factory.newHazelcastInstance(config);
    OperationService opService = getOperationService(local);
    InvocationFuture future = (InvocationFuture) opService.invokeOnPartition(new SlowOperation(SECONDS.toMillis(60)).setPartitionId(getPartitionId(remote)));
    assertDetectHeartbeatTimeoutEventually(future.invocation, NO_TIMEOUT__HEARTBEAT_TIMEOUT_NOT_EXPIRED);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) OperationService(com.hazelcast.spi.OperationService) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 54 with OperationService

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

the class Invocation_DetectHeartbeatTimeoutTest method whenResponseAvailable.

@Test
public void whenResponseAvailable() {
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
    HazelcastInstance local = factory.newHazelcastInstance();
    HazelcastInstance remote = factory.newHazelcastInstance();
    OperationService opService = getOperationService(local);
    Operation operation = new SlowOperation(SECONDS.toMillis(60));
    InvocationFuture future = (InvocationFuture) opService.invokeOnPartition(null, operation, getPartitionId(remote));
    Invocation invocation = future.invocation;
    invocation.pendingResponse = "foo";
    invocation.backupsAcksExpected = 1;
    assertEquals(NO_TIMEOUT__RESPONSE_AVAILABLE, invocation.detectTimeout(SECONDS.toMillis(1)));
    assertFalse(future.isDone());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) OperationService(com.hazelcast.spi.OperationService) Operation(com.hazelcast.spi.Operation) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 55 with OperationService

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

the class Invocation_NestedLocalTest method invokeOnPartition_outerLocal_innerSameInstance_samePartition.

@Test
public void invokeOnPartition_outerLocal_innerSameInstance_samePartition() {
    HazelcastInstance local = createHazelcastInstance();
    OperationService operationService = getOperationService(local);
    int partitionId = getPartitionId(local);
    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.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