Search in sources :

Example 16 with DurableExecutorService

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

the class ClientDurableExecutorServiceTest method testInvokeAll_WithTimeout.

@Test
public void testInvokeAll_WithTimeout() throws Exception {
    DurableExecutorService service = client.getDurableExecutorService(randomString());
    List<BasicTestCallable> callables = Collections.emptyList();
    expectedException.expect(UnsupportedOperationException.class);
    service.invokeAll(callables, 1, TimeUnit.SECONDS);
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) BasicTestCallable(com.hazelcast.executor.ExecutorServiceTestSupport.BasicTestCallable) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 17 with DurableExecutorService

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

the class ClientDurableRetrieveResultTest method testRetrieve_WhenResultOverwritten.

@Test
public void testRetrieve_WhenResultOverwritten() throws Exception {
    String name = randomString();
    DurableExecutorService executorService = client.getDurableExecutorService(name);
    DurableExecutorServiceFuture<String> future = executorService.submitToKeyOwner(new BasicTestCallable(), name);
    long taskId = future.getTaskId();
    future.get();
    for (int i = 0; i < DEFAULT_RING_BUFFER_CAPACITY; i++) {
        executorService.submitToKeyOwner(new BasicTestCallable(), name);
    }
    Future<Object> resultFuture = executorService.retrieveResult(taskId);
    try {
        resultFuture.get();
        fail();
    } catch (ExecutionException e) {
        assertTrue(e.getCause() instanceof StaleTaskIdException);
    }
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) StaleTaskIdException(com.hazelcast.durableexecutor.StaleTaskIdException) BasicTestCallable(com.hazelcast.executor.ExecutorServiceTestSupport.BasicTestCallable) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) ExecutionException(java.util.concurrent.ExecutionException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 18 with DurableExecutorService

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

the class ClientDurableRetrieveResultTest method testDisposeResult.

@Test
public void testDisposeResult() throws Exception {
    String name = randomString();
    String key = generateKeyOwnedBy(instance1);
    DurableExecutorService executorService = client.getDurableExecutorService(name);
    BasicTestCallable task = new BasicTestCallable();
    DurableExecutorServiceFuture<String> future = executorService.submitToKeyOwner(task, key);
    future.get();
    executorService.disposeResult(future.getTaskId());
    Future<Object> resultFuture = executorService.retrieveResult(future.getTaskId());
    assertNull(resultFuture.get());
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) BasicTestCallable(com.hazelcast.executor.ExecutorServiceTestSupport.BasicTestCallable) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 19 with DurableExecutorService

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

the class ClientDurableExecutorServiceTest method testShutdownMultipleTimes.

@Test
public void testShutdownMultipleTimes() {
    final DurableExecutorService service = client.getDurableExecutorService(randomString());
    service.shutdownNow();
    service.shutdown();
    assertTrueEventually(new AssertTask() {

        public void run() throws Exception {
            assertTrue(service.isShutdown());
        }
    });
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) AssertTask(com.hazelcast.test.AssertTask) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExpectedException(org.junit.rules.ExpectedException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 20 with DurableExecutorService

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

the class ClientDurableExecutorServiceTest method testShutdownNow.

@Test
public void testShutdownNow() {
    final DurableExecutorService service = client.getDurableExecutorService(randomString());
    service.shutdownNow();
    assertTrueEventually(new AssertTask() {

        public void run() throws Exception {
            assertTrue(service.isShutdown());
        }
    });
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) AssertTask(com.hazelcast.test.AssertTask) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExpectedException(org.junit.rules.ExpectedException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) 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