/** * @return Cache transaction manager. */ public IgniteTxManager tm() { return sharedCtx.tm(); }
/** {@inheritDoc} */ @Nullable @Override public Transaction tx() { GridNearTxLocal tx = cctx.tm().userTx(); return tx != null ? tx.proxy() : null; }
/** * Initializes read map. * * @return {@code True} if transaction was successfully started. */ public boolean init() { return !txState.init(txSize) || cctx.tm().onStarted(this); }
/** {@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(); } }); }
/** */ private Optional<GridDhtTxLocalAdapter> findTx(MvccVersion mvccVer) { return cctx.tm().activeTransactions().stream() .filter(tx -> tx.local() && tx.mvccSnapshot() != null) .filter(tx -> belongToSameTx(mvccVer, tx.mvccSnapshot())) .map(GridDhtTxLocalAdapter.class::cast) .findAny(); }
/** */ private void init() { cctx.tm().addFuture(this); if (topVer == null) // Tx manager already stopped onDone(); else map(keys, Collections.<IgniteTxKey, TxLockList>emptyMap()); }
/** {@inheritDoc} */ @Override public boolean onDone(@Nullable TxDeadlock res, @Nullable Throwable err) { if (super.onDone(res, err)) { cctx.tm().removeFuture(futId); if (timeoutObj != null) cctx.time().removeTimeoutObject(timeoutObj); return true; } return false; }
/** {@inheritDoc} */ @Override public String toString() { if (!pendingLocks.isEmpty()) { Map<GridCacheVersion, IgniteInternalTx> txs = new HashMap<>(1, 1.0f); for (Collection<GridCacheMvccCandidate> cands : pendingLocks.values()) for (GridCacheMvccCandidate c : cands) txs.put(c.version(), cctx.tm().tx(c.version())); return S.toString(FinishLockFuture.class, this, "txs=" + txs + ", super=" + super.toString()); } else return S.toString(FinishLockFuture.class, this, super.toString()); } }
/** * Properly close transaction. * @param tx Transaction. * @throws IgniteCheckedException if failed. */ private void closeTx(@NotNull GridNearTxLocal tx) throws IgniteCheckedException { try { tx.close(); } finally { ctx.cache().context().tm().resetContext(); } }
/** * */ private long nearTxNum() { IgnitePredicate<IgniteInternalTx> pred = new IgnitePredicate<IgniteInternalTx>() { @Override public boolean apply(IgniteInternalTx tx) { return tx.local() && tx.near(); } }; return F.size(gridKernalCtx.cache().context().tm().activeTransactions(), pred); }
/** * @param nodeId Node ID. * @param req Request. */ private void processDhtTxOnePhaseCommitAckRequest(final UUID nodeId, final GridDhtTxOnePhaseCommitAckRequest req) { assert nodeId != null; assert req != null; if (log.isDebugEnabled()) log.debug("Processing dht tx one phase commit ack request [nodeId=" + nodeId + ", req=" + req + ']'); for (GridCacheVersion ver : req.versions()) ctx.tm().removeTxReturn(ver); }
/** */ private static List<IgniteInternalTx> txsOnNode(IgniteEx node, GridCacheVersion xidVer) { List<IgniteInternalTx> txs = node.context().cache().context().tm().activeTransactions().stream() .peek(tx -> assertEquals(xidVer, tx.nearXidVersion())) .collect(Collectors.toList()); assert !txs.isEmpty(); return txs; }
/** * @throws IgniteCheckedException If failed. */ private void proceedMapping() throws IgniteCheckedException { boolean set = tx != null && cctx.shared().tm().setTxTopologyHint(tx.topologyVersionSnapshot()); try { proceedMapping0(); } finally { if (set) cctx.tm().setTxTopologyHint(null); } }
/** */ private static List<IgniteInternalTx> txsOnNode(IgniteEx node, GridCacheVersion xidVer) { return node.context().cache().context().tm().activeTransactions().stream() .peek(tx -> assertEquals(xidVer, tx.nearXidVersion())) .collect(Collectors.toList()); } }
@Override public boolean apply() { for (IgniteKernal g : grids) { GridCacheSharedContext<Object, Object> ctx = g.context().cache().context(); int txNum = ctx.tm().idMapSize(); if (txNum != 0) return false; } return true; } }, 10000);
/** * @param ignite Node. * @return Completed txs map. */ private Map completedTxsMap(Ignite ignite) { IgniteTxManager tm = ((IgniteKernal)ignite).context().cache().context().tm(); return U.field(tm, "completedVersHashMap"); }
/** * */ private void checkDetectionFuts() { for (int i = 0; i < NODES_CNT ; i++) { Ignite ignite = ignite(i); IgniteTxManager txMgr = ((IgniteKernal)ignite).context().cache().context().tm(); Collection<IgniteInternalFuture<?>> futs = txMgr.deadlockDetectionFutures(); assertTrue(futs.isEmpty()); } }
/** * */ private void checkDetectionFutures() { for (int i = 0; i < NODES_CNT ; i++) { Ignite ignite = ignite(i); IgniteTxManager txMgr = ((IgniteKernal)ignite).context().cache().context().tm(); Collection<IgniteInternalFuture<?>> futs = txMgr.deadlockDetectionFutures(); assertTrue(futs.isEmpty()); } } }
/** * */ private void checkTransactions() { for (int i = 0; i < 3; i++) { IgniteTxManager tm = ((IgniteKernal)grid(i)).context().cache().context().tm(); assertEquals("Uncommitted transactions found on node [idx=" + i + ", mapSize=" + tm.idMapSize() + ']', 0, tm.idMapSize()); } }
/** * @param node Node. */ private void checkNoTx(Ignite node) { IgniteTransactions txs = node.transactions(); assertNull(txs.tx()); assertNull(((IgniteKernal)node).context().cache().context().tm().tx()); } }