@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder builder = getDefaultClusteredCacheConfig(getCacheMode(), false); createClusteredCaches(2, cacheName(), builder); }
@Override public Address failover(FailoverContext fc) { return randomNode(fc.executionCandidates(), fc.executionFailureLocation()); }
public void testDistributedExecutorWithManagedExecutorService() throws ExecutionException, InterruptedException { ExecutorService service = new ManagedExecutorServicesEmulator(); customExecutorServiceDistributedExecutorTest(service, false); }
public void testBasicPollInvocationWithSleepingCallable() throws Exception { DistributedExecutorService des = new DefaultExecutorService(c1); DistributedExecutionCompletionService<Integer> decs = new DistributedExecutionCompletionService<>(des); try { decs.submit(new SimpleCallable(true, 5000)); CompletableFuture<Integer> callable = decs.poll(); AssertJUnit.assertNull(callable); } finally { des.shutdownNow(); } }
public void testBasicInvocationWithRunnable() throws Exception { DistributedExecutorService des = new DefaultExecutorService(c1); try { DistributedExecutionCompletionService<Integer> decs = new DistributedExecutionCompletionService<>(des); Integer result = 5; decs.submit(new SimpleRunnable(), result); CompletableFuture<Integer> future = decs.take(); Integer r = future.get(); AssertJUnit.assertEquals(result, r); } finally { des.shutdownNow(); } }
public void testBasicInvocationWithNullRunnable() throws Exception { DistributedExecutorService des = new DefaultExecutorService(c1); try { DistributedExecutionCompletionService<Integer> decs = new DistributedExecutionCompletionService<>(des); Integer result = 5; expectException(NullPointerException.class, () -> decs.submit(null, result)); } finally { des.shutdownNow(); } }
public void testBasicDistributedCallable() throws Exception { DistributedExecutorService des = createDES(getCache()); Future<Boolean> future = des.submit(new SimpleDistributedCallable(false)); Boolean r = future.get(); assert r; // the same using DistributedTask API DistributedTaskBuilder<Boolean> taskBuilder = des .createDistributedTaskBuilder(new SimpleDistributedCallable(false)); DistributedTask<Boolean> distributedTask = taskBuilder.build(); future = des.submit(distributedTask); r = future.get(); assert r; }
public void testBasicTargetDistributedCallableWithNullExecutionPolicy() throws Exception { Cache<Object, Object> cache1 = getCache(); //initiate task from cache1 and select cache2 as target DistributedExecutorService des = createDES(cache1); //the same using DistributedTask API DistributedTaskBuilder<Boolean> taskBuilder = des.createDistributedTaskBuilder(new SimpleDistributedCallable(false)); expectException(IllegalArgumentException.class, () -> taskBuilder.executionPolicy(null)); }
public void testBasicDistributedCallableEverywhereWithKeysAndNullTask() throws Exception { DistributedExecutorService des = createDES(getCache()); DistributedTask task = null; expectException(NullPointerException.class, () -> des.submitEverywhere(task, "key1", "key2")); }
public void testRunnableExecutionOnTerminatedExecutor() { DistributedExecutorService des = createDES(getCache()); des.shutdown(); BoringRunnable runnable = new BoringRunnable(); expectException(RejectedExecutionException.class, () -> des.execute(runnable)); }
public void testBasicTargetCallableWithNullTarget() { Cache<Object, Object> cache1 = getCache(); DistributedExecutorService des = createDES(cache1); expectException(NullPointerException.class, () -> des.submit((Address) null, new SimpleCallable())); }
public void testRunnableInvocation() throws Exception { DistributedExecutorService des = createDES(getCache()); Future<?> future = des.submit(new BoringRunnable()); Object object = future.get(); assertEquals(null, object); }
public void testBasicDistributedCallableWithNullKeys() throws Exception { Cache<Object, Object> c1 = getCache(); c1.put("key1", "value1"); c1.put("key2", "value2"); c1.put("key3", "value3"); c1.put("key4", "value4"); DistributedExecutorService des = createDES(getCache()); des.submit(new SimpleDistributedCallable(false)); }
public void testBasicInvocation() throws Exception { basicInvocation(new SimpleCallable()); }
@Override public Address failover(FailoverContext context) { return context.executionFailureLocation(); }
public void testBasicPollInvocationWithTimeout() throws Exception { DistributedExecutorService des = new DefaultExecutorService(c1); DistributedExecutionCompletionService<Integer> decs = new DistributedExecutionCompletionService<>(des); try { decs.submit(new SimpleCallable(true,5000)); CompletableFuture<Integer> callable = decs.poll(10, TimeUnit.MILLISECONDS); AssertJUnit.assertNull(callable); } finally { des.shutdownNow(); } }
public void testBasicInvocationWithNullTask() throws Exception { DistributedExecutorService des = new DefaultExecutorService(c1); try { DistributedExecutionCompletionService<Integer> decs = new DistributedExecutionCompletionService<>(des); expectException(NullPointerException.class, () -> decs.submit(null)); } finally { des.shutdownNow(); } }
public void testBasicDistributedCallableEverywhereWithNullTask() throws Exception { DistributedExecutorService des = createDES(getCache()); DistributedTask task = null; expectException(NullPointerException.class, () -> des.submitEverywhere(task)); }
public void testBasicPollInvocation() throws Exception { DistributedExecutorService des = new DefaultExecutorService(c1); DistributedExecutionCompletionService<Integer> decs = new DistributedExecutionCompletionService<>(des); try { decs.submit(new SimpleCallable()); CompletableFuture<Integer> callable = decs.poll(1000, TimeUnit.MILLISECONDS); AssertJUnit.assertEquals((Integer) 1, callable.get()); } finally { des.shutdownNow(); } }