Search in sources :

Example 16 with ComputeJob

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());
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) ComputeJob(org.apache.ignite.compute.ComputeJob) VisorClusterGroupEmptyException(org.apache.ignite.internal.visor.util.VisorClusterGroupEmptyException) UUID(java.util.UUID)

Example 17 with ComputeJob

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;
    }
}
Also used : ComputeJob(org.apache.ignite.compute.ComputeJob) IgniteRunnable(org.apache.ignite.lang.IgniteRunnable)

Aggregations

ComputeJob (org.apache.ignite.compute.ComputeJob)17 ClusterNode (org.apache.ignite.cluster.ClusterNode)15 HashMap (java.util.HashMap)7 UUID (java.util.UUID)5 Nullable (org.jetbrains.annotations.Nullable)5 IgniteException (org.apache.ignite.IgniteException)4 Map (java.util.Map)3 ArrayList (java.util.ArrayList)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 ComputeJobAdapter (org.apache.ignite.compute.ComputeJobAdapter)2 ComputeTask (org.apache.ignite.compute.ComputeTask)2 GridifyArgument (org.apache.ignite.compute.gridify.GridifyArgument)2 GridifyJobAdapter (org.apache.ignite.internal.util.gridify.GridifyJobAdapter)2 VisorClusterGroupEmptyException (org.apache.ignite.internal.visor.util.VisorClusterGroupEmptyException)2 Serializable (java.io.Serializable)1 LinkedList (java.util.LinkedList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Ignite (org.apache.ignite.Ignite)1 IgniteFileSystem (org.apache.ignite.IgniteFileSystem)1