/** * @param nodeId Node ID. * @param res Response. */ private void processNearTxPrepareResponse(UUID nodeId, GridNearTxPrepareResponse res) { if (txPrepareMsgLog.isDebugEnabled()) txPrepareMsgLog.debug("Received near prepare response [txId=" + res.version() + ", node=" + nodeId + ']'); GridNearTxPrepareFutureAdapter fut = (GridNearTxPrepareFutureAdapter)ctx.mvcc() .<IgniteInternalTx>versionedFuture(res.version(), res.futureId()); if (fut == null) { U.warn(log, "Failed to find future for near prepare response [txId=" + res.version() + ", node=" + nodeId + ", res=" + res + ']'); return; } IgniteInternalTx tx = fut.tx(); assert tx != null; res.txState(tx.txState()); fut.onResult(nodeId, res); }
/** * Completes this future. */ public void complete() { GridNearTxPrepareResponse res = new GridNearTxPrepareResponse(); res.error(err != null ? err : new IgniteCheckedException("Failed to prepare transaction.")); onComplete(res); }
if (parent.tx.remainingTime() == -1 || res.error() instanceof IgniteTxTimeoutCheckedException) { parent.onTimeout(); if (res.error() != null) { parent.onError(res.error(), false); if (res.clientRemapVersion() != null) { assert parent.cctx.kernalContext().clientNode(); assert m.clientFirst(); parent.cctx.exchange().affinityReadyFuture(res.clientRemapVersion());
return; assert res.error() == null : res; if (tx.onePhaseCommit() && !res.onePhaseCommit()) tx.onePhaseCommit(false); for (Map.Entry<IgniteTxKey, CacheVersionedValue> entry : res.ownedValues().entrySet()) { IgniteTxEntry txEntry = tx.entry(entry.getKey()); tx.implicitSingleResult(res.returnValue()); for (IgniteTxKey key : res.filterFailedKeys()) { IgniteTxEntry txEntry = tx.entry(key); cctx.versions().onReceived(nodeId, res.dhtVersion()); GridCacheVersion writeVer = res.writeVersion(); writeVer = res.dhtVersion(); m.dhtVersion(res.dhtVersion(), writeVer); map.dhtVersion(res.dhtVersion(), writeVer); tx.readyNearLocks(m, res.pending(), res.committedVersions(), res.rolledbackVersions());
IgnitePair<Collection<GridCacheVersion>> versPair = cctx.tm().versions(min); res.completedVersions(versPair.get1(), versPair.get2()); res.pending(localDhtPendingVersions(tx.writeEntries(), min)); res.filterFailedKeys(filterFailedKeys);
tx.activeCachesDeploymentEnabled()); res.mvccSnapshot(tx.mvccSnapshot()); IgnitePair<Collection<GridCacheVersion>> versPair = cctx.tm().versions(min); res.completedVersions(versPair.get1(), versPair.get2()); res.pending(localDhtPendingVersions(tx.writeEntries(), min)); res.filterFailedKeys(filterFailedKeys);
/** * @param cacheMsg Cache message. * @return Transaction ID if applicable for message. */ @Nullable private GridCacheVersion txId(GridCacheMessage cacheMsg) { if (cacheMsg instanceof GridDhtTxPrepareRequest) return ((GridDhtTxPrepareRequest)cacheMsg).nearXidVersion(); else if (cacheMsg instanceof GridNearTxPrepareRequest) return ((GridNearTxPrepareRequest)cacheMsg).version(); else if (cacheMsg instanceof GridNearTxPrepareResponse) return ((GridNearTxPrepareResponse)cacheMsg).version(); else if (cacheMsg instanceof GridNearTxFinishRequest) return ((GridNearTxFinishRequest)cacheMsg).version(); else if (cacheMsg instanceof GridNearTxFinishResponse) return ((GridNearTxFinishResponse)cacheMsg).xid(); return null; }
/** {@inheritDoc} */ @Override public void onResult(UUID nodeId, GridNearTxPrepareResponse res) { if (!isDone()) { assert res.clientRemapVersion() == null : res; MiniFuture f = miniFuture(res.miniId()); if (f != null) { assert f.primary().id().equals(nodeId); f.onResult(res, true); } else { if (msgLog.isDebugEnabled()) { msgLog.debug("Near pessimistic prepare, failed to find mini future [txId=" + tx.nearXidVersion() + ", node=" + nodeId + ", res=" + res + ", fut=" + this + ']'); } } } else { if (msgLog.isDebugEnabled()) { msgLog.debug("Near pessimistic prepare, response for finished future [txId=" + tx.nearXidVersion() + ", node=" + nodeId + ", res=" + res + ", fut=" + this + ']'); } } }
@Override public void apply(IgniteInternalFuture<Boolean> remapFut0) { try { IgniteInternalFuture<?> affFut = parent.cctx.exchange().affinityReadyFuture(res.clientRemapVersion()); log.debug("Will remap client tx [" + "fut=" + parent + ", topVer=" + res.topologyVersion() + ']');
res.addOwnedValue(txEntry.txKey(), dhtVer, val0); IgniteTxEntry txEntry = tx.entry(ver.getKey()); if (res.hasOwnedValue(ver.getKey())) continue; CacheObject val0 = entry.valueBytes(); res.addOwnedValue(txEntry.txKey(), dhtVer, val0);
if (!writer.writeHeader(directType(), fieldsCount())) return false;
/** * @param res Response. * @param updateMapping Update mapping flag. */ void onResult(GridNearTxPrepareResponse res, boolean updateMapping) { if (res.error() != null) onError(res.error()); else { if (res.mvccSnapshot() != null) tx.mvccSnapshot(res.mvccSnapshot()); onPrepareResponse(m, res, updateMapping); onDone(res); } }
@Override public GridNearTxPrepareResponse apply(IgniteInternalFuture<GridNearTxPrepareResponse> f) { try { return f.get(); } catch (Exception e) { locTx.setRollbackOnly(); // Just in case. if (!X.hasCause(e, IgniteTxOptimisticCheckedException.class) && !X.hasCause(e, IgniteFutureCancelledException.class)) U.error(log, "Failed to prepare DHT transaction: " + locTx, e); return new GridNearTxPrepareResponse( req.partition(), req.version(), req.futureId(), req.miniId(), req.version(), req.version(), null, e, null, req.onePhaseCommit(), req.deployInfo() != null); } } });
/** {@inheritDoc} */ @Override public boolean collect(@Nullable GridNearTxPrepareResponse res) { assert res != null; if (res.clientRemapVersion() == null) remap = false; return true; }
return; assert res.error() == null : res; if (tx.onePhaseCommit() && !res.onePhaseCommit()) tx.onePhaseCommit(false); for (Map.Entry<IgniteTxKey, CacheVersionedValue> entry : res.ownedValues().entrySet()) { IgniteTxEntry txEntry = tx.entry(entry.getKey()); tx.implicitSingleResult(res.returnValue()); for (IgniteTxKey key : res.filterFailedKeys()) { IgniteTxEntry txEntry = tx.entry(key); cctx.versions().onReceived(nodeId, res.dhtVersion()); GridCacheVersion writeVer = res.writeVersion(); writeVer = res.dhtVersion(); m.dhtVersion(res.dhtVersion(), writeVer); map.dhtVersion(res.dhtVersion(), writeVer); tx.readyNearLocks(m, res.pending(), res.committedVersions(), res.rolledbackVersions());
GridNearTxPrepareResponse res = (GridNearTxPrepareResponse)msg0; GridCacheVersion txId = res.version();
/** {@inheritDoc} */ @Override public void onResult(UUID nodeId, GridNearTxPrepareResponse res) { if (!isDone()) { assert res.clientRemapVersion() == null : res; MiniFuture f = miniFuture(res.miniId()); if (f != null) { assert f.primary().id().equals(nodeId); f.onResult(res, true); } else { if (msgLog.isDebugEnabled()) { msgLog.debug("Near pessimistic prepare, failed to find mini future [txId=" + tx.nearXidVersion() + ", node=" + nodeId + ", res=" + res + ", fut=" + this + ']'); } } } else { if (msgLog.isDebugEnabled()) { msgLog.debug("Near pessimistic prepare, response for finished future [txId=" + tx.nearXidVersion() + ", node=" + nodeId + ", res=" + res + ", fut=" + this + ']'); } } }
@Override public void apply(IgniteInternalFuture<Boolean> remapFut0) { try { IgniteInternalFuture<?> affFut = parent.cctx.exchange().affinityReadyFuture(res.clientRemapVersion()); log.debug("Will remap client tx [" + "fut=" + parent + ", topVer=" + res.topologyVersion() + ']');