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);
}
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);
}
}
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."));
}
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);
}
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();
}
Aggregations