Search in sources :

Example 76 with ClusterTopologyCheckedException

use of org.apache.ignite.internal.cluster.ClusterTopologyCheckedException in project ignite by apache.

the class GridTaskWorker method reduce.

/**
 * @param results Job results.
 */
private void reduce(final List<ComputeJobResult> results) {
    R reduceRes = null;
    Throwable userE = null;
    try {
        try {
            // Reduce results.
            reduceRes = U.wrapThreadLoader(dep.classLoader(), new Callable<R>() {

                @Nullable
                @Override
                public R call() {
                    return task.reduce(results);
                }
            });
        } finally {
            synchronized (mux) {
                assert state == State.REDUCING : "Invalid task state: " + state;
                state = State.REDUCED;
            }
        }
        if (log.isDebugEnabled())
            log.debug(S.toString("Reduced job responses", "reduceRes", reduceRes, true, "ses", ses, false));
        recordTaskEvent(EVT_TASK_REDUCED, "Task reduced.");
    } catch (ClusterTopologyCheckedException e) {
        U.warn(log, "Failed to reduce job results for task (any nodes from task topology left grid?): " + task);
        userE = e;
    } catch (IgniteCheckedException e) {
        U.error(log, "Failed to reduce job results for task: " + task, e);
        userE = e;
    }// Catch Throwable to protect against bad user code.
     catch (Throwable e) {
        String errMsg = "Failed to reduce job results due to undeclared user exception [task=" + task + ", err=" + e + ']';
        U.error(log, errMsg, e);
        userE = new ComputeUserUndeclaredException(errMsg, e);
        if (e instanceof Error)
            throw e;
    } finally {
        finishTask(reduceRes, userE);
    }
}
Also used : EVT_JOB_FAILED_OVER(org.apache.ignite.events.EventType.EVT_JOB_FAILED_OVER) TC_NO_FAILOVER(org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_NO_FAILOVER) FAILOVER(org.apache.ignite.compute.ComputeJobResultPolicy.FAILOVER) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) ComputeUserUndeclaredException(org.apache.ignite.compute.ComputeUserUndeclaredException) Callable(java.util.concurrent.Callable) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)

Example 77 with ClusterTopologyCheckedException

use of org.apache.ignite.internal.cluster.ClusterTopologyCheckedException in project ignite by apache.

the class GridNearOptimisticSerializableTxPrepareFuture method prepare.

/**
 * @param fut Mini future.
 * @param txNodes Tx nodes.
 * @param locNearEntriesFut Local future for near cache entries prepare.
 * @return Prepare error if any.
 */
@Nullable
private IgniteCheckedException prepare(final MiniFuture fut, Map<UUID, Collection<UUID>> txNodes, @Nullable MiniFuture locNearEntriesFut) {
    GridDistributedTxMapping m = fut.mapping();
    final ClusterNode primary = m.primary();
    long timeout = tx.remainingTime();
    if (timeout == -1) {
        IgniteCheckedException err = tx.timeoutException();
        fut.onResult(err);
        return err;
    }
    // Must lock near entries separately.
    if (m.hasNearCacheEntries()) {
        try {
            cctx.tm().prepareTx(tx, m.nearCacheEntries());
        } catch (IgniteCheckedException e) {
            fut.onResult(e);
            return e;
        }
    }
    if (primary.isLocal()) {
        if (locNearEntriesFut != null) {
            boolean nearEntries = fut == locNearEntriesFut;
            GridNearTxPrepareRequest req = createRequest(txNodes, fut, timeout, nearEntries ? m.nearEntriesReads() : m.colocatedEntriesReads(), nearEntries ? m.nearEntriesWrites() : m.colocatedEntriesWrites());
            prepareLocal(req, fut, nearEntries);
        } else {
            GridNearTxPrepareRequest req = createRequest(txNodes, fut, timeout, m.reads(), m.writes());
            prepareLocal(req, fut, m.hasNearCacheEntries());
        }
    } else {
        try {
            GridNearTxPrepareRequest req = createRequest(txNodes, fut, timeout, m.reads(), m.writes());
            cctx.io().send(primary, req, tx.ioPolicy());
        } catch (ClusterTopologyCheckedException e) {
            e.retryReadyFuture(cctx.nextAffinityReadyFuture(tx.topologyVersion()));
            fut.onNodeLeft(e);
            return e;
        } catch (IgniteCheckedException e) {
            fut.onResult(e);
            return e;
        }
    }
    return null;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridDistributedTxMapping(org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxMapping) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) Nullable(org.jetbrains.annotations.Nullable)

Example 78 with ClusterTopologyCheckedException

use of org.apache.ignite.internal.cluster.ClusterTopologyCheckedException in project ignite by apache.

the class GridNearOptimisticTxPrepareFuture method onNodeLeft.

/**
 * {@inheritDoc}
 */
@Override
public boolean onNodeLeft(UUID nodeId) {
    boolean found = false;
    for (IgniteInternalFuture<?> fut : futures()) {
        if (isMini(fut)) {
            MiniFuture f = (MiniFuture) fut;
            if (f.node().id().equals(nodeId)) {
                ClusterTopologyCheckedException e = new ClusterTopologyCheckedException("Remote node left grid: " + nodeId);
                e.retryReadyFuture(cctx.nextAffinityReadyFuture(tx.topologyVersion()));
                f.onNodeLeft(e, true);
                found = true;
            }
        }
    }
    return found;
}
Also used : ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)

Example 79 with ClusterTopologyCheckedException

use of org.apache.ignite.internal.cluster.ClusterTopologyCheckedException in project ignite by apache.

the class GridNearPessimisticTxPrepareFuture method onNodeLeft.

/**
 * {@inheritDoc}
 */
@Override
public boolean onNodeLeft(UUID nodeId) {
    boolean found = false;
    for (IgniteInternalFuture<?> fut : futures()) {
        MiniFuture f = (MiniFuture) fut;
        if (f.primary().id().equals(nodeId)) {
            ClusterTopologyCheckedException e = new ClusterTopologyCheckedException("Remote node left grid: " + nodeId);
            e.retryReadyFuture(cctx.nextAffinityReadyFuture(tx.topologyVersion()));
            f.onNodeLeft(e);
            found = true;
        }
    }
    return found;
}
Also used : ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)

Aggregations

ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)79 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)59 ClusterNode (org.apache.ignite.cluster.ClusterNode)49 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)19 UUID (java.util.UUID)17 Map (java.util.Map)16 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)16 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)14 GridCacheEntryRemovedException (org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException)13 HashMap (java.util.HashMap)12 GridCacheVersion (org.apache.ignite.internal.processors.cache.version.GridCacheVersion)12 ArrayList (java.util.ArrayList)11 ClusterTopologyServerNotFoundException (org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException)10 Collection (java.util.Collection)8 IgniteException (org.apache.ignite.IgniteException)8 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)8 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)7 IgniteInterruptedCheckedException (org.apache.ignite.internal.IgniteInterruptedCheckedException)7 Event (org.apache.ignite.events.Event)6 IgniteClientDisconnectedCheckedException (org.apache.ignite.internal.IgniteClientDisconnectedCheckedException)6