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