Search in sources :

Example 6 with IgniteClientDisconnectedCheckedException

use of org.apache.ignite.internal.IgniteClientDisconnectedCheckedException in project ignite by apache.

the class DataStreamerImpl method onDisconnected.

/**
     * @param reconnectFut Reconnect future.
     * @throws IgniteCheckedException If failed.
     */
public void onDisconnected(IgniteFuture<?> reconnectFut) throws IgniteCheckedException {
    IgniteClientDisconnectedCheckedException err = new IgniteClientDisconnectedCheckedException(reconnectFut, "Data streamer has been closed, client node disconnected.");
    disconnectErr = (CacheException) CU.convertToCacheException(err);
    for (Buffer buf : bufMappings.values()) buf.cancelAll(err);
    closeEx(true, err);
}
Also used : IgniteClientDisconnectedCheckedException(org.apache.ignite.internal.IgniteClientDisconnectedCheckedException)

Example 7 with IgniteClientDisconnectedCheckedException

use of org.apache.ignite.internal.IgniteClientDisconnectedCheckedException in project ignite by apache.

the class GridTaskWorker method sendRequest.

/**
     * @param res Job result.
     */
private void sendRequest(ComputeJobResult res) {
    assert res != null;
    GridJobExecuteRequest req = null;
    ClusterNode node = res.getNode();
    try {
        ClusterNode curNode = ctx.discovery().node(node.id());
        // thrown in case of send failure.
        if (curNode == null) {
            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() + ']');
            ctx.resource().invokeAnnotated(dep, res.getJob(), ComputeJobAfterSend.class);
            GridJobExecuteResponse fakeRes = new GridJobExecuteResponse(node.id(), ses.getId(), res.getJobContext().getJobId(), null, null, null, null, null, null, false, null);
            fakeRes.setFakeException(new ClusterTopologyException("Failed to send job due to node failure: " + node));
            onResponse(fakeRes);
        } else {
            long timeout = ses.getEndTime() == Long.MAX_VALUE ? Long.MAX_VALUE : ses.getEndTime() - U.currentTimeMillis();
            if (timeout > 0) {
                boolean loc = node.id().equals(ctx.discovery().localNode().id()) && !ctx.config().isMarshalLocalJobs();
                Map<Object, Object> sesAttrs = ses.isFullSupport() ? ses.getAttributes() : null;
                Map<? extends Serializable, ? extends Serializable> jobAttrs = (Map<? extends Serializable, ? extends Serializable>) res.getJobContext().getAttributes();
                boolean forceLocDep = internal || !ctx.deploy().enabled();
                req = new GridJobExecuteRequest(ses.getId(), res.getJobContext().getJobId(), ses.getTaskName(), ses.getUserVersion(), ses.getTaskClassName(), loc ? null : U.marshal(marsh, res.getJob()), loc ? res.getJob() : null, ses.getStartTime(), timeout, ses.getTopology(), loc ? null : U.marshal(marsh, ses.getJobSiblings()), loc ? ses.getJobSiblings() : null, loc ? null : U.marshal(marsh, sesAttrs), loc ? sesAttrs : null, loc ? null : U.marshal(marsh, jobAttrs), loc ? jobAttrs : null, ses.getCheckpointSpi(), dep.classLoaderId(), dep.deployMode(), continuous, dep.participants(), forceLocDep, ses.isFullSupport(), internal, subjId, affCacheIds, affPartId, mapTopVer, ses.executorName());
                if (loc)
                    ctx.job().processJobExecuteRequest(ctx.discovery().localNode(), req);
                else {
                    byte plc;
                    if (internal)
                        plc = MANAGEMENT_POOL;
                    else {
                        Byte ctxPlc = getThreadContext(TC_IO_POLICY);
                        if (ctxPlc != null)
                            plc = ctxPlc;
                        else
                            plc = PUBLIC_POOL;
                    }
                    // Send job execution request.
                    ctx.io().sendToGridTopic(node, TOPIC_JOB, req, plc);
                    if (log.isDebugEnabled())
                        log.debug("Sent job request [req=" + req + ", node=" + node + ']');
                }
                if (!loc)
                    ctx.resource().invokeAnnotated(dep, res.getJob(), ComputeJobAfterSend.class);
            } else
                U.warn(log, "Job timed out prior to sending job execution request: " + res.getJob());
        }
    } catch (IgniteCheckedException e) {
        IgniteException fakeErr = null;
        try {
            boolean deadNode = isDeadNode(res.getNode().id());
            // Avoid stack trace if node has left grid.
            if (deadNode) {
                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() + ']');
                fakeErr = new ClusterTopologyException("Failed to send job due to node failure: " + node, e);
            } else
                U.error(log, "Failed to send job request: " + req, e);
        } catch (IgniteClientDisconnectedCheckedException e0) {
            if (log.isDebugEnabled())
                log.debug("Failed to send job request, client disconnected [node=" + node + ", taskName=" + ses.getTaskName() + ", taskSesId=" + ses.getId() + ", jobSesId=" + res.getJobContext().getJobId() + ']');
            fakeErr = U.convertException(e0);
        }
        GridJobExecuteResponse fakeRes = new GridJobExecuteResponse(node.id(), ses.getId(), res.getJobContext().getJobId(), null, null, null, null, null, null, false, null);
        if (fakeErr == null)
            fakeErr = U.convertException(e);
        fakeRes.setFakeException(fakeErr);
        onResponse(fakeRes);
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) Serializable(java.io.Serializable) GridJobExecuteRequest(org.apache.ignite.internal.GridJobExecuteRequest) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridJobExecuteResponse(org.apache.ignite.internal.GridJobExecuteResponse) ComputeJobAfterSend(org.apache.ignite.compute.ComputeJobAfterSend) IgniteException(org.apache.ignite.IgniteException) IgniteClientDisconnectedCheckedException(org.apache.ignite.internal.IgniteClientDisconnectedCheckedException) ClusterTopologyException(org.apache.ignite.cluster.ClusterTopologyException) GridTimeoutObject(org.apache.ignite.internal.processors.timeout.GridTimeoutObject) Map(java.util.Map) HashMap(java.util.HashMap)

Example 8 with IgniteClientDisconnectedCheckedException

use of org.apache.ignite.internal.IgniteClientDisconnectedCheckedException in project ignite by apache.

the class GridServiceProcessor method onDisconnected.

/** {@inheritDoc} */
@Override
public void onDisconnected(IgniteFuture<?> reconnectFut) throws IgniteCheckedException {
    cancelFutures(depFuts, new IgniteClientDisconnectedCheckedException(ctx.cluster().clientReconnectFuture(), "Failed to deploy service, client node disconnected."));
    cancelFutures(undepFuts, new IgniteClientDisconnectedCheckedException(ctx.cluster().clientReconnectFuture(), "Failed to undeploy service, client node disconnected."));
}
Also used : IgniteClientDisconnectedCheckedException(org.apache.ignite.internal.IgniteClientDisconnectedCheckedException)

Example 9 with IgniteClientDisconnectedCheckedException

use of org.apache.ignite.internal.IgniteClientDisconnectedCheckedException in project ignite by apache.

the class IgniteUtils method convertException.

/**
     * @param e Ignite checked exception.
     * @return Ignite runtime exception.
     */
public static IgniteException convertException(IgniteCheckedException e) {
    IgniteClientDisconnectedException e0 = e.getCause(IgniteClientDisconnectedException.class);
    if (e0 != null) {
        assert e0.reconnectFuture() != null : e0;
        throw e0;
    }
    IgniteClientDisconnectedCheckedException disconnectedErr = e.getCause(IgniteClientDisconnectedCheckedException.class);
    if (disconnectedErr != null) {
        assert disconnectedErr.reconnectFuture() != null : disconnectedErr;
        e = disconnectedErr;
    }
    C1<IgniteCheckedException, IgniteException> converter = exceptionConverters.get(e.getClass());
    if (converter != null)
        return converter.apply(e);
    if (e.getCause() instanceof IgniteException)
        return (IgniteException) e.getCause();
    return new IgniteException(e.getMessage(), e);
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) IgniteClientDisconnectedCheckedException(org.apache.ignite.internal.IgniteClientDisconnectedCheckedException)

Example 10 with IgniteClientDisconnectedCheckedException

use of org.apache.ignite.internal.IgniteClientDisconnectedCheckedException in project ignite by apache.

the class TcpCommunicationSpi method onClientDisconnected.

/** {@inheritDoc} */
@Override
public void onClientDisconnected(IgniteFuture<?> reconnectFut) {
    connectGate.disconnected(reconnectFut);
    for (GridCommunicationClient[] clients0 : clients.values()) {
        for (GridCommunicationClient client : clients0) {
            if (client != null)
                client.forceClose();
        }
    }
    IgniteClientDisconnectedCheckedException err = new IgniteClientDisconnectedCheckedException(reconnectFut, "Failed to connect client node disconnected.");
    for (GridFutureAdapter<GridCommunicationClient> clientFut : clientFuts.values()) clientFut.onDone(err);
    recoveryDescs.clear();
    inRecDescs.clear();
    outRecDescs.clear();
}
Also used : IgniteClientDisconnectedCheckedException(org.apache.ignite.internal.IgniteClientDisconnectedCheckedException) GridCommunicationClient(org.apache.ignite.internal.util.nio.GridCommunicationClient)

Aggregations

IgniteClientDisconnectedCheckedException (org.apache.ignite.internal.IgniteClientDisconnectedCheckedException)19 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)10 IgniteException (org.apache.ignite.IgniteException)7 HashMap (java.util.HashMap)4 Map (java.util.Map)4 ConcurrentMap (java.util.concurrent.ConcurrentMap)3 ClusterTopologyException (org.apache.ignite.cluster.ClusterTopologyException)3 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)3 IgniteInterruptedCheckedException (org.apache.ignite.internal.IgniteInterruptedCheckedException)3 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)3 ArrayList (java.util.ArrayList)2 UUID (java.util.UUID)2 CacheException (javax.cache.CacheException)2 JMException (javax.management.JMException)2 IgniteClientDisconnectedException (org.apache.ignite.IgniteClientDisconnectedException)2 IgniteDataStreamerTimeoutException (org.apache.ignite.IgniteDataStreamerTimeoutException)2 IgniteInterruptedException (org.apache.ignite.IgniteInterruptedException)2 CacheExistsException (org.apache.ignite.cache.CacheExistsException)2 ClusterNode (org.apache.ignite.cluster.ClusterNode)2 IgniteFutureTimeoutCheckedException (org.apache.ignite.internal.IgniteFutureTimeoutCheckedException)2