/** @param m Mapping. */ private void finish(GridDistributedTxMapping m) { ClusterNode n = m.node(); assert !m.empty(); GridNearTxFinishRequest req = new GridNearTxFinishRequest( futId, tx.xidVersion(), tx.threadId(), commit, tx.isInvalidate(), tx.system(), tx.ioPolicy(), tx.syncCommit(), tx.syncRollback(), m.explicitLock(), tx.storeEnabled(), tx.topologyVersion(), null, null, null, tx.size(), tx.subjectId(), tx.taskNameHash(), tx.activeCachesDeploymentEnabled()); // If this is the primary node for the keys. if (n.isLocal()) { req.miniId(IgniteUuid.randomUuid()); IgniteInternalFuture<IgniteInternalTx> fut = cctx.tm().txHandler().finish(n.id(), tx, req); // Add new future. if (fut != null) add(fut); } else { FinishMiniFuture fut = new FinishMiniFuture(m); req.miniId(fut.futureId()); add(fut); // Append new future. if (tx.pessimistic()) cctx.tm().beforeFinishRemote(n.id(), tx.threadId()); try { cctx.io().send(n, req, tx.ioPolicy()); // If we don't wait for result, then mark future as done. if (!isSync() && !m.explicitLock()) fut.onDone(); } catch (ClusterTopologyCheckedException e) { // Remove previous mapping. mappings.remove(m.node().id()); fut.onNodeLeft(n.id()); } catch (IgniteCheckedException e) { // Fail the whole thing. fut.onDone(e); } } }
/** @param nodeId Undo mapping. */ @Override public boolean removeMapping(UUID nodeId) { if (mappings.remove(nodeId) != null) { if (log.isDebugEnabled()) log.debug("Removed mapping for node [nodeId=" + nodeId + ", tx=" + this + ']'); return true; } else { if (log.isDebugEnabled()) log.debug("Mapping for node was not found [nodeId=" + nodeId + ", tx=" + this + ']'); return false; } }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public boolean onNodeLeft(UUID nodeId) { boolean found = false; for (IgniteInternalFuture<?> fut : futures()) if (isMini(fut)) { MinFuture f = (MinFuture) fut; if (f.onNodeLeft(nodeId)) { // Remove previous mapping. mappings.remove(nodeId); found = true; } } return found; }