Search in sources :

Example 26 with DurableExecutorService

use of com.hazelcast.durableexecutor.DurableExecutorService in project hazelcast by hazelcast.

the class ClientDurableExecutorServiceTest method testIsTerminated.

@Test
public void testIsTerminated() {
    DurableExecutorService service = client.getDurableExecutorService(randomString());
    assertFalse(service.isTerminated());
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 27 with DurableExecutorService

use of com.hazelcast.durableexecutor.DurableExecutorService in project hazelcast by hazelcast.

the class ClientDurableRetrieveResultTest method testRetrieve_WhenSubmitterMemberDown.

@Test
public void testRetrieve_WhenSubmitterMemberDown() throws Exception {
    String name = randomString();
    DurableExecutorService executorService = client.getDurableExecutorService(name);
    SleepingTask task = new SleepingTask(4);
    long taskId = executorService.submit(task).getTaskId();
    client.shutdown();
    client = hazelcastFactory.newHazelcastClient();
    executorService = client.getDurableExecutorService(name);
    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 28 with DurableExecutorService

use of com.hazelcast.durableexecutor.DurableExecutorService in project hazelcast by hazelcast.

the class ClientDurableRetrieveResultTest method testRetrieveAndDispose_WhenOwnerMemberDown.

@Test
public void testRetrieveAndDispose_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.retrieveAndDisposeResult(taskId);
    assertTrue(future.get());
    Future<Boolean> resultFuture = executorService.retrieveResult(taskId);
    assertNull(resultFuture.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 29 with DurableExecutorService

use of com.hazelcast.durableexecutor.DurableExecutorService in project hazelcast by hazelcast.

the class ClientDurableRetrieveResultTest method testRetrieveAndDispose_WhenClientDown.

@Test
public void testRetrieveAndDispose_WhenClientDown() throws Exception {
    String name = randomString();
    DurableExecutorService executorService = client.getDurableExecutorService(name);
    SleepingTask task = new SleepingTask(4);
    long taskId = executorService.submit(task).getTaskId();
    client.shutdown();
    client = hazelcastFactory.newHazelcastClient();
    executorService = client.getDurableExecutorService(name);
    Future<Boolean> future = executorService.retrieveAndDisposeResult(taskId);
    assertTrue(future.get());
    Future<Object> resultFuture = executorService.retrieveResult(taskId);
    assertNull(resultFuture.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 30 with DurableExecutorService

use of com.hazelcast.durableexecutor.DurableExecutorService 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)

Aggregations

DurableExecutorService (com.hazelcast.durableexecutor.DurableExecutorService)41 ParallelTest (com.hazelcast.test.annotation.ParallelTest)39 QuickTest (com.hazelcast.test.annotation.QuickTest)39 Test (org.junit.Test)39 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)28 IMap (com.hazelcast.core.IMap)11 MapPutRunnable (com.hazelcast.client.executor.tasks.MapPutRunnable)10 BasicTestCallable (com.hazelcast.executor.ExecutorServiceTestSupport.BasicTestCallable)9 CountDownLatch (java.util.concurrent.CountDownLatch)9 SleepingTask (com.hazelcast.executor.ExecutorServiceTestSupport.SleepingTask)7 MapPutPartitionAwareRunnable (com.hazelcast.client.executor.tasks.MapPutPartitionAwareRunnable)6 Member (com.hazelcast.core.Member)6 AppendCallable (com.hazelcast.client.executor.tasks.AppendCallable)5 AssertTask (com.hazelcast.test.AssertTask)5 Future (java.util.concurrent.Future)5 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)5 MapPutPartitionAwareCallable (com.hazelcast.client.executor.tasks.MapPutPartitionAwareCallable)4 ExecutionException (java.util.concurrent.ExecutionException)4 FailingCallable (com.hazelcast.client.executor.tasks.FailingCallable)3 ExecutionCallback (com.hazelcast.core.ExecutionCallback)3