use of org.apache.ignite.internal.cluster.ClusterTopologyCheckedException in project ignite by apache.
the class InitNewCoordinatorFuture method init.
/**
* @param exchFut Current future.
* @throws IgniteCheckedException If failed.
*/
public void init(GridDhtPartitionsExchangeFuture exchFut) throws IgniteCheckedException {
initTopVer = exchFut.initialVersion();
GridCacheSharedContext cctx = exchFut.sharedContext();
restoreState = exchangeProtocolVersion(exchFut.context().events().discoveryCache().minimumNodeVersion()) > 1;
boolean newAff = exchFut.localJoinExchange();
IgniteInternalFuture<?> fut = cctx.affinity().initCoordinatorCaches(exchFut, newAff);
if (fut != null)
add(fut);
if (restoreState) {
DiscoCache curDiscoCache = cctx.discovery().discoCache();
DiscoCache discoCache = exchFut.events().discoveryCache();
List<ClusterNode> nodes = new ArrayList<>();
synchronized (this) {
for (ClusterNode node : discoCache.allNodes()) {
if (!node.isLocal() && cctx.discovery().alive(node)) {
awaited.add(node.id());
nodes.add(node);
} else if (!node.isLocal()) {
if (log.isInfoEnabled())
log.info("Init new coordinator future will skip remote node: " + node);
}
}
if (exchFut.context().mergeExchanges() && !curDiscoCache.version().equals(discoCache.version())) {
for (ClusterNode node : curDiscoCache.allNodes()) {
if (discoCache.node(node.id()) == null) {
if (exchangeProtocolVersion(node.version()) == 1)
break;
awaited.add(node.id());
nodes.add(node);
if (joinedNodes == null)
joinedNodes = new HashMap<>();
GridDhtPartitionExchangeId exchId = new GridDhtPartitionExchangeId(node.id(), EVT_NODE_JOINED, new AffinityTopologyVersion(node.order()));
joinedNodes.put(node.id(), exchId);
}
}
}
if (joinedNodes == null)
joinedNodes = Collections.emptyMap();
if (!awaited.isEmpty()) {
restoreStateFut = new GridFutureAdapter();
add(restoreStateFut);
}
}
if (log.isInfoEnabled()) {
log.info("Try restore exchange result [awaited=" + awaited + ", joined=" + joinedNodes.keySet() + ", nodes=" + U.nodeIds(nodes) + ", discoAllNodes=" + U.nodeIds(discoCache.allNodes()) + ']');
}
if (!nodes.isEmpty()) {
GridDhtPartitionsSingleRequest req = GridDhtPartitionsSingleRequest.restoreStateRequest(exchFut.exchangeId(), exchFut.exchangeId());
for (ClusterNode node : nodes) {
try {
GridDhtPartitionsSingleRequest sndReq = req;
if (joinedNodes.containsKey(node.id())) {
sndReq = GridDhtPartitionsSingleRequest.restoreStateRequest(joinedNodes.get(node.id()), exchFut.exchangeId());
}
cctx.io().send(node, sndReq, GridIoPolicy.SYSTEM_POOL);
} catch (ClusterTopologyCheckedException e) {
if (log.isDebugEnabled())
log.debug("Failed to send partitions request, node failed: " + node);
onNodeLeft(node.id());
}
}
}
}
markInitialized();
}
use of org.apache.ignite.internal.cluster.ClusterTopologyCheckedException in project ignite by apache.
the class MvccProcessorImpl method onCoordinatorFailed.
/**
*/
private void onCoordinatorFailed(UUID nodeId) {
// 1. Notify all listeners waiting for a snapshot.
Map<Long, MvccSnapshotResponseListener> map = snapLsnrs.remove(nodeId);
if (map != null) {
ClusterTopologyCheckedException ex = new ClusterTopologyCheckedException("Failed to request mvcc " + "version, coordinator left: " + nodeId);
MvccSnapshotResponseListener lsnr;
for (Long id : map.keySet()) {
if ((lsnr = map.remove(id)) != null)
lsnr.onError(ex);
}
}
// 2. Notify acknowledge futures.
for (WaitAckFuture fut : ackFuts.values()) fut.onNodeLeft(nodeId);
}
use of org.apache.ignite.internal.cluster.ClusterTopologyCheckedException in project ignite by apache.
the class MvccProcessorImpl method ackTxRollback.
/**
* {@inheritDoc}
*/
@Override
public void ackTxRollback(MvccVersion updateVer) {
assert updateVer != null;
MvccCoordinator crd = curCrd;
if (crd.disconnected() || crd.version() != updateVer.coordinatorVersion())
return;
MvccAckRequestTx msg = new MvccAckRequestTx((long) -1, updateVer.counter());
msg.skipResponse(true);
try {
sendMessage(crd.nodeId(), msg);
} catch (ClusterTopologyCheckedException e) {
if (log.isDebugEnabled())
log.debug("Failed to send tx rollback ack, node left [msg=" + msg + ", node=" + crd.nodeId() + ']');
} catch (IgniteCheckedException e) {
U.error(log, "Failed to send tx rollback ack [msg=" + msg + ", node=" + crd.nodeId() + ']', e);
}
}
use of org.apache.ignite.internal.cluster.ClusterTopologyCheckedException in project ignite by apache.
the class IgniteSnapshotManager method processLocalSnapshotStartStageResult.
/**
* @param id Request id.
* @param res Results.
* @param err Errors.
*/
private void processLocalSnapshotStartStageResult(UUID id, Map<UUID, SnapshotOperationResponse> res, Map<UUID, Exception> err) {
if (cctx.kernalContext().clientNode())
return;
SnapshotOperationRequest snpReq = clusterSnpReq;
boolean cancelled = err.values().stream().anyMatch(e -> e instanceof IgniteFutureCancelledCheckedException);
if (snpReq == null || !snpReq.requestId().equals(id)) {
synchronized (snpOpMux) {
if (clusterSnpFut != null && clusterSnpFut.rqId.equals(id)) {
if (cancelled) {
clusterSnpFut.onDone(new IgniteFutureCancelledCheckedException("Execution of snapshot tasks " + "has been cancelled by external process [err=" + err + ", snpReq=" + snpReq + ']'));
} else {
clusterSnpFut.onDone(new IgniteCheckedException("Snapshot operation has not been fully completed " + "[err=" + err + ", snpReq=" + snpReq + ']'));
}
clusterSnpFut = null;
}
return;
}
}
snpReq.startStageEnded(true);
if (isLocalNodeCoordinator(cctx.discovery())) {
Set<UUID> missed = new HashSet<>(snpReq.nodes());
missed.removeAll(res.keySet());
missed.removeAll(err.keySet());
if (cancelled) {
snpReq.error(new IgniteFutureCancelledCheckedException("Execution of snapshot tasks " + "has been cancelled by external process [err=" + err + ", missed=" + missed + ']'));
} else if (!missed.isEmpty()) {
snpReq.error(new ClusterTopologyCheckedException("Snapshot operation interrupted, because baseline " + "node left the cluster. Uncompleted snapshot will be deleted [missed=" + missed + ']'));
} else if (!F.isEmpty(err)) {
snpReq.error(new IgniteCheckedException("Execution of local snapshot tasks fails. " + "Uncompleted snapshot will be deleted [err=" + err + ']'));
}
completeHandlersAsyncIfNeeded(snpReq, res.values()).listen(f -> {
if (f.error() != null)
snpReq.error(f.error());
endSnpProc.start(snpReq.requestId(), snpReq);
});
}
}
use of org.apache.ignite.internal.cluster.ClusterTopologyCheckedException in project ignite by apache.
the class IgniteTxHandler method sendReply.
/**
* Sends tx finish response to remote node, if response is requested.
*
* @param nodeId Node id that originated finish request.
* @param req Request.
* @param committed {@code True} if transaction committed on this node.
* @param nearTxId Near tx version.
*/
private void sendReply(UUID nodeId, GridDhtTxFinishRequest req, boolean committed, GridCacheVersion nearTxId) {
if (req.replyRequired() || req.checkCommitted()) {
GridDhtTxFinishResponse res = new GridDhtTxFinishResponse(req.partition(), req.version(), req.futureId(), req.miniId());
if (req.checkCommitted()) {
res.checkCommitted(true);
if (committed) {
if (req.needReturnValue()) {
try {
GridCacheReturnCompletableWrapper wrapper = ctx.tm().getCommittedTxReturn(req.version());
if (wrapper != null)
res.returnValue(wrapper.fut().get());
else
assert !ctx.discovery().alive(nodeId) : nodeId;
} catch (IgniteCheckedException ignored) {
if (txFinishMsgLog.isDebugEnabled()) {
txFinishMsgLog.debug("Failed to gain entry processor return value. [txId=" + nearTxId + ", dhtTxId=" + req.version() + ", node=" + nodeId + ']');
}
}
}
} else {
ClusterTopologyCheckedException cause = new ClusterTopologyCheckedException("Primary node left grid.");
res.checkCommittedError(new IgniteTxRollbackCheckedException("Failed to commit transaction " + "(transaction has been rolled back on backup node): " + req.version(), cause));
}
}
try {
ctx.io().send(nodeId, res, req.policy());
if (txFinishMsgLog.isDebugEnabled()) {
txFinishMsgLog.debug("Sent dht tx finish response [txId=" + nearTxId + ", dhtTxId=" + req.version() + ", node=" + nodeId + ", checkCommitted=" + req.checkCommitted() + ']');
}
} catch (Throwable e) {
// Double-check.
if (ctx.discovery().node(nodeId) == null) {
if (txFinishMsgLog.isDebugEnabled()) {
txFinishMsgLog.debug("Node left while send dht tx finish response [txId=" + nearTxId + ", dhtTxId=" + req.version() + ", node=" + nodeId + ']');
}
} else {
U.error(log, "Failed to send finish response to node [txId=" + nearTxId + ", dhtTxId=" + req.version() + ", nodeId=" + nodeId + ", res=" + res + ']', e);
}
if (e instanceof Error)
throw (Error) e;
}
} else {
if (txFinishMsgLog.isDebugEnabled()) {
txFinishMsgLog.debug("Skip send dht tx finish response [txId=" + nearTxId + ", dhtTxId=" + req.version() + ", node=" + nodeId + ']');
}
}
}
Aggregations