use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ExecutorServiceTest method test_registerCallback_beforeFutureIsCompletedOnOtherNode.
@Test
public void test_registerCallback_beforeFutureIsCompletedOnOtherNode() throws Exception {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance instance1 = factory.newHazelcastInstance();
HazelcastInstance instance2 = factory.newHazelcastInstance();
assertTrue(instance1.getCountDownLatch("latch").trySetCount(1));
String name = randomString();
IExecutorService executorService = instance2.getExecutorService(name);
ICountDownLatchAwaitCallable task = new ICountDownLatchAwaitCallable("latch");
String key = generateKeyOwnedBy(instance1);
ICompletableFuture<Boolean> future = (ICompletableFuture<Boolean>) executorService.submitToKeyOwner(task, key);
CountingDownExecutionCallback<Boolean> callback = new CountingDownExecutionCallback<Boolean>(1);
future.andThen(callback);
instance1.getCountDownLatch("latch").countDown();
assertTrue(future.get());
assertOpenEventually(callback.getLatch());
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ExecutorServiceCancelTest method testGetValueAfterCancel_submitToMember.
private void testGetValueAfterCancel_submitToMember(HazelcastInstance instance, Member member) throws Exception {
IExecutorService executorService = instance.getExecutorService(randomString());
Future<Boolean> future = executorService.submitToMember(new SleepingTask(Integer.MAX_VALUE, taskStartedLatchName), member);
awaitTaskStart();
future.cancel(true);
future.get(10, TimeUnit.SECONDS);
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ExecutorServiceCancelTest method testCancel_submitToKeyOwner.
@Test
public void testCancel_submitToKeyOwner() throws ExecutionException, InterruptedException {
IExecutorService executorService = localHz.getExecutorService(randomString());
Future<Boolean> future = executorService.submitToKeyOwner(new SleepingTask(Integer.MAX_VALUE, taskStartedLatchName), randomString());
awaitTaskStart();
boolean cancelled = future.cancel(true);
assertTrue(cancelled);
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ExecutorServiceCancelTest method testGetValueAfterCancel_submitToKeyOwner.
@Test(expected = CancellationException.class)
public void testGetValueAfterCancel_submitToKeyOwner() throws Exception {
IExecutorService executorService = localHz.getExecutorService(randomString());
Future<Boolean> future = executorService.submitToKeyOwner(new SleepingTask(Integer.MAX_VALUE, taskStartedLatchName), randomString());
awaitTaskStart();
future.cancel(true);
future.get(10, TimeUnit.SECONDS);
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ClientRegressionWithMockNetworkTest method testGithubIssue3557.
@Test(expected = ExecutionException.class, timeout = 120000)
public void testGithubIssue3557() throws Exception {
HazelcastInstance hz = hazelcastFactory.newHazelcastInstance();
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
UnDeserializable unDeserializable = new UnDeserializable(1);
IExecutorService executorService = client.getExecutorService("default");
Issue2509Runnable task = new Issue2509Runnable(unDeserializable);
Future<?> future = executorService.submitToMember(task, hz.getCluster().getLocalMember());
future.get();
}
Aggregations