use of com.hazelcast.client.test.executor.tasks.CancellationAwareTask in project hazelcast by hazelcast.
the class ClientExecutorServiceCancelTest method testCancel_submitRandom.
private void testCancel_submitRandom(boolean smartRouting) throws ExecutionException, InterruptedException, IOException {
HazelcastInstance client = createClient(smartRouting);
IExecutorService executorService = client.getExecutorService(randomString());
Future<Boolean> future = executorService.submit(new CancellationAwareTask(SLEEP_TIME));
boolean cancelled = future.cancel(true);
assertTrue(cancelled);
future.get();
}
use of com.hazelcast.client.test.executor.tasks.CancellationAwareTask in project hazelcast by hazelcast.
the class ClientExecutorServiceCancelTest method testCancel_submitToMember.
private void testCancel_submitToMember(boolean smartRouting, HazelcastInstance server, boolean waitTaskStart) throws ExecutionException, InterruptedException, IOException {
HazelcastInstance client = createClient(smartRouting);
IExecutorService executorService = client.getExecutorService(randomString());
Future<Boolean> future = executorService.submitToMember(new CancellationAwareTask(SLEEP_TIME), server.getCluster().getLocalMember());
if (waitTaskStart) {
awaitTaskStartAtMember(server, 1);
}
boolean cancelled = future.cancel(true);
assertTrue(cancelled);
awaitTaskCancelAtMember(server, 1);
future.get();
}
use of com.hazelcast.client.test.executor.tasks.CancellationAwareTask in project hazelcast by hazelcast.
the class ClientExecutorServiceTest method testCancelFutureAfterCancellationAwareTaskTimeOut.
@Test
@Ignore("https://github.com/hazelcast/hazelcast/issues/4677")
public // Ignored because fixing it requires extensive refactoring see ClientExecutorServiceCancelTest
void testCancelFutureAfterCancellationAwareTaskTimeOut() throws InterruptedException, ExecutionException {
IExecutorService service = client.getExecutorService(randomString());
CancellationAwareTask task = new CancellationAwareTask(Long.MAX_VALUE);
Future future = service.submit(task);
try {
future.get(1, TimeUnit.SECONDS);
} catch (TimeoutException ignored) {
}
assertTrue(future.cancel(true));
assertTrue(future.isCancelled());
assertTrue(future.isDone());
}
use of com.hazelcast.client.test.executor.tasks.CancellationAwareTask in project hazelcast by hazelcast.
the class ClientExecutorServiceTest method testFutureAfterCancellationAwareTaskTimeOut.
@Test
public void testFutureAfterCancellationAwareTaskTimeOut() throws InterruptedException, ExecutionException {
IExecutorService service = client.getExecutorService(randomString());
CancellationAwareTask task = new CancellationAwareTask(Long.MAX_VALUE);
Future future = service.submit(task);
try {
future.get(1, TimeUnit.SECONDS);
} catch (TimeoutException ignored) {
}
assertFalse(future.isDone());
assertFalse(future.isCancelled());
}
Aggregations