use of com.hazelcast.client.executor.tasks.CancellationAwareTask in project hazelcast by hazelcast.
the class ClientExecutorServiceCancelTest method testCancel_submitToKeyOwner.
private void testCancel_submitToKeyOwner(boolean smartRouting) throws ExecutionException, InterruptedException {
HazelcastInstance client = createClient(smartRouting);
IExecutorService executorService = client.getExecutorService(randomString());
Future<Boolean> future = executorService.submitToKeyOwner(new CancellationAwareTask(SLEEP_TIME), randomString());
boolean cancelled = future.cancel(true);
assertTrue(cancelled);
future.get();
}
use of com.hazelcast.client.executor.tasks.CancellationAwareTask in project hazelcast by hazelcast.
the class ClientExecutorServiceTest method testGetFutureAfterCancel.
@Test(expected = CancellationException.class)
public void testGetFutureAfterCancel() throws InterruptedException, ExecutionException, TimeoutException {
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) {
}
future.cancel(true);
future.get();
}
use of com.hazelcast.client.executor.tasks.CancellationAwareTask in project hazelcast by hazelcast.
the class ClientExecutorServiceTest method testCancellationAwareTask_whenTimeOut.
@Test(expected = TimeoutException.class)
public void testCancellationAwareTask_whenTimeOut() throws InterruptedException, ExecutionException, TimeoutException {
IExecutorService service = client.getExecutorService(randomString());
CancellationAwareTask task = new CancellationAwareTask(Long.MAX_VALUE);
Future future = service.submit(task);
future.get(1, TimeUnit.SECONDS);
}
use of com.hazelcast.client.executor.tasks.CancellationAwareTask in project hazelcast by hazelcast.
the class ClientExecutorServiceCancelTest method testCancel_submitToMember.
private void testCancel_submitToMember(boolean smartRouting, Member member) throws ExecutionException, InterruptedException {
HazelcastInstance client = createClient(smartRouting);
IExecutorService executorService = client.getExecutorService(randomString());
Future<Boolean> future = executorService.submitToMember(new CancellationAwareTask(SLEEP_TIME), member);
boolean cancelled = future.cancel(true);
assertTrue(cancelled);
future.get();
}
use of com.hazelcast.client.executor.tasks.CancellationAwareTask in project hazelcast by hazelcast.
the class ClientExecutorServiceCancelTest method testCancel_submitRandom.
private void testCancel_submitRandom(boolean smartRouting) throws ExecutionException, InterruptedException {
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();
}
Aggregations