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());
}
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());
}
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);
}
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());
}
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());
}
Aggregations