Search in sources :

Example 6 with SleepingTask

use of com.hazelcast.executor.ExecutorServiceTestSupport.SleepingTask in project hazelcast by hazelcast.

the class ClientDurableRetrieveResultTest method testRetrieve_WhenOwnerMemberDown.

@Test
public void testRetrieve_WhenOwnerMemberDown() throws Exception {
    String name = randomString();
    String key = generateKeyOwnedBy(instance2);
    DurableExecutorService executorService = client.getDurableExecutorService(name);
    SleepingTask task = new SleepingTask(4);
    long taskId = executorService.submitToKeyOwner(task, key).getTaskId();
    instance2.shutdown();
    Future<Boolean> future = executorService.retrieveResult(taskId);
    assertTrue(future.get());
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) SleepingTask(com.hazelcast.executor.ExecutorServiceTestSupport.SleepingTask) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 7 with SleepingTask

use of com.hazelcast.executor.ExecutorServiceTestSupport.SleepingTask in project hazelcast by hazelcast.

the class ClientDurableExecutorServiceTest method test_whenRingBufferIsFull_thenThrowRejectedExecutionException.

@Test
public void test_whenRingBufferIsFull_thenThrowRejectedExecutionException() throws Exception {
    String key = randomString();
    DurableExecutorService service = client.getDurableExecutorService(SINGLE_TASK + randomString());
    service.submitToKeyOwner(new SleepingTask(100), key);
    DurableExecutorServiceFuture<String> future = service.submitToKeyOwner(new BasicTestCallable(), key);
    expectedException.expect(new RootCauseMatcher(RejectedExecutionException.class));
    future.get();
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) SleepingTask(com.hazelcast.executor.ExecutorServiceTestSupport.SleepingTask) BasicTestCallable(com.hazelcast.executor.ExecutorServiceTestSupport.BasicTestCallable) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) RootCauseMatcher(com.hazelcast.util.RootCauseMatcher) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

DurableExecutorService (com.hazelcast.durableexecutor.DurableExecutorService)7 SleepingTask (com.hazelcast.executor.ExecutorServiceTestSupport.SleepingTask)7 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)7 ParallelTest (com.hazelcast.test.annotation.ParallelTest)6 QuickTest (com.hazelcast.test.annotation.QuickTest)6 Test (org.junit.Test)6 BasicTestCallable (com.hazelcast.executor.ExecutorServiceTestSupport.BasicTestCallable)3 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 RootCauseMatcher (com.hazelcast.util.RootCauseMatcher)1 ExecutionException (java.util.concurrent.ExecutionException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1