use of com.hazelcast.core.ExecutionCallback in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceSubmitTest method testSubmitRunnable_withExecutionCallback.
@Test
public void testSubmitRunnable_withExecutionCallback() {
DurableExecutorService service = client.getDurableExecutorService(randomString());
String mapName = randomString();
Runnable runnable = new MapPutRunnable(mapName);
final CountDownLatch responseLatch = new CountDownLatch(1);
service.submit(runnable).andThen(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());
}
use of com.hazelcast.core.ExecutionCallback in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceSubmitTest method submitRunnableToKeyOwner.
@Test
public void submitRunnableToKeyOwner() {
DurableExecutorService service = client.getDurableExecutorService(randomString());
String mapName = randomString();
Runnable runnable = new MapPutRunnable(mapName);
final CountDownLatch responseLatch = new CountDownLatch(1);
service.submitToKeyOwner(runnable, "key").andThen(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());
}
use of com.hazelcast.core.ExecutionCallback in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceSubmitTest method submitRunnablePartitionAware_withExecutionCallback.
@Test
public void submitRunnablePartitionAware_withExecutionCallback() {
DurableExecutorService service = client.getDurableExecutorService(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).andThen(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.ExecutionCallback in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method testSubmitRunnable_withExecutionCallback.
@Test
public void testSubmitRunnable_withExecutionCallback() throws Exception {
IExecutorService service = client.getExecutorService(randomString());
String mapName = randomString();
Runnable runnable = new MapPutRunnable(mapName);
final CountDownLatch responseLatch = new CountDownLatch(1);
service.submit(runnable, 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());
}
use of com.hazelcast.core.ExecutionCallback 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()));
}
Aggregations