/** * Suspends transaction. * Should not be used directly. Use tx.suspend() instead. * * @param tx Transaction to be suspended. * * @see #resumeTx(GridNearTxLocal, long) * @see GridNearTxLocal#suspend() * @see GridNearTxLocal#resume() * @throws IgniteCheckedException If failed to suspend transaction. */ public void suspendTx(final GridNearTxLocal tx) throws IgniteCheckedException { assert tx != null && !tx.system() : tx; if (!tx.state(SUSPENDED)) { throw new IgniteCheckedException("Trying to suspend transaction with incorrect state " + "[expected=" + ACTIVE + ", actual=" + tx.state() + ']'); } clearThreadMap(tx); transactionMap(tx).remove(tx.xidVersion(), tx); }
/** {@inheritDoc} */ @Override public final void prepare() { // Obtain the topology version to use. long threadId = Thread.currentThread().getId(); AffinityTopologyVersion topVer = cctx.mvcc().lastExplicitLockTopologyVersion(threadId); // If there is another system transaction in progress, use it's topology version to prevent deadlock. if (topVer == null && tx.system()) { topVer = cctx.tm().lockedTopologyVersion(threadId, tx); if (topVer == null) topVer = tx.topologyVersionSnapshot(); } if (topVer != null) { tx.topologyVersion(topVer); cctx.mvcc().addFuture(this); prepare0(false, true); return; } prepareOnTopology(false, null); }
/** * Resume transaction in current thread. * Please don't use directly. Use tx.resume() instead. * * @param tx Transaction to be resumed. * @param threadId Thread id to restore. * * @see #suspendTx(GridNearTxLocal) * @see GridNearTxLocal#suspend() * @see GridNearTxLocal#resume() * @throws IgniteCheckedException If failed to resume tx. */ public void resumeTx(GridNearTxLocal tx, long threadId) throws IgniteCheckedException { assert tx != null && !tx.system() : tx; if (!tx.state(ACTIVE)) { throw new IgniteCheckedException("Trying to resume transaction with incorrect state " + "[expected=" + SUSPENDED + ", actual=" + tx.state() + ']'); } assert !threadMap.containsValue(tx) : tx; assert !transactionMap(tx).containsValue(tx) : tx; assert !haveSystemTxForThread(Thread.currentThread().getId()); if (threadMap.putIfAbsent(threadId, tx) != null) throw new IgniteCheckedException("Thread already has started a transaction."); if (transactionMap(tx).putIfAbsent(tx.xidVersion(), tx) != null) throw new IgniteCheckedException("Thread already has started a transaction."); tx.threadId(threadId); }
lb); if (tx.system()) { AffinityTopologyVersion topVer = cctx.tm().lockedTopologyVersion(Thread.currentThread().getId(), tx);
if (!tx.system()) { if (commit) cctx.txMetrics().onTxCommit();
if (topVer == null && tx.system()) topVer = cctx.tm().lockedTopologyVersion(threadId, tx);
true, false, tx.system(), tx.ioPolicy(), false,
if (topVer == null && tx != null && tx.system()) topVer = cctx.tm().lockedTopologyVersion(Thread.currentThread().getId(), tx);
if (topVer == null && tx != null && tx.system()) topVer = cctx.tm().lockedTopologyVersion(threadId, tx);
if (topVer == null && tx.system()) topVer = cctx.tm().lockedTopologyVersion(threadId, tx);
commit, tx.isInvalidate(), tx.system(), tx.ioPolicy(), syncMode,
/** * Suspends transaction. * Should not be used directly. Use tx.suspend() instead. * * @param tx Transaction to be suspended. * * @see #resumeTx(GridNearTxLocal, long) * @see GridNearTxLocal#suspend() * @see GridNearTxLocal#resume() * @throws IgniteCheckedException If failed to suspend transaction. */ public void suspendTx(final GridNearTxLocal tx) throws IgniteCheckedException { assert tx != null && !tx.system() : tx; if (!tx.state(SUSPENDED)) { throw new IgniteCheckedException("Trying to suspend transaction with incorrect state " + "[expected=" + ACTIVE + ", actual=" + tx.state() + ']'); } clearThreadMap(tx); transactionMap(tx).remove(tx.xidVersion(), tx); }
/** * Resume transaction in current thread. * Please don't use directly. Use tx.resume() instead. * * @param tx Transaction to be resumed. * @param threadId Thread id to restore. * * @see #suspendTx(GridNearTxLocal) * @see GridNearTxLocal#suspend() * @see GridNearTxLocal#resume() * @throws IgniteCheckedException If failed to resume tx. */ public void resumeTx(GridNearTxLocal tx, long threadId) throws IgniteCheckedException { assert tx != null && !tx.system() : tx; if (!tx.state(ACTIVE)) { throw new IgniteCheckedException("Trying to resume transaction with incorrect state " + "[expected=" + SUSPENDED + ", actual=" + tx.state() + ']'); } assert !threadMap.containsValue(tx) : tx; assert !transactionMap(tx).containsValue(tx) : tx; assert !haveSystemTxForThread(Thread.currentThread().getId()); if (threadMap.putIfAbsent(threadId, tx) != null) throw new IgniteCheckedException("Thread already has started a transaction."); if (transactionMap(tx).putIfAbsent(tx.xidVersion(), tx) != null) throw new IgniteCheckedException("Thread already has started a transaction."); tx.threadId(threadId); }
/** {@inheritDoc} */ @Override public final void prepare() { // Obtain the topology version to use. long threadId = Thread.currentThread().getId(); AffinityTopologyVersion topVer = cctx.mvcc().lastExplicitLockTopologyVersion(threadId); // If there is another system transaction in progress, use it's topology version to prevent deadlock. if (topVer == null && tx.system()) { topVer = cctx.tm().lockedTopologyVersion(threadId, tx); if (topVer == null) topVer = tx.topologyVersionSnapshot(); } if (topVer != null) { tx.topologyVersion(topVer); cctx.mvcc().addFuture(this); prepare0(false, true); return; } prepareOnTopology(false, null); }
lb); if (tx.system()) { AffinityTopologyVersion topVer = cctx.tm().lockedTopologyVersion(Thread.currentThread().getId(), tx);
if (!tx.system()) { if (commit) cctx.txMetrics().onTxCommit();
/** */ private void init() { // Obtain the topology version to use. long threadId = Thread.currentThread().getId(); AffinityTopologyVersion topVer = cctx.mvcc().lastExplicitLockTopologyVersion(threadId); // If there is another system transaction in progress, use it's topology version to prevent deadlock. if (topVer == null && tx.system()) topVer = cctx.tm().lockedTopologyVersion(threadId, tx); if (topVer != null) tx.topologyVersion(topVer); if (topVer == null) topVer = tx.topologyVersionSnapshot(); if (topVer != null) { for (GridDhtTopologyFuture fut : cctx.shared().exchange().exchangeFutures()) { if (fut.exchangeDone() && fut.topologyVersion().equals(topVer)) { Throwable err = fut.validateCache(cctx, false, false, null, null); if (err != null) { onDone(err); return; } break; } } onDone(topVer); topLocked = true; return; } acquireTopologyVersion(); }
if (topVer == null && tx != null && tx.system()) topVer = cctx.tm().lockedTopologyVersion(Thread.currentThread().getId(), tx);
if (topVer == null && tx != null && tx.system()) topVer = cctx.tm().lockedTopologyVersion(threadId, tx);
true, false, tx.system(), tx.ioPolicy(), false,