/** {@inheritDoc} */ @Override public void callcc() { if (jobCtx != null) jobCtx.callcc(); }
/** * Gets job priority from task context. If job has no priority default one will be used. * * @param ctx Job context. * @return Job priority. */ private int getJobPriority(GridComputeJobContext ctx) { assert ctx != null; Integer p; try { p = ctx.getAttribute(STEALING_PRIORITY_ATTR); } catch (ClassCastException e) { U.error(log, "Type of job context priority attribute '" + STEALING_PRIORITY_ATTR + "' is not java.lang.Integer (will use default priority) [type=" + ctx.getAttribute(STEALING_PRIORITY_ATTR).getClass() + ", dfltPriority=" + DFLT_JOB_PRIORITY + ']', e); p = DFLT_JOB_PRIORITY; } if (p == null) p = DFLT_JOB_PRIORITY; return p; }
/** {@inheritDoc} */ @Override public boolean heldcc() { return jobCtx != null && jobCtx.heldcc(); }
Integer stealingCnt = waitCtx.getJobContext().getAttribute(STEALING_ATTEMPT_COUNT_ATTR); break; Integer pri = waitCtx.getJobContext().getAttribute(STEALING_PRIORITY_ATTR); boolean cancel = waitCtx.getJobContext().getAttribute(THIEF_NODE_ATTR) == null; waitCtx.getJobContext().setAttribute(THIEF_NODE_ATTR, nodeId); waitCtx.getJobContext().setAttribute(STEALING_ATTEMPT_COUNT_ATTR, stealingCnt + 1); waitCtx.getJobContext().setAttribute(STEALING_PRIORITY_ATTR, pri + 1); log.debug("Failed to reject job [i=" + i + ']'); waitCtx.getJobContext().setAttribute(THIEF_NODE_ATTR, null); waitCtx.getJobContext().setAttribute(STEALING_ATTEMPT_COUNT_ATTR, stealingCnt); waitCtx.getJobContext().setAttribute(STEALING_PRIORITY_ATTR, pri);
ctx.job().cancelJob(ses.getId(), res.getJobContext().getJobId(), /*courtesy*/true); else { try { ctx.io().send(node, TOPIC_JOB_CANCEL, new GridJobCancelRequest(ses.getId(), res.getJobContext().getJobId(), /*courtesy*/true), PUBLIC_POOL); U.error(log, "Failed to send cancel request to node (will ignore) [nodeId=" + nodeId + ", taskName=" + ses.getTaskName() + ", taskSesId=" + ses.getId() + ", jobSesId=" + res.getJobContext().getJobId() + ']', e);
U.warn(log, "Failed to send job request because remote node left grid (if fail-over is enabled, " + "will attempt fail-over to another node) [node=" + node + ", taskName=" + ses.getTaskName() + ", taskSesId=" + ses.getId() + ", jobSesId=" + res.getJobContext().getJobId() + ']'); res.getJobContext().getJobId(), null, null, null, null, null, null, false); (Map<? extends Serializable, ? extends Serializable>)res.getJobContext().getAttributes(); new GridJobExecuteRequest( ses.getId(), res.getJobContext().getJobId(), ses.getTaskName(), ses.getUserVersion(), U.warn(log, "Failed to send job request because remote node left grid (if failover is enabled, " + "will attempt fail-over to another node) [node=" + node + ", taskName=" + ses.getTaskName() + ", taskSesId=" + ses.getId() + ", jobSesId=" + res.getJobContext().getJobId() + ']'); else U.error(log, "Failed to send job request: " + req, e); res.getJobContext().getJobId(), null, null, null, null, null, null, false);
/** {@inheritDoc} */ @Nullable @Override public <T> T holdcc(long timeout) { return jobCtx == null ? null : jobCtx.<T>holdcc(timeout); } }
/** * Increases priority if job has bumped down. * * @param jobs Ordered collection of collision contexts for jobs that are currently waiting * for execution. */ private void bumpPriority(List<GridCollisionJobContextWrapper> jobs) { int starvationInc = this.starvationInc; for (int i = 0; i < jobs.size(); i++) { GridCollisionJobContextWrapper wrapper = jobs.get(i); if (i > wrapper.originalIndex()) wrapper.getContext().getJobContext() .setAttribute(jobPriAttrKey, getJobPriority(wrapper.getContext()) + starvationInc); } }
Collection<UUID> failedNodes = ctx.getJobResult().getJobContext().getAttribute(FAILED_NODE_LIST_ATTR); else { ctx.getJobResult().getJobContext().setAttribute(FAILED_NODE_LIST_ATTR, failedNodes);
/** {@inheritDoc} */ @Nullable @Override public <T> T holdcc() { return jobCtx == null ? null : jobCtx.<T>holdcc(); }
Integer failoverCnt = ctx.getJobResult().getJobContext().getAttribute(FAILOVER_ATTEMPT_COUNT_ATTR); boolean isNodeFailed = false; UUID thiefId = ctx.getJobResult().getJobContext().getAttribute(THIEF_NODE_ATTR); ctx.getJobResult().getJobContext().setAttribute(THIEF_NODE_ATTR, null); Collection<UUID> failedNodes = ctx.getJobResult().getJobContext().getAttribute(FAILED_NODE_LIST_ATTR); ctx.getJobResult().getJobContext().setAttribute(FAILED_NODE_LIST_ATTR, failedNodes); ctx.getJobResult().getJobContext().setAttribute(FAILOVER_ATTEMPT_COUNT_ATTR, failoverCnt);
jr.getJobContext().getJobId(), null, null, null, null, null, null, false);
p = (Integer)jctx.getAttribute(jobPriAttrKey); "' is not java.lang.Integer [type=" + jctx.getAttribute(jobPriAttrKey).getClass() + ']');
/** * @param jobRes Job result. */ private void sendFailoverRequest(GridJobResultImpl jobRes) { // Internal failover notification. evtLsnr.onJobFailover(this, jobRes.getSibling(), jobRes.getNode().id()); long timeout = ses.getEndTime() - U.currentTimeMillis(); if (timeout > 0) { recordJobEvent(EVT_JOB_FAILED_OVER, jobRes.getJobContext().getJobId(), jobRes.getNode(), "Job failed over."); // Send new reference to remote nodes for execution. sendRequest(jobRes); } else // Don't apply 'finishTask(..)' here as it will // be called from 'onTimeout(..)' callback. U.warn(log, "Failed to fail-over job due to task timeout: " + jobRes); }
recordJobEvent(EVT_JOB_RESULTED, jobRes.getJobContext().getJobId(), jobRes.getNode(), "Job got resulted with: " + plc);