/** * {@inheritDoc CompletionService} * * <p>This future object may not be used as a NotifyingFuture. That is because internally this * class sets the listener to provide ability to add to the queue. */ @Override public Future<V> submit(Callable<V> task) { if (task == null) throw new NullPointerException(); NotifyingFuture<V> f = (NotifyingFuture<V>) executor.submit(task); f.attachListener(listener); return f; }
public void testBasicTargetRemoteDistributedCallable() throws Exception { long taskTimeout = TimeUnit.SECONDS.toMillis(15); EmbeddedCacheManager cacheManager1 = manager(0); final EmbeddedCacheManager cacheManager2 = manager(1); Cache<Object, Object> cache1 = cacheManager1.getCache(); Cache<Object, Object> cache2 = cacheManager2.getCache(); DistributedExecutorService des = null; try { des = new DefaultExecutorService(cache1); Address target = cache2.getAdvancedCache().getRpcManager().getAddress(); DistributedTaskBuilder<Integer> builder = des.createDistributedTaskBuilder(new SimpleCallable()) .failoverPolicy(DefaultExecutorService.RANDOM_NODE_FAILOVER) .timeout(taskTimeout, TimeUnit.MILLISECONDS); Future<Integer> future = des.submit(target, builder.build()); AssertJUnit.assertEquals((Integer) 1, future.get()); } catch (Exception ex) { AssertJUnit.fail("Task did not failover properly " + ex); } finally { des.shutdown(); } }
public <K> Future<V> submit(Callable<V> task, K... input) { NotifyingFuture<V> f = (NotifyingFuture<V>) executor.submit(task, input); f.attachListener(listener); return f; }