use of com.hazelcast.core.IExecutorService 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.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceExecuteTest method testExecuteOnMember.
@Test
public void testExecuteOnMember() {
IExecutorService service = client.getExecutorService(randomString());
String mapName = randomString();
Member member = server1.getCluster().getLocalMember();
final String targetUuid = member.getUuid();
service.executeOnMember(new MapPutRunnable(mapName), member);
final IMap map = client.getMap(mapName);
assertTrueEventually(new AssertTask() {
public void run() throws Exception {
assertTrue(map.containsKey(targetUuid));
}
});
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceExecuteTest method testExecuteOnAllMembers.
@Test
public void testExecuteOnAllMembers() {
IExecutorService service = client.getExecutorService(randomString());
String mapName = randomString();
service.executeOnAllMembers(new MapPutRunnable(mapName));
IMap map = client.getMap(mapName);
assertSizeEventually(CLUSTER_SIZE, map);
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitRunnablePartitionAware_withExecutionCallback.
@Test
public void submitRunnablePartitionAware_withExecutionCallback() throws Exception {
IExecutorService service = client.getExecutorService(randomString());
String mapName = randomString();
String key = HazelcastTestSupport.generateKeyOwnedBy(server);
Member member = server.getCluster().getLocalMember();
Runnable runnable = new MapPutPartitionAwareRunnable<String>(mapName, key);
final CountDownLatch responseLatch = new CountDownLatch(1);
service.submit(runnable, new ExecutionCallback() {
@Override
public void onResponse(Object response) {
responseLatch.countDown();
}
@Override
public void onFailure(Throwable t) {
}
});
IMap map = client.getMap(mapName);
assertOpenEventually("responseLatch", responseLatch);
assertTrue(map.containsKey(member.getUuid()));
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitRunnable_withExecutionCallback.
@Test
public void submitRunnable_withExecutionCallback() {
IExecutorService service = client.getExecutorService(randomString());
final CountDownLatch responseLatch = new CountDownLatch(1);
String mapName = randomString();
Runnable runnable = new MapPutRunnable(mapName);
MemberSelector selector = new SelectAllMembers();
service.submit(runnable, selector, new ExecutionCallback() {
public void onResponse(Object response) {
responseLatch.countDown();
}
public void onFailure(Throwable t) {
}
});
IMap map = client.getMap(mapName);
assertOpenEventually("responseLatch", responseLatch);
assertEquals(1, map.size());
}
Aggregations