use of com.hazelcast.client.executor.tasks.MapPutPartitionAwareRunnable 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).thenRun(() -> responseLatch.countDown());
IMap map = client.getMap(mapName);
assertOpenEventually("responseLatch", responseLatch);
assertTrue(map.containsKey(member.getUuid()));
}
use of com.hazelcast.client.executor.tasks.MapPutPartitionAwareRunnable in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitRunnablePartitionAware_withExecutionCallback.
@Test
public void submitRunnablePartitionAware_withExecutionCallback() {
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.client.executor.tasks.MapPutPartitionAwareRunnable in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitRunnablePartitionAware.
@Test
public void submitRunnablePartitionAware() {
IExecutorService service = client.getExecutorService(randomString());
String mapName = randomString();
String key = HazelcastTestSupport.generateKeyOwnedBy(server);
final Member member = server.getCluster().getLocalMember();
// this task should execute on a node owning the given key argument,
// the action is to put the UUid of the executing node into a map with the given name
Runnable runnable = new MapPutPartitionAwareRunnable<String>(mapName, key);
service.submit(runnable);
final IMap map = client.getMap(mapName);
assertTrueEventually(new AssertTask() {
public void run() {
assertTrue(map.containsKey(member.getUuid()));
}
});
}
use of com.hazelcast.client.executor.tasks.MapPutPartitionAwareRunnable in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitRunnablePartitionAware_withResult.
@Test
public void submitRunnablePartitionAware_withResult() throws Exception {
IExecutorService service = client.getExecutorService(randomString());
String expectedResult = "result";
String mapName = randomString();
String key = HazelcastTestSupport.generateKeyOwnedBy(server);
final Member member = server.getCluster().getLocalMember();
Runnable runnable = new MapPutPartitionAwareRunnable<String>(mapName, key);
Future result = service.submit(runnable, expectedResult);
final IMap map = client.getMap(mapName);
assertEquals(expectedResult, result.get());
assertTrueEventually(new AssertTask() {
public void run() {
assertTrue(map.containsKey(member.getUuid()));
}
});
}
use of com.hazelcast.client.executor.tasks.MapPutPartitionAwareRunnable in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceSubmitTest method submitRunnablePartitionAware_withResult.
@Test
public void submitRunnablePartitionAware_withResult() throws Exception {
DurableExecutorService service = client.getDurableExecutorService(randomString());
String expectedResult = "result";
String mapName = randomString();
String key = HazelcastTestSupport.generateKeyOwnedBy(server);
final Member member = server.getCluster().getLocalMember();
Runnable runnable = new MapPutPartitionAwareRunnable<String>(mapName, key);
Future result = service.submit(runnable, expectedResult);
final IMap map = client.getMap(mapName);
assertEquals(expectedResult, result.get());
assertTrueEventually(new AssertTask() {
public void run() {
assertTrue(map.containsKey(member.getUuid()));
}
});
}
Aggregations