/** {@inheritDoc} */ @Nullable @Override public <T> T holdcc(long timeout) { return jobCtx == null ? null : jobCtx.<T>holdcc(timeout); } }
/** {@inheritDoc} */ @Nullable @Override public <T> T holdcc() { return jobCtx == null ? null : jobCtx.<T>holdcc(); }
@Override public Object call() throws Exception { if (!held) { ctx.holdcc(1000); held = true; } return null; } }));
@Override public Object call() throws Exception { if (!held) { ctx.holdcc(1000); held = true; } return null; } }));
/** * @param fut Future to listen. * @return {@code true} If future was not completed and this job should holdCC. */ private boolean callAsync(IgniteFuture fut) { if (fut.isDone()) return false; jobCtx.holdcc(); fut.listen(lsnr); return true; }
@Override public Object apply(Integer holdccTimeout) { assert holdccTimeout >= 2000; counter++; if (counter == 1) { new Timer().schedule(new TimerTask() { @Override public void run() { jobCtx.callcc(); } }, 1000); jobCtx.holdcc(holdccTimeout); } if (counter == 2) // Job returned from the suspended state. return null; return null; } }
/** {@inheritDoc} */ @Override public Object execute() throws IgniteException { if (cnt < 1) { cnt++; jobCtx.holdcc(); new Timer().schedule(new TimerTask() { @Override public void run() { jobCtx.callcc(); } }, 500); return "NOT DONE"; } return "DONE"; } }
@Override public Boolean apply(Object param) { counter++; if (counter == 2) return success; jobCtx.holdcc(4000); try { jobCtx.holdcc(); } catch (IllegalStateException ignored) { success = true; log.info("Second holdcc() threw IllegalStateException as expected."); } finally { new Timer().schedule(new TimerTask() { @Override public void run() { jobCtx.callcc(); } }, 1000); } return false; } }
/** {@inheritDoc} */ @Override protected ResultT run(VisorIdleVerifyTaskArg arg) throws IgniteException { if (fut == null) { fut = ignite.compute().executeAsync(taskCls, arg); if (!fut.isDone()) { jobCtx.holdcc(); fut.listen((IgniteInClosure<IgniteFuture<ResultT>>)f -> jobCtx.callcc()); return null; } } return fut.get(); }
/** {@inheritDoc} */ @Override protected VisorIdleVerifyTaskResult run(VisorIdleVerifyTaskArg arg) throws IgniteException { if (fut == null) { fut = ignite.compute().executeAsync(VerifyBackupPartitionsTask.class, arg.getCaches()); if (!fut.isDone()) { jobCtx.holdcc(); fut.listen(new IgniteInClosure<IgniteFuture<Map<PartitionKey, List<PartitionHashRecord>>>>() { @Override public void apply(IgniteFuture<Map<PartitionKey, List<PartitionHashRecord>>> f) { jobCtx.callcc(); } }); return null; } } return new VisorIdleVerifyTaskResult(fut.get()); }
/** {@inheritDoc} */ @Override public Object execute() throws IgniteException { if (future == null) { IgniteCompute compute = ignite.compute().withAsync(); compute.execute(remoteTask, arg); ComputeTaskFuture<R> future = compute.future(); this.future = future; jobCtx.holdcc(); future.listen(new IgniteInClosure<IgniteFuture<R>>() { @Override public void apply(IgniteFuture<R> future) { jobCtx.callcc(); } }); return null; } else { return future.get(); } } }
return jobCtx.holdcc();
/** {@inheritDoc} */ @Override public Map<UUID, Integer> call() throws Exception { IgniteInternalCache<Object, Object> cache = ignite.context().cache().utilityCache(); if (cache == null) { List<ComputeJobContext> pendingCtxs = ((GridServiceProcessor)ignite.context().service()).pendingJobCtxs; synchronized (pendingCtxs) { // Double check cache reference after lock acqusition. cache = ignite.context().cache().utilityCache(); if (cache == null) { if (!waitedCacheInit) { log.debug("Utility cache hasn't been initialized yet. Waiting."); // waiting for a minute for cache initialization. jCtx.holdcc(60 * 1000); pendingCtxs.add(jCtx); waitedCacheInit = true; return null; } else { log.error("Failed to gather service topology. Utility " + "cache initialization is stuck."); throw new IgniteCheckedException("Failed to gather service topology. Utility " + "cache initialization is stuck."); } } } } return serviceTopology(cache, svcName); } }
return jobCtx.holdcc(pollDelay);
/** * Holds (suspends) job execution until our cache version becomes equal to remote cache's version. * * @return {@code True} if topology check passed. */ private boolean waitAffinityReadyFuture() { GridCacheProcessor cacheProc = ((IgniteEx)ignite).context().cache(); AffinityTopologyVersion locTopVer = cacheProc.context().exchange().readyAffinityVersion(); if (locTopVer.compareTo(topVer) < 0) { IgniteInternalFuture<?> fut = cacheProc.context().exchange().affinityReadyFuture(topVer); if (fut != null && !fut.isDone()) { jobCtx.holdcc(); fut.listen(new CI1<IgniteInternalFuture<?>>() { @Override public void apply(IgniteInternalFuture<?> t) { ((IgniteEx)ignite).context().closure().runLocalSafe(new Runnable() { @Override public void run() { jobCtx.callcc(); } }, false); } }); return false; } } return true; } }
return jobCtx.holdcc();
/** {@inheritDoc} */ @Nullable @Override public <T> T holdcc(long timeout) { return jobCtx == null ? null : jobCtx.<T>holdcc(timeout); } }
/** {@inheritDoc} */ @Nullable @Override public <T> T holdcc() { return jobCtx == null ? null : jobCtx.<T>holdcc(); }
/** * @param fut Future to listen. * @return {@code true} If future was not completed and this job should holdCC. */ private boolean callAsync(IgniteFuture fut) { if (fut.isDone()) return false; jobCtx.holdcc(); fut.listen(lsnr); return true; }