use of org.apache.ignite.compute.ComputeJob in project ignite by apache.
the class VisorQueryCleanupTask method map0.
/** {@inheritDoc} */
@Override
protected Map<? extends ComputeJob, ClusterNode> map0(List<ClusterNode> subgrid, @Nullable VisorTaskArgument<VisorQueryCleanupTaskArg> arg) {
Set<UUID> nodeIds = taskArg.getQueryIds().keySet();
if (nodeIds.isEmpty())
throw new VisorClusterGroupEmptyException("Nothing to clear. List with node IDs is empty!");
Map<ComputeJob, ClusterNode> map = U.newHashMap(nodeIds.size());
try {
for (ClusterNode node : subgrid) if (nodeIds.contains(node.id()))
map.put(new VisorQueryCleanupJob(taskArg.getQueryIds().get(node.id()), debug), node);
if (map.isEmpty()) {
StringBuilder notFoundNodes = new StringBuilder();
for (UUID nid : nodeIds) notFoundNodes.append((notFoundNodes.length() == 0) ? "" : ",").append(U.id8(nid));
throw new VisorClusterGroupEmptyException("Failed to clear query results. Nodes are not available: [" + notFoundNodes + "]");
}
return map;
} finally {
if (debug)
logMapped(ignite.log(), getClass(), map.values());
}
}
use of org.apache.ignite.compute.ComputeJob in project ignite by apache.
the class GridJobWorker method cancel.
/**
* @param sys System flag.
*/
public void cancel(boolean sys) {
try {
super.cancel();
final ComputeJob job0 = job;
if (sys)
sysCancelled = true;
if (job0 != null) {
if (log.isDebugEnabled())
log.debug("Cancelling job: " + ses);
U.wrapThreadLoader(dep.classLoader(), new IgniteRunnable() {
@Override
public void run() {
job0.cancel();
}
});
}
if (!internal && ctx.event().isRecordable(EVT_JOB_CANCELLED))
recordEvent(EVT_JOB_CANCELLED, "Job was cancelled: " + job0);
}// Catch throwable to protect against bad user code.
catch (Throwable e) {
U.error(log, "Failed to cancel job due to undeclared user exception [jobId=" + ses.getJobId() + ", ses=" + ses + ']', e);
if (e instanceof Error)
throw e;
}
}
Aggregations