/** * @param cctx Cache context. * @return Transaction for current thread. */ public GridNearTxLocal threadLocalTx(GridCacheContext cctx) { IgniteInternalTx tx = tx(cctx, Thread.currentThread().getId()); if (tx != null && tx.local() && (!tx.dht() || tx.colocated()) && !tx.implicit()) { assert tx instanceof GridNearTxLocal : tx; return (GridNearTxLocal)tx; } return null; }
/** * @param tx Transaction to clear. */ public void clearThreadMap(IgniteInternalTx tx) { if (tx.local() && !tx.dht()) { assert tx instanceof GridNearTxLocal : tx; if (!tx.system()) threadMap.remove(tx.threadId(), tx); else { Integer cacheId = tx.txState().firstCacheId(); if (cacheId != null) sysThreadMap.remove(new TxThreadKey(tx.threadId(), cacheId), tx); else { for (Iterator<IgniteInternalTx> it = sysThreadMap.values().iterator(); it.hasNext(); ) { IgniteInternalTx txx = it.next(); if (tx == txx) { it.remove(); break; } } } } } }
/** * * @param tx Transaction to check. * @return {@code True} if transaction has been committed or rolled back, * {@code false} otherwise. */ private boolean isCompleted(IgniteInternalTx tx) { boolean completed = completedVersHashMap.containsKey(tx.xidVersion()); // Need check that for tx rollback message was not received before lock. // This could happen on timeout or async rollback. if (!completed && tx.local() && tx.dht()) return completedVersHashMap.containsKey(tx.nearXidVersion()); return completed; }
/** * @param ses Session. * @param load {@code True} if {@link #loadAll} method is called. */ private void checkTx(@Nullable CacheStoreSession ses, boolean load) { Transaction tx = ses != null ? ses.transaction() : null; if (tx == null) return; txs.add(tx); IgniteInternalTx tx0 = GridTestUtils.getFieldValue(tx, "tx"); if (!tx0.local()) throw new IgniteException("Tx is not local: " + tx); if (tx0.dht() && !load) throw new IgniteException("Tx is DHT: " + tx); }
if (tx.local() && !tx.dht()) { assert tx instanceof GridNearTxLocal : tx;
if (!tx.dht() && tx.local()) { if (!tx.system()) cctx.txMetrics().onTxRollback();
IgniteInternalTx tx0 = tx; if (tx0 != null && (tx0.dht() && tx0.local())) tx0 = null;
if (!tx.dht() && tx.local()) { if (!tx.system()) cctx.txMetrics().onTxCommit();
if (cctx.isReplicated() || cctx.isColocated() || tx.near()) tx0 = tx; else if (tx.dht()) { GridCacheVersion ver = tx.nearXidVersion();
assert tx.dht() : "Received invalid partition for non DHT transaction [tx=" + tx + ", invalidPart=" + e.partition() + ']';
/** * @param cctx Cache context. * @return Transaction for current thread. */ public GridNearTxLocal threadLocalTx(GridCacheContext cctx) { IgniteInternalTx tx = tx(cctx, Thread.currentThread().getId()); if (tx != null && tx.local() && (!tx.dht() || tx.colocated()) && !tx.implicit()) { assert tx instanceof GridNearTxLocal : tx; return (GridNearTxLocal)tx; } return null; }
/** * @param tx Transaction to clear. */ public void clearThreadMap(IgniteInternalTx tx) { if (tx.local() && !tx.dht()) { assert tx instanceof GridNearTxLocal : tx; if (!tx.system()) threadMap.remove(tx.threadId(), tx); else { Integer cacheId = tx.txState().firstCacheId(); if (cacheId != null) sysThreadMap.remove(new TxThreadKey(tx.threadId(), cacheId), tx); else { for (Iterator<IgniteInternalTx> it = sysThreadMap.values().iterator(); it.hasNext(); ) { IgniteInternalTx txx = it.next(); if (tx == txx) { it.remove(); break; } } } } } }
/** * * @param tx Transaction to check. * @return {@code True} if transaction has been committed or rolled back, * {@code false} otherwise. */ private boolean isCompleted(IgniteInternalTx tx) { boolean completed = completedVersHashMap.containsKey(tx.xidVersion()); // Need check that for tx rollback message was not received before lock. // This could happen on timeout or async rollback. if (!completed && tx.local() && tx.dht()) return completedVersHashMap.containsKey(tx.nearXidVersion()); return completed; }
if (tx.local() && !tx.dht()) { assert tx instanceof GridNearTxLocal : tx;
if (!tx.dht() && tx.local()) { if (!tx.system()) cctx.txMetrics().onTxRollback();
IgniteInternalTx tx0 = tx; if (tx0 != null && (tx0.dht() && tx0.local())) tx0 = null;
if (!tx.dht() && tx.local()) { if (!tx.system()) cctx.txMetrics().onTxCommit();
if (cctx.isReplicated() || cctx.isColocated() || tx.near()) tx0 = tx; else if (tx.dht()) { GridCacheVersion ver = tx.nearXidVersion();
assert tx.dht() : "Received invalid partition for non DHT transaction [tx=" + tx + ", invalidPart=" + e.partition() + ']';