use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class Invocation_TimeoutTest method async_whenEventuallyHeartbeatTimeout_thenOperationTimeoutException.
@Test
public void async_whenEventuallyHeartbeatTimeout_thenOperationTimeoutException() throws Exception {
long callTimeoutMs = 5000;
Config config = new Config().setProperty(GroupProperty.OPERATION_CALL_TIMEOUT_MILLIS.getName(), "" + callTimeoutMs);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance local = factory.newHazelcastInstance(config);
HazelcastInstance remote = factory.newHazelcastInstance(config);
warmUpPartitions(local, remote);
OperationService opService = getOperationService(local);
ICompletableFuture<Object> future = opService.invokeOnPartition(null, new VoidOperation(callTimeoutMs * 5), getPartitionId(remote));
final ExecutionCallback<Object> callback = getExecutionCallbackMock();
future.andThen(callback);
assertEventuallyFailsWithHeartbeatTimeout(callback);
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class Invocation_TimeoutTest method async_whenCallTimeout_thenOperationTimeoutException.
@Test
public void async_whenCallTimeout_thenOperationTimeoutException() throws Exception {
long callTimeoutMs = 60000;
Config config = new Config().setProperty(GroupProperty.OPERATION_CALL_TIMEOUT_MILLIS.getName(), "" + callTimeoutMs);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance local = factory.newHazelcastInstance(config);
HazelcastInstance remote = factory.newHazelcastInstance(config);
warmUpPartitions(local, remote);
OperationService opService = getOperationService(local);
int partitionId = getPartitionId(remote);
long slowOperationDurationMs = (long) (callTimeoutMs * 1.1);
opService.invokeOnPartition(new SlowOperation(slowOperationDurationMs).setPartitionId(partitionId));
ICompletableFuture<Object> future = opService.invokeOnPartition(new DummyOperation().setPartitionId(partitionId));
ExecutionCallback<Object> callback = getExecutionCallbackMock();
future.andThen(callback);
assertEventuallyFailsWithCallTimeout(callback);
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class Invocation_TimeoutTest method sync_whenEventuallyHeartbeatTimeout_thenOperationTimeoutException.
// ==================== eventually operation heartbeat timeout ===============================================================
// This test verifies that an Invocation is going to timeout when initially there was a heartbeat, but eventually this
// heartbeat stops
//
// This is done by creating a void operation that runs for an extended period and on completion, the void operation doesn't
// send a response.
// ===========================================================================================================================
@Test
public void sync_whenEventuallyHeartbeatTimeout_thenOperationTimeoutException() throws Exception {
long callTimeoutMs = 5000;
Config config = new Config().setProperty(GroupProperty.OPERATION_CALL_TIMEOUT_MILLIS.getName(), "" + callTimeoutMs);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance local = factory.newHazelcastInstance(config);
HazelcastInstance remote = factory.newHazelcastInstance(config);
warmUpPartitions(local, remote);
OperationService opService = getOperationService(local);
Future future = opService.invokeOnPartition(null, new VoidOperation(callTimeoutMs * 5), getPartitionId(remote));
try {
future.get(10 * callTimeoutMs, MILLISECONDS);
fail();
} catch (ExecutionException e) {
Throwable cause = e.getCause();
assertInstanceOf(OperationTimeoutException.class, cause);
assertContains(cause.getMessage(), "operation-heartbeat-timeout");
}
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class Invocation_TimeoutTest method async_whenLongRunningOperation.
@Test
public void async_whenLongRunningOperation() throws InterruptedException, ExecutionException, TimeoutException {
long callTimeout = 5000;
Config config = new Config().setProperty(GroupProperty.OPERATION_CALL_TIMEOUT_MILLIS.getName(), "" + callTimeout);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance local = factory.newHazelcastInstance(config);
HazelcastInstance remote = factory.newHazelcastInstance(config);
warmUpPartitions(local, remote);
OperationService opService = getOperationService(local);
ICompletableFuture<Object> future = opService.invokeOnPartition(null, new SlowOperation(6 * callTimeout, RESPONSE), getPartitionId(remote));
final ExecutionCallback<Object> callback = getExecutionCallbackMock();
future.andThen(callback);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
verify(callback).onResponse(RESPONSE);
}
});
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class SystemOperationPrecedenseTest method testPartitionUnaware.
@Test
public void testPartitionUnaware() {
HazelcastInstance hz = createHazelcastInstance();
OperationService opService = getNode(hz).nodeEngine.getOperationService();
int pendingOperations = 10000;
final CountDownLatch latch = new CountDownLatch(1);
//we are going to fill up the partition first with tons of normal operations with take a lot of time
for (int k = 0; k < pendingOperations; k++) {
opService.execute(new NormalPartitionUnawareOperation());
}
//then we place the system operation
opService.execute(new UrgentPartitionUnawareOperation(latch));
//if the system operation would be given urgency, we should only wait for 1 operation to be processed before
//our system operation is processed.
assertTrueEventually(new AssertTask() {
@Override
public void run() {
assertEquals(0, latch.getCount());
}
});
}
Aggregations