use of com.hazelcast.client.executor.tasks.MapPutPartitionAwareCallable in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceSubmitTest method submitCallablePartitionAware.
@Test
public void submitCallablePartitionAware() throws Exception {
DurableExecutorService service = client.getDurableExecutorService(randomString());
String mapName = randomString();
IMap map = client.getMap(mapName);
String key = HazelcastTestSupport.generateKeyOwnedBy(server);
Member member = server.getCluster().getLocalMember();
Callable<String> callable = new MapPutPartitionAwareCallable<String, String>(mapName, key);
Future<String> result = service.submit(callable);
assertEquals(member.getUuid(), result.get());
assertTrue(map.containsKey(member.getUuid()));
}
use of com.hazelcast.client.executor.tasks.MapPutPartitionAwareCallable in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitCallablePartitionAware_WithExecutionCallback.
@Test
public void submitCallablePartitionAware_WithExecutionCallback() throws Exception {
IExecutorService service = client.getExecutorService(randomString());
String mapName = randomString();
IMap map = client.getMap(mapName);
String key = HazelcastTestSupport.generateKeyOwnedBy(server);
Member member = server.getCluster().getLocalMember();
Callable<String> runnable = new MapPutPartitionAwareCallable<String, String>(mapName, key);
final AtomicReference<String> result = new AtomicReference<String>();
final CountDownLatch responseLatch = new CountDownLatch(1);
service.submit(runnable, new ExecutionCallback<String>() {
public void onResponse(String response) {
result.set(response);
responseLatch.countDown();
}
public void onFailure(Throwable t) {
}
});
assertOpenEventually("responseLatch", responseLatch);
assertEquals(member.getUuid(), result.get());
assertTrue(map.containsKey(member.getUuid()));
}
use of com.hazelcast.client.executor.tasks.MapPutPartitionAwareCallable in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitCallablePartitionAware.
@Test
public void submitCallablePartitionAware() throws Exception {
IExecutorService service = client.getExecutorService(randomString());
String mapName = randomString();
IMap map = client.getMap(mapName);
String key = HazelcastTestSupport.generateKeyOwnedBy(server);
Member member = server.getCluster().getLocalMember();
Callable<String> callable = new MapPutPartitionAwareCallable<String, String>(mapName, key);
Future<String> result = service.submit(callable);
assertEquals(member.getUuid(), result.get());
assertTrue(map.containsKey(member.getUuid()));
}
use of com.hazelcast.client.executor.tasks.MapPutPartitionAwareCallable in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceSubmitTest method submitCallablePartitionAware_WithExecutionCallback.
@Test
public void submitCallablePartitionAware_WithExecutionCallback() {
DurableExecutorService service = client.getDurableExecutorService(randomString());
String mapName = randomString();
IMap map = client.getMap(mapName);
String key = HazelcastTestSupport.generateKeyOwnedBy(server);
Member member = server.getCluster().getLocalMember();
Callable<String> runnable = new MapPutPartitionAwareCallable<String, String>(mapName, key);
final AtomicReference<String> result = new AtomicReference<String>();
final CountDownLatch responseLatch = new CountDownLatch(1);
service.submit(runnable).andThen(new ExecutionCallback<String>() {
public void onResponse(String response) {
result.set(response);
responseLatch.countDown();
}
public void onFailure(Throwable t) {
}
});
assertOpenEventually("responseLatch", responseLatch);
assertEquals(member.getUuid(), result.get());
assertTrue(map.containsKey(member.getUuid()));
}
Aggregations