/** * Acquires topology read lock. * * @return Topology ready future. */ protected final GridDhtTopologyFuture topologyReadLock() { return tx.txState().topologyReadLock(cctx, this); }
/** * Releases topology read lock. */ protected final void topologyReadUnlock() { tx.txState().topologyReadUnlock(cctx); }
/** * Checks if mapped transaction can be committed on one phase. * One-phase commit can be done if transaction maps to one primary node and not more than one backup. * * @param txNodes Primary to backups node map. */ final void checkOnePhase(Map<UUID, Collection<UUID>> txNodes) { if (tx.storeWriteThrough() || tx.txState().mvccEnabled()) // TODO IGNITE-3479 (onePhase + mvcc) return; if (txNodes.size() == 1) { Map.Entry<UUID, Collection<UUID>> entry = txNodes.entrySet().iterator().next(); assert entry != null; Collection<UUID> backups = entry.getValue(); if (backups.size() <= 1) tx.onePhaseCommit(true); } }
/** * Resume transaction if it was previously suspended. * * @param tx Transaction to resume. * @throws IgniteCheckedException If resume failed. */ public void resumeTx(GridNearTxLocal tx) throws IgniteCheckedException { tx.txState().awaitLastFuture(this); tx.resume(); }
/** * Suspends transaction. It could be resume later. Supported only for optimistic transactions. * * @param tx Transaction to suspend. * @throws IgniteCheckedException If suspension failed. */ public void suspendTx(GridNearTxLocal tx) throws IgniteCheckedException { tx.txState().awaitLastFuture(this); tx.suspend(); }
/** * @param tx Transaction to commit. * @return Commit future. */ @SuppressWarnings("unchecked") public IgniteInternalFuture<IgniteInternalTx> commitTxAsync(GridNearTxLocal tx) { GridCacheContext ctx = tx.txState().singleCacheContext(this); if (ctx == null) { tx.txState().awaitLastFuture(this); return tx.commitNearTxLocalAsync(); } else return ctx.cache().commitTxAsync(tx); }
/** * @param awaitLastFuture If true - method will wait until transaction finish every action started before. * @throws IgniteCheckedException If failed. */ public final void prepare(boolean awaitLastFuture) throws IgniteCheckedException { if (awaitLastFuture) txState().awaitLastFuture(cctx); prepareNearTxLocal().get(); }
/** * @param tx Transaction to close. * @throws IgniteCheckedException If failed. */ public void endTx(GridNearTxLocal tx) throws IgniteCheckedException { boolean clearThreadMap = txMgr.threadLocalTx(null) == tx; if (clearThreadMap) tx.txState().awaitLastFuture(this); else tx.state(MARKED_ROLLBACK); tx.close(clearThreadMap); }
/** * @param tx Transaction to rollback. * @throws IgniteCheckedException If failed. * @return Rollback future. */ public IgniteInternalFuture rollbackTxAsync(GridNearTxLocal tx) throws IgniteCheckedException { boolean clearThreadMap = txMgr.threadLocalTx(null) == tx; if (clearThreadMap) tx.txState().awaitLastFuture(this); else tx.state(MARKED_ROLLBACK); return tx.rollbackNearTxLocalAsync(clearThreadMap, false); }
final GridNearTxPrepareRequest req ) { req.txState(locTx.txState());
tx.txState().onTxEnd(cctx, tx, commit);
IgniteCheckedException err = tx.txState().validateTopology( cctx, tx.writeMap().isEmpty(),
req.txState(locTx.txState());
txNodes.size() == 1, tx.activeCachesDeploymentEnabled(), tx.txState().recovery());
assert !tx.implicitSingle() || tx.txState().mvccEnabled(); // Non-mvcc implicit-single tx goes fast commit way. if (tx.txState().mvccEnabled()) { Collection<GridDistributedTxMapping> mvccMappings = tx.implicitSingle() ? Collections.singleton(tx.mappings().singleMapping()) : tx.mappings().mappings();
true, tx.activeCachesDeploymentEnabled(), tx.txState().recovery());
true, tx.activeCachesDeploymentEnabled(), tx.txState().recovery());
/** * Releases topology read lock. */ protected final void topologyReadUnlock() { tx.txState().topologyReadUnlock(cctx); }
/** * Resume transaction if it was previously suspended. * * @param tx Transaction to resume. * @throws IgniteCheckedException If resume failed. */ public void resumeTx(GridNearTxLocal tx) throws IgniteCheckedException { tx.txState().awaitLastFuture(this); tx.resume(); }