IgniteTxEntry firstWrite = unmarshal(req.writes()); IgniteTxEntry firstRead = unmarshal(req.reads()); GridCacheVersion mappedVer = ctx.tm().mappedVersion(req.version()); U.warn(log, "Missing local transaction for mapped near version [nearVer=" + req.version() + ", mappedVer=" + mappedVer + ']'); else { if (req.concurrency() == PESSIMISTIC) tx.nearFutureId(req.futureId()); if (req.firstClientRequest()) { assert firstEntry != null : req; assert req.concurrency() == OPTIMISTIC : req; assert nearNode.isClient() : nearNode; if (req.allowWaitTopologyFuture()) { GridDhtTopologyFuture topFut = top.topologyVersionFuture(); if (!req.allowWaitTopologyFuture() && !topFut.isDone()) { retry = true; "txId=" + req.version() + ", node=" + nearNode.id() + ", reqTopVer=" + req.topologyVersion() + ", locTopVer=" + top.readyTopologyVersion() + ", req=" + req + ']');
/** * */ public void cloneEntries() { reads(cloneEntries(reads())); writes(cloneEntries(writes())); }
/** {@inheritDoc} */ @Override public String toString() { StringBuilder flags = new StringBuilder(); if (near()) flags.append("[near]"); if (firstClientRequest()) flags.append("[firstClientReq]"); if (implicitSingle()) flags.append("[implicitSingle]"); if (explicitLock()) flags.append("[explicitLock]"); return S.toString(GridNearTxPrepareRequest.class, this, "flags", flags.toString(), "super", super.toString()); } }
@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); } } });
req.partition(), req.version(), req.futureId(), req.miniId(), req.version(), req.version(), null, null, null, false, req.deployInfo() != null); res.error(req.classError()); sendResponseOnFailedMessage(nodeId, res, cctx, req.policy());
/** * @param nearNode Sender node. * @param req Request. */ private void processNearTxPrepareRequest0(ClusterNode nearNode, GridNearTxPrepareRequest req) { IgniteInternalFuture<GridNearTxPrepareResponse> fut; if (req.firstClientRequest() && req.allowWaitTopologyFuture()) { for (;;) { if (waitForExchangeFuture(nearNode, req)) return; fut = prepareNearTx(nearNode, req); if (fut != null) break; } } else fut = prepareNearTx(nearNode, req); assert req.txState() != null || fut == null || fut.error() != null || (ctx.tm().tx(req.version()) == null && ctx.tm().nearTx(req.version()) == null); }
GridDistributedTxMapping m = fut.mapping(); GridNearTxPrepareRequest req = new GridNearTxPrepareRequest( futId, tx.topologyVersion(), req.addDhtVersion(txEntry.txKey(), null); req.miniId(fut.futureId());
/** {@inheritDoc} */ @Override public int partition() { return U.safeAbs(version().hashCode()); }
Collection<IgniteTxEntry> reads, Collection<IgniteTxEntry> writes) { GridNearTxPrepareRequest req = new GridNearTxPrepareRequest( futId, tx.topologyVersion(), tx.txState().recovery()); req.queryUpdate(m.queryUpdate()); req.addDhtVersion(txEntry.txKey(), null);
assert req.firstClientRequest() : req; ctx.time().waitAsync(topFut, req.timeout(), (e, timedOut) -> { if (e != null || timedOut) { sendResponseOnTimeoutOrError(e, topFut, node, req); if (req.timeout() > 0) topFut.get(req.timeout()); else topFut.get();
/** * @param msgs Messages. * @param expCnt Expected number of messages. */ private void checkClientPrepareMessages(List<Object> msgs, int expCnt) { assertEquals(expCnt, msgs.size()); assertTrue(((GridNearTxPrepareRequest)msgs.get(0)).firstClientRequest()); for (int i = 1; i < msgs.size(); i++) assertFalse(((GridNearTxPrepareRequest) msgs.get(i)).firstClientRequest()); }
assertTrue(req.onePhaseCommit());
/** * @param originTx Transaction for copy. * @param req Request. * @return Prepare future. */ public IgniteInternalFuture<GridNearTxPrepareResponse> prepareNearTxLocal( final GridNearTxLocal originTx, final GridNearTxPrepareRequest req) { // Make sure not to provide Near entries to DHT cache. req.cloneEntries(); return prepareNearTx(originTx, ctx.localNode(), req); }
msg = new GridNearTxPrepareRequest();
if (e == null) e = new IgniteTxTimeoutCheckedException("Failed to wait topology version for near prepare " + "[txId=" + req.version() + ", topVer=" + topFut.initialVersion() + ", node=" + node.id() + req.partition(), req.version(), req.futureId(), req.miniId(), req.version(), req.version(), null, e, null, req.onePhaseCommit(), req.deployInfo() != null); ctx.io().send(node.id(), res, req.policy()); "[txId=" + req.version() + ", topVer=" + topFut.initialVersion() + ", node=" + node.id() +
req.partition(), req.version(), req.futureId(), req.miniId(), req.version(), req.version(), null, null, null, false, req.deployInfo() != null); res.error(req.classError()); sendResponseOnFailedMessage(nodeId, res, cctx, req.policy());
/** * @param nearNode Sender node. * @param req Request. */ private void processNearTxPrepareRequest0(ClusterNode nearNode, GridNearTxPrepareRequest req) { IgniteInternalFuture<GridNearTxPrepareResponse> fut; if (req.firstClientRequest() && req.allowWaitTopologyFuture()) { for (;;) { if (waitForExchangeFuture(nearNode, req)) return; fut = prepareNearTx(nearNode, req); if (fut != null) break; } } else fut = prepareNearTx(nearNode, req); assert req.txState() != null || fut == null || fut.error() != null || (ctx.tm().tx(req.version()) == null && ctx.tm().nearTx(req.version()) == null); }
/** {@inheritDoc} */ @Override public String toString() { StringBuilder flags = new StringBuilder(); if (near()) flags.append("[near]"); if (firstClientRequest()) flags.append("[firstClientReq]"); if (implicitSingle()) flags.append("[implicitSingle]"); if (explicitLock()) flags.append("[explicitLock]"); return S.toString(GridNearTxPrepareRequest.class, this, "flags", flags.toString(), "super", super.toString()); } }
GridNearTxPrepareRequest req = new GridNearTxPrepareRequest( futId, tx.topologyVersion(), req.addDhtVersion(txEntry.txKey(), null); req.miniId(fut.futureId());
/** * @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; }