/** * @return {@code True} if current thread is currently within transaction. */ public boolean inUserTx() { return userTx() != null; }
/** {@inheritDoc} */ @Override public Collection<Transaction> localActiveTransactions() { return F.viewReadOnly(cctx.tm().activeTransactions(), new IgniteClosure<IgniteInternalTx, Transaction>() { @Override public Transaction apply(IgniteInternalTx tx) { return ((GridNearTxLocal)tx).rollbackOnlyProxy(); } }, new IgnitePredicate<IgniteInternalTx>() { @Override public boolean apply(IgniteInternalTx tx) { return tx.local() && tx.near(); } }); }
/** * @return User transaction for current thread. */ @Nullable public GridNearTxLocal userTx() { IgniteInternalTx tx = txContext(); if (activeUserTx(tx)) return (GridNearTxLocal)tx; tx = tx(null, Thread.currentThread().getId()); if (activeUserTx(tx)) return (GridNearTxLocal)tx; return null; }
/** * @param cctx Cache context. * @return User transaction for current thread. */ @Nullable GridNearTxLocal userTx(GridCacheContext cctx) { IgniteInternalTx tx = tx(cctx, Thread.currentThread().getId()); if (activeUserTx(tx)) return (GridNearTxLocal)tx; return null; }
addRolledbackTx(tx); ConcurrentMap<GridCacheVersion, IgniteInternalTx> txIdMap = transactionMap(tx); unlockMultiple(tx, tx.writeEntries()); if (unlockReadEntries(tx)) unlockMultiple(tx, tx.readEntries()); notifyEvictions(tx); removeObsolete(tx); clearThreadMap(tx); resetContext();
log.debug("Uncommiting from TM: " + tx); ConcurrentMap<GridCacheVersion, IgniteInternalTx> txIdMap = transactionMap(tx); unlockMultiple(tx, tx.writeEntries()); if (unlockReadEntries(tx)) unlockMultiple(tx, tx.readEntries()); notifyEvictions(tx); clearThreadMap(tx); resetContext();
/** * @param ctx Context. * @param prj Projection. * @param concurrency Concurrency. * @param isolation Isolation. * @return New transaction. */ public static GridNearTxLocal txStartInternal(GridCacheContext ctx, IgniteInternalCache prj, TransactionConcurrency concurrency, TransactionIsolation isolation) { assert ctx != null; assert prj != null; ctx.tm().resetContext(); return prj.txStartEx(concurrency, isolation); }
/** * @return Local transaction. */ @Nullable public IgniteTxLocalAdapter localTx() { IgniteTxLocalAdapter tx = tx(); return tx != null && tx.local() ? tx : null; }
boolean first = true; for (IgniteInternalTx tx : tm.activeTransactions()) { if (first) { U.warn(diagnosticLog, "Pending transactions:"); ", exchWait=" + tm.needWaitTransaction(tx, exchTopVer) + ", tx=" + tx + ']'); first = true; for (IgniteInternalFuture<?> fut : tm.deadlockDetectionFutures()) { if (first) { U.warn(diagnosticLog, "Pending transaction deadlock detection futures:");
GridNearTxLocal tx = ctx.tm().threadLocalTx(ctx); tx = ctx.tm().newTx( true, op.single(), ctx.tm().resetContext(); ctx.near().dht().context().tm().resetContext();
assert tx.optimistic() || tx.readMap().isEmpty(); ConcurrentMap<GridCacheVersion, IgniteInternalTx> txIdMap = transactionMap(tx); notifyEvictions(tx); removeObsolete(tx); clearThreadMap(tx); resetContext();
/** * @param nodeId Node ID. * @param req Request. * @return Future. */ @Nullable private IgniteInternalFuture<IgniteInternalTx> processNearTxFinishRequest( UUID nodeId, GridNearTxFinishRequest req ) { if (txFinishMsgLog.isDebugEnabled()) txFinishMsgLog.debug("Received near finish request [txId=" + req.version() + ", node=" + nodeId + ']'); IgniteInternalFuture<IgniteInternalTx> fut = finish(nodeId, null, req); assert req.txState() != null || fut == null || fut.error() != null || (ctx.tm().tx(req.version()) == null && ctx.tm().nearTx(req.version()) == null) : "[req=" + req + ", fut=" + fut + "]"; return fut; }
if (cctx.tm().deadlockDetectionEnabled()) { synchronized (GridNearLockFuture.this) { requestedKeys = requestedKeys0(); IgniteInternalFuture<TxDeadlock> fut = cctx.tm().detectDeadlock(tx, keys);
/** {@inheritDoc} */ @Override public void onTimeout() { if (log.isDebugEnabled()) log.debug("Timed out waiting for lock response: " + this); synchronized (GridDhtLockFuture.this) { timedOut = true; // Stop locks and responses processing. pendingLocks.clear(); clear(); } boolean releaseLocks = !(inTx() && cctx.tm().deadlockDetectionEnabled()); onComplete(false, false, releaseLocks); }
tx = ctx.tm().newTx( true, op.single(), ctx.tm().resetContext(); ctx.near().dht().context().tm().resetContext();
/** * @param ctx Grid kernal context. * @param cctx Cache context. * @param timeout Transaction timeout. * @return Newly started SQL transaction. */ private static GridNearTxLocal txStart(GridKernalContext ctx, @Nullable GridCacheContext cctx, long timeout) { if (timeout == 0) { TransactionConfiguration tcfg = CU.transactionConfiguration(cctx, ctx.config()); if (tcfg != null) timeout = tcfg.getDefaultTxTimeout(); } GridNearTxLocal tx = ctx.cache().context().tm().newTx( false, false, cctx != null && cctx.systemTx() ? cctx : null, PESSIMISTIC, REPEATABLE_READ, timeout, cctx == null || !cctx.skipStore(), true, 0, null ); tx.syncMode(FULL_SYNC); return tx; }
/** * Removes Tx from manager. Can be used only if there were no updates. * * @param tx Transaction to finish. */ public void forgetTx(IgniteInternalTx tx) { assert tx != null; if (transactionMap(tx).remove(tx.xidVersion(), tx)) { // 1. Remove from per-thread storage. clearThreadMap(tx); // 2. Unregister explicit locks. if (!tx.alternateVersions().isEmpty()) for (GridCacheVersion ver : tx.alternateVersions()) idMap.remove(ver); // 3. Remove Near-2-DHT mappings. if (tx instanceof GridCacheMappedVersion) mappedVers.remove(((GridCacheMappedVersion)tx).mappedVersion()); // 4. Clear context. resetContext(); // 5. Complete finish future. tx.state(UNKNOWN); } }