Search in sources :

Example 1 with StaleTaskIdException

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

Aggregations

DurableExecutorService (com.hazelcast.durableexecutor.DurableExecutorService)1 StaleTaskIdException (com.hazelcast.durableexecutor.StaleTaskIdException)1 BasicTestCallable (com.hazelcast.executor.ExecutorServiceTestSupport.BasicTestCallable)1 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)1 ParallelTest (com.hazelcast.test.annotation.ParallelTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 ExecutionException (java.util.concurrent.ExecutionException)1 Test (org.junit.Test)1