/** */ 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(); }
/** * Sets MVCC state. * * @param tx Transaction. * @param state New state. */ public void setMvccState(IgniteInternalTx tx, byte state) { if (cctx.kernalContext().clientNode() || tx.mvccSnapshot() == null || tx.near() && !tx.local()) return; cctx.database().checkpointReadLock(); try { cctx.coordinators().updateState(tx.mvccSnapshot(), state, tx.local()); } finally { cctx.database().checkpointReadUnlock(); } }
/** * Commits or rolls back prepared transaction. * * @param tx Transaction. * @param commit Whether transaction should be committed or rolled back. */ public void finishTxOnRecovery(final IgniteInternalTx tx, boolean commit) { if (log.isInfoEnabled()) log.info("Finishing prepared transaction [commit=" + commit + ", tx=" + tx + ']'); if (!tx.markFinalizing(RECOVERY_FINISH)) { if (log.isInfoEnabled()) log.info("Will not try to commit prepared transaction (could not mark finalized): " + tx); return; } if (tx instanceof IgniteTxRemoteEx) { IgniteTxRemoteEx rmtTx = (IgniteTxRemoteEx)tx; rmtTx.doneRemote(tx.xidVersion(), Collections.<GridCacheVersion>emptyList(), Collections.<GridCacheVersion>emptyList(), Collections.<GridCacheVersion>emptyList()); } if (commit) tx.commitAsync().listen(new CommitListener(tx)); else if (tx.mvccSnapshot() != null && !tx.local()) // remote (backup) mvcc transaction sends partition counters to other backup transaction // in order to keep counters consistent neighborcastPartitionCountersAndRollback(tx); else tx.rollbackAsync(); }
log.debug("Transaction finished: [commit=" + commit + ", tx=" + tx + ']'); if (tx.system() || tx.internal() || tx.mvccSnapshot() == null) return; cntrs.remove(new TxKey(tx.mvccSnapshot().coordinatorVersion(), tx.mvccSnapshot().counter()));
&& tx.mvccSnapshot() != null) allTxFinFut.add(tx.finishFuture());
/** * Rollback all active transactions with acquired Mvcc snapshot. */ public void rollbackMvccTxOnCoordinatorChange() { for (IgniteInternalTx tx : activeTransactions()) { if (tx.mvccSnapshot() != null) ((GridNearTxLocal)tx).rollbackNearTxLocalAsync(false, false); } }
/** * Commits or rolls back prepared transaction. * * @param tx Transaction. * @param commit Whether transaction should be committed or rolled back. */ public void finishTxOnRecovery(final IgniteInternalTx tx, boolean commit) { if (log.isInfoEnabled()) log.info("Finishing prepared transaction [commit=" + commit + ", tx=" + tx + ']'); if (!tx.markFinalizing(RECOVERY_FINISH)) { if (log.isInfoEnabled()) log.info("Will not try to commit prepared transaction (could not mark finalized): " + tx); return; } if (tx instanceof IgniteTxRemoteEx) { IgniteTxRemoteEx rmtTx = (IgniteTxRemoteEx)tx; rmtTx.doneRemote(tx.xidVersion(), Collections.<GridCacheVersion>emptyList(), Collections.<GridCacheVersion>emptyList(), Collections.<GridCacheVersion>emptyList()); } if (commit) tx.commitAsync().listen(new CommitListener(tx)); else if (tx.mvccSnapshot() != null && !tx.local()) // remote (backup) mvcc transaction sends partition counters to other backup transaction // in order to keep counters consistent neighborcastPartitionCountersAndRollback(tx); else tx.rollbackAsync(); }
log.debug("Transaction finished: [commit=" + commit + ", tx=" + tx + ']'); if (tx.system() || tx.internal() || tx.mvccSnapshot() == null) return; cntrs.remove(new TxKey(tx.mvccSnapshot().coordinatorVersion(), tx.mvccSnapshot().counter()));
&& tx.mvccSnapshot() != null) allTxFinFut.add(tx.finishFuture());