@Override public IgniteFuture<?> applyx(ClusterGroup prj) { return compute(prj).broadcastAsync(new TestCallable()); } });
@Override public IgniteFuture<?> applyx(ClusterGroup prj) { return compute(prj).broadcastAsync(new TestClosure(), "arg"); } });
@Override public IgniteFuture<?> applyx(ClusterGroup prj) { return compute(prj).broadcastAsync(new TestRunnable()); } });
/** * Starts the background cleanup of old cache entries. * * @param grid Grid. * @param metaCache Meta cache. * @param dataCacheName Data cache name. * @param currentVersions Current versions. */ private void startBackgroundCleanup(Ignite grid, final Cache<CleanupNodeId, UUID> metaCache, final String dataCacheName, final Map<String, EntryProcessorResult<Long>> currentVersions) { if (cleanupFlags.containsKey(dataCacheName)) return; // Current node already performs cleanup. if (!trySetGlobalCleanupFlag(grid, metaCache)) return; cleanupFlags.put(dataCacheName, true); final ClusterGroup dataNodes = grid.cluster().forDataNodes(dataCacheName); IgniteFuture f = grid.compute(dataNodes).broadcastAsync( new RemoveOldEntriesRunnable(dataCacheName, currentVersions)); f.listen(new CleanupCompletionListener(metaCache, dataCacheName)); }
/** * @param idx Node index. * @param job Runnable job. * @param p Optional node predicate. * @return Future object. */ private IgniteFuture<?> broadcast(int idx, IgniteRunnable job, @Nullable IgnitePredicate<ClusterNode> p) { assert idx >= 0 && idx < NODES_CNT; assert job != null; execCntr.set(0); ClusterGroup prj = grid(idx).cluster(); if (p != null) prj = prj.forPredicate(p); return compute(prj).broadcastAsync(job); }
@Override public void test(Factory factory, Ignite ignite) throws Exception { IgniteRunnable job = (IgniteRunnable)factory.create(); IgniteFuture<Void> fut = ignite.compute().broadcastAsync(job); fut.get(); // All checks are inside the run() method of the job. } });
@Override public void test(Factory factory, Ignite ignite) throws Exception { final Collection<Object> resultsAllNull = ignite.compute() .broadcast((IgniteClosure<Object, Object>)factory.create(), null); assertEquals("Result's size mismatch: job must be run on all server nodes", gridCount() - clientsCount(), resultsAllNull.size()); for (Object o : resultsAllNull) assertNull("All results must be null", o); IgniteFuture<Collection<Object>> fut = ignite.compute() .broadcastAsync((IgniteClosure<Object, Object>)factory.create(), value(0)); checkResultsClassCount(gridCount() - clientsCount(), fut.get(), value(0).getClass()); } });
@Override public void test(Factory factory, Ignite ignite) throws Exception { EchoCallable job = (EchoCallable)factory.create(); job.setArg(null); final IgniteFuture<Collection<Object>> futAllNull = ignite.compute() .broadcastAsync(job); assertEquals("Result's size mismatch: job must be run on all server nodes", gridCount() - clientsCount(), futAllNull.get().size()); for (Object o : futAllNull.get()) assertNull("All results must be null", o); job.setArg(value(0)); IgniteFuture<Collection<Object>> futNotNull = ignite.compute() .broadcastAsync(job); checkResultsClassCount(gridCount() - clientsCount(), futNotNull.get(), value(0).getClass()); for (Object o : futNotNull.get()) assertEquals("Invalid broadcast results", value(0), o); } });
/** * @param idx Node index. * @param job Callable job. * @param p Optional node predicate. * @return Future object. */ private IgniteFuture<Collection<Integer>> broadcast(int idx, IgniteCallable<Integer> job, @Nullable IgnitePredicate<ClusterNode> p) { assert idx >= 0 && idx < NODES_CNT; assert job != null; execCntr.set(0); IgniteCompute comp = p != null ? compute(grid(idx).cluster().forPredicate(p)) : grid(idx).compute(); return comp.broadcastAsync(job); }
/** * @param cnt Counter. * @throws Exception If failed. */ private void run1(AtomicInteger cnt) throws Exception { IgniteFuture<Void> fut = compute(prj).broadcastAsync(runJob); waitForExecution(fut); cnt.set(0); compute(prj).broadcast(runJob); waitForValue(cnt, projectionSize()); }
/** * @param cnt Counter. * @throws Exception If failed. */ private void call1(AtomicInteger cnt) throws Exception { IgniteFuture<Collection<String>> fut = compute(prj).broadcastAsync(calJob); waitForExecution(fut); cnt.set(0); compute(prj).broadcast(calJob); waitForValue(cnt, projectionSize()); }
/** * @param cnt Counter. * @throws Exception If failed. */ private void call5(AtomicInteger cnt) throws Exception { IgniteFuture<Collection<String>> fut = compute(prj).broadcastAsync(new TestClosure(), "arg"); waitForExecution(fut); cnt.set(0); Collection<String> res = compute(prj).broadcast(new TestClosure(), "arg"); assertEquals(projectionSize(), res.size()); waitForValue(cnt, projectionSize()); for (String resStr : res) assertEquals("arg", resStr); }
/** * @throws Exception If failed. */ @Test public void testAsync() throws Exception { ClusterGroup empty = ignite(0).cluster().forNodeId(UUID.randomUUID()); assertEquals(0, empty.nodes().size()); IgniteCompute comp = ignite(0).compute(empty); checkFutureFails(comp.affinityRunAsync(DEFAULT_CACHE_NAME, 1, new FailRunnable())); checkFutureFails(comp.applyAsync(new FailClosure(), new Object())); checkFutureFails(comp.affinityCallAsync(DEFAULT_CACHE_NAME, 1, new FailCallable())); checkFutureFails(comp.broadcastAsync(new FailCallable())); }
.broadcastAsync( new IgniteRunnable() { @Override public void run() {
/** * Starts the background cleanup of old cache entries. * * @param grid Grid. * @param metaCache Meta cache. * @param dataCacheName Data cache name. * @param currentVersions Current versions. */ private void startBackgroundCleanup(Ignite grid, final Cache<CleanupNodeId, UUID> metaCache, final String dataCacheName, final Map<String, EntryProcessorResult<Long>> currentVersions) { if (cleanupFlags.containsKey(dataCacheName)) return; // Current node already performs cleanup. if (!trySetGlobalCleanupFlag(grid, metaCache)) return; cleanupFlags.put(dataCacheName, true); final ClusterGroup dataNodes = grid.cluster().forDataNodes(dataCacheName); IgniteFuture f = grid.compute(dataNodes).broadcastAsync( new RemoveOldEntriesRunnable(dataCacheName, currentVersions)); f.listen(new CleanupCompletionListener(metaCache, dataCacheName)); }