use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitCallableToMember_withMultiExecutionCallback.
@Test
public void submitCallableToMember_withMultiExecutionCallback() throws Exception {
IExecutorService service = client.getExecutorService(randomString());
final CountDownLatch responseLatch = new CountDownLatch(CLUSTER_SIZE);
final CountDownLatch completeLatch = new CountDownLatch(CLUSTER_SIZE);
final String msg = randomString();
Callable<String> callable = new AppendCallable(msg);
Collection<Member> collection = server.getCluster().getMembers();
service.submitToMembers(callable, collection, new MultiExecutionCallback() {
public void onResponse(Member member, Object value) {
if (value.equals(msg + AppendCallable.APPENDAGE)) {
responseLatch.countDown();
}
}
public void onComplete(Map<Member, Object> values) {
for (Member member : values.keySet()) {
Object value = values.get(member);
if (value.equals(msg + AppendCallable.APPENDAGE)) {
completeLatch.countDown();
}
}
}
});
assertOpenEventually("responseLatch", responseLatch);
assertOpenEventually("completeLatch", completeLatch);
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ExecutorServiceLiteMemberTest method test_executeRunnable_failsWhenNoLiteMemberExists.
@Test(expected = RejectedExecutionException.class)
public void test_executeRunnable_failsWhenNoLiteMemberExists() {
factory.newHazelcastInstance();
final HazelcastInstance client = factory.newHazelcastClient();
final String name = randomString();
final IExecutorService executor = client.getExecutorService(name);
executor.execute(new ResultSettingRunnable(name), LITE_MEMBER_SELECTOR);
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ExecutorServiceLiteMemberTest method test_executeRunnable_onLiteMember.
@Test
public void test_executeRunnable_onLiteMember() {
final HazelcastInstance lite1 = factory.newHazelcastInstance(liteConfig);
final HazelcastInstance lite2 = factory.newHazelcastInstance(liteConfig);
factory.newHazelcastInstance();
final HazelcastInstance client = factory.newHazelcastClient();
final String name = randomString();
final IExecutorService executor = client.getExecutorService(name);
executor.execute(new ResultSettingRunnable(name), LITE_MEMBER_SELECTOR);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
final IMap<Object, Object> results = lite1.getMap(name);
assertEquals(1, results.size());
final boolean executedOnLite1 = results.containsKey(lite1.getCluster().getLocalMember());
final boolean executedOnLite2 = results.containsKey(lite2.getCluster().getLocalMember());
assertTrue(executedOnLite1 || executedOnLite2);
}
});
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ExecutorServiceLiteMemberTest method test_submitCallable_onLiteMembers.
@Test
public void test_submitCallable_onLiteMembers() throws ExecutionException, InterruptedException {
final HazelcastInstance lite1 = factory.newHazelcastInstance(liteConfig);
final HazelcastInstance lite2 = factory.newHazelcastInstance(liteConfig);
factory.newHazelcastInstance();
final HazelcastInstance client = factory.newHazelcastClient();
final IExecutorService executor = client.getExecutorService(randomString());
final Map<Member, Future<Member>> results = executor.submitToMembers(new LocalMemberReturningCallable(), LITE_MEMBER_SELECTOR);
assertEquals(2, results.size());
final Member liteMember1 = lite1.getCluster().getLocalMember();
final Member liteMember2 = lite2.getCluster().getLocalMember();
assertEquals(liteMember1, results.get(liteMember1).get());
assertEquals(liteMember2, results.get(liteMember2).get());
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class Invocation_RegressionTest method testIssue2509.
@Test(expected = ExecutionException.class, timeout = 120000)
public void testIssue2509() throws Exception {
TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(2);
HazelcastInstance h1 = nodeFactory.newHazelcastInstance();
HazelcastInstance h2 = nodeFactory.newHazelcastInstance();
UnDeserializable unDeserializable = new UnDeserializable(1);
IExecutorService executorService = h1.getExecutorService("default");
Issue2509Runnable task = new Issue2509Runnable(unDeserializable);
Future<?> future = executorService.submitToMember(task, h2.getCluster().getLocalMember());
future.get();
}
Aggregations