Search in sources :

Example 1 with ResultSettingRunnable

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);
}
Also used : ResultSettingRunnable(com.hazelcast.executor.ExecutorServiceTestSupport.ResultSettingRunnable) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ExecutorServiceTestSupport.randomString(com.hazelcast.executor.ExecutorServiceTestSupport.randomString) IExecutorService(com.hazelcast.core.IExecutorService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with ResultSettingRunnable

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);
        }
    });
}
Also used : ResultSettingRunnable(com.hazelcast.executor.ExecutorServiceTestSupport.ResultSettingRunnable) IMap(com.hazelcast.core.IMap) HazelcastInstance(com.hazelcast.core.HazelcastInstance) AssertTask(com.hazelcast.test.AssertTask) ExecutorServiceTestSupport.randomString(com.hazelcast.executor.ExecutorServiceTestSupport.randomString) IExecutorService(com.hazelcast.core.IExecutorService) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExecutionException(java.util.concurrent.ExecutionException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 3 with ResultSettingRunnable

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()));
        }
    });
}
Also used : ResultSettingRunnable(com.hazelcast.executor.ExecutorServiceTestSupport.ResultSettingRunnable) IMap(com.hazelcast.core.IMap) HazelcastInstance(com.hazelcast.core.HazelcastInstance) AssertTask(com.hazelcast.test.AssertTask) ExecutorServiceTestSupport.randomString(com.hazelcast.executor.ExecutorServiceTestSupport.randomString) IExecutorService(com.hazelcast.core.IExecutorService) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExecutionException(java.util.concurrent.ExecutionException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 IExecutorService (com.hazelcast.core.IExecutorService)3 ResultSettingRunnable (com.hazelcast.executor.ExecutorServiceTestSupport.ResultSettingRunnable)3 ExecutorServiceTestSupport.randomString (com.hazelcast.executor.ExecutorServiceTestSupport.randomString)3 ParallelTest (com.hazelcast.test.annotation.ParallelTest)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 Test (org.junit.Test)3 IMap (com.hazelcast.core.IMap)2 AssertTask (com.hazelcast.test.AssertTask)2 ExecutionException (java.util.concurrent.ExecutionException)2 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)2