use of com.hazelcast.executor.ExecutorServiceTestSupport.ResultSettingRunnable 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.executor.ExecutorServiceTestSupport.ResultSettingRunnable 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.executor.ExecutorServiceTestSupport.ResultSettingRunnable in project hazelcast by hazelcast.
the class ExecutorServiceLiteMemberTest method test_executeRunnable_onAllLiteMembers.
@Test
public void test_executeRunnable_onAllLiteMembers() {
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.executeOnMembers(new ResultSettingRunnable(name), LITE_MEMBER_SELECTOR);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
final IMap<Object, Object> results = lite1.getMap(name);
assertEquals(2, results.size());
assertTrue(results.containsKey(lite1.getCluster().getLocalMember()));
assertTrue(results.containsKey(lite2.getCluster().getLocalMember()));
}
});
}
Aggregations