@Override public IgniteFuture<?> applyx(ClusterGroup prj) { return compute(prj).runAsync(new TestRunnable()); } });
@Override public IgniteFuture<?> applyx(ClusterGroup prj) { return compute(prj).runAsync(Arrays.asList(new TestRunnable(), new TestRunnable())); } });
@Override public Object call() throws Exception { while (!stop.get()) { int idx = rnd.nextInt(GRID_CNT); try { grid(idx).compute().runAsync(F.noop()).get(3000); } catch (IgniteException ignored) { // Ignore all job execution related errors. } } return null; } }, 1, "job-runner");
@Override public void test(Factory factory, Ignite ignite) throws Exception { IgniteRunnable job = (IgniteRunnable)factory.create(); IgniteFuture<Void> fut0 = ignite.compute().runAsync(job); fut0.get(); // All checks are inside the run() method of the job. Collection<IgniteRunnable> jobs = new ArrayList<>(MAX_JOB_COUNT); for (int i = 0; i < MAX_JOB_COUNT; ++i) jobs.add((IgniteRunnable)factory.create()); IgniteFuture<Void> fut1 = ignite.compute().runAsync(jobs); fut1.get(); // All checks are inside the run() method of the job. } });
/** * @param cnt Counter. * @throws Exception If failed. */ private void run2(AtomicInteger cnt) throws Exception { Collection<IgniteRunnable> jobs = F.asList(runJob); IgniteFuture<Void> fut = compute(prj).runAsync(jobs); waitForExecution(fut); cnt.set(0); compute(prj).run(jobs); waitForValue(cnt, jobs.size()); }
/** * @param idx Node index. * @param job Runnable job. * @param p Optional node predicate. * @return Future object. */ private IgniteFuture<?> runAsync(int idx, IgniteRunnable 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.runAsync(job); }
/** * @param idx Node index. * @param jobs Runnable jobs. * @param p Optional node predicate. * @return Future object. */ private IgniteFuture<?> runAsync(int idx, Collection<ClosureTestRunnable> jobs, @Nullable IgnitePredicate<ClusterNode> p) { assert idx >= 0 && idx < NODES_CNT; assert !F.isEmpty(jobs); execCntr.set(0); IgniteCompute comp = p != null ? compute(grid(idx).cluster().forPredicate(p)) : grid(idx).compute(); return comp.runAsync(jobs); }
proxy.remoteCompute().runAsync(new StopGridTask(igniteInstanceName, cancel));
/** * @throws Exception If fails. */ @Test public void testRuntimeException() throws Exception { Ignite ignite = grid(0); ignite.compute().runAsync(new IgniteRunnable() { @Override public void run() { try { Thread.sleep(500); } catch (InterruptedException ignored) { // No-op. } } }).listen(new IgniteInClosure<IgniteFuture<Void>>() { @Override public void apply(IgniteFuture<Void> future) { throw new RuntimeException(); } }); } }
/** * @throws Exception If failed. */ @Test public void testNoTimeout() throws Exception { Ignite ignite = ignite(0); IgniteFuture fut = null; for (int i = 0; i < 10000; i++) { fut = ignite.compute().runAsync(new IgniteRunnable() { @Override public void run() { } }); } fut.get(); assertTrue(true); } }
IgniteFuture<Void> fut = comp.runAsync(new ClientChangeGlobalStateComputeRequest(activate, blt, forceBlt));
IgniteFuture<?> fut = comp.runAsync(putJob);
futs.add(client.compute().runAsync(new IgniteRunnable() { @IgniteInstanceResource private transient Ignite ignite;
@Override public void run() { final Streamer<Serializable> streamer = ObjectContainer.<StreamingJob<Serializable>>get(jobMeta.getId()).streamer(); final int concurrency = igniteRemote.cluster().nodes().size() * jobMeta.getThreads(); LOGGER.info("Cluster concurrency : {}", concurrency); final Semaphore cycle = new Semaphore(concurrency); final List<IgniteFuture> futures = new ArrayList<>(); final IgniteCompute igniteCompute = igniteRemote.compute(select(ignite)).withExecutor(jobMeta.getId()); while (streamer.hasNext()) { // execute final Serializable next = streamer.next(); try { cycle.acquire(); final IgniteFuture<Void> igniteFuture = igniteCompute .runAsync(() -> { ObjectContainer.<StreamingJob<Serializable>>get(jobMeta.getId()).executor().execute(next); }); futures.add(igniteFuture); igniteFuture.listen((future) -> { cycle.release(); }); } catch (InterruptedException e) { } } futures.forEach(IgniteFuture::get); } });
IgniteFuture<Void> fut = comp.runAsync(new ClientChangeGlobalStateComputeRequest(activate, blt, forceBlt));