public void setDistributed(boolean flag) { checkClosed(); TXStateProxy tx = getTXState(); // Check whether given flag and current flag are different and whether a transaction is in progress if (tx != null && flag != isDistributed()) { // Cannot change mode in the middle of a transaction throw new java.lang.IllegalStateException( LocalizedStrings.TXManagerImpl_CANNOT_CHANGE_TRANSACTION_MODE_WHILE_TRANSACTIONS_ARE_IN_PROGRESS .toLocalizedString()); } else { isTXDistributed.set(new Boolean(flag)); } }
public void precommit() throws CommitConflictException { checkClosed(); final TXStateProxy tx = getTXState(); if (tx == null) { throw new IllegalStateException(LocalizedStrings.TXManagerImpl_THREAD_DOES_NOT_HAVE_AN_ACTIVE_TRANSACTION.toLocalizedString()); } tx.checkJTA(LocalizedStrings.TXManagerImpl_CAN_NOT_COMMIT_THIS_TRANSACTION_BECAUSE_IT_IS_ENLISTED_WITH_A_JTA_TRANSACTION_USE_THE_JTA_MANAGER_TO_PERFORM_THE_COMMIT.toLocalizedString()); tx.precommit(); }
/** Build a new {@link TXId}, use it as part of the transaction * state and associate with the current thread using a {@link * ThreadLocal}. */ public void begin() { checkClosed(); { TransactionId tid = getTransactionId(); if (tid != null) { throw new java.lang.IllegalStateException(LocalizedStrings.TXManagerImpl_TRANSACTION_0_ALREADY_IN_PROGRESS.toLocalizedString(tid)); } } TXId id = new TXId(this.distributionMgrId, this.uniqId.incrementAndGet()); TXStateProxyImpl proxy = null; if (isDistributed()) { proxy = new DistTXStateProxyImplOnCoordinator(this, id, null); } else { proxy = new TXStateProxyImpl(this, id, null); } setTXState(proxy); this.localTxMap.put(id, proxy); }
/** Build a new {@link TXId}, use it as part of the transaction * state and associate with the current thread using a {@link * ThreadLocal}. Flag the transaction to be enlisted with a JTA * Transaction. Should only be called in a context where we know * there is no existing transaction. */ public TXStateProxy beginJTA() { checkClosed(); final TXContext context = getOrCreateTXContext(); final TXId txId = TXId.newTXId(this.cache); final TXStateProxy txState = this.hostedTXStates.create(txId, txStateJTACreator, IsolationLevel.DEFAULT, null, false); context.setTXState(txState); return txState; }
/** Build a new {@link TXId}, use it as part of the transaction * state and associate with the current thread using a {@link * ThreadLocal}. Flag the transaction to be enlisted with a JTA * Transaction. Should only be called in a context where we know * there is no existing transaction. */ public TXStateProxy beginJTA() { checkClosed(); TXId id = new TXId(this.distributionMgrId, this.uniqId.incrementAndGet()); TXStateProxy newState = null; if (isDistributed()) { newState = new DistTXStateProxyImplOnCoordinator(this, id, true); } else { newState = new TXStateProxyImpl(this, id, true); } setTXState(newState); return newState; }
public final TXStateProxy resumeTX(final TXManagerImpl.TXContext context, final IsolationLevel isolationLevel, final EnumSet<TransactionFlag> txFlags, TXId txid) { checkClosed(); TXId txId = context.getTXId(); context.remoteBatching(false); if (txId != null) { throw new IllegalTransactionStateException( LocalizedStrings.TXManagerImpl_TRANSACTION_0_ALREADY_IN_PROGRESS .toLocalizedString(txId)); } txId = txid; // Do we have a proxy here TXStateProxy txState = this.hostedTXStates.get(txId); if (txState != null) { return txState; } txState = this.hostedTXStates.create(txId, txStateProxyCreator, isolationLevel, txFlags, false); // context.setTXState(txState); return txState; }
/** Roll back the transaction associated with the current * thread. When this method completes, the thread is no longer * associated with a transaction. */ public void rollback() { checkClosed(); TXStateProxy tx = getTXState(); if (tx == null) { throw new IllegalStateException(LocalizedStrings.TXManagerImpl_THREAD_DOES_NOT_HAVE_AN_ACTIVE_TRANSACTION.toLocalizedString()); } tx.checkJTA(LocalizedStrings.TXManagerImpl_CAN_NOT_ROLLBACK_THIS_TRANSACTION_IS_ENLISTED_WITH_A_JTA_TRANSACTION_USE_THE_JTA_MANAGER_TO_PERFORM_THE_ROLLBACK.toLocalizedString()); final long opStart = CachePerfStats.getStatTime(); final long lifeTime = opStart - tx.getBeginTime(); setTXState(null); tx.rollback(); saveTXStateForClientFailover(tx); cleanup(tx.getTransactionId()); noteRollbackSuccess(opStart, lifeTime, tx); }
public final TXStateProxy beginTX(final TXManagerImpl.TXContext context, final IsolationLevel isolationLevel, final EnumSet<TransactionFlag> txFlags, TXId nextTxID) { checkClosed(); TXId txId = context.getTXId(); if (txId != null) { throw new IllegalTransactionStateException( LocalizedStrings.TXManagerImpl_TRANSACTION_0_ALREADY_IN_PROGRESS .toLocalizedString(txId)); } if (nextTxID != null) { txId = nextTxID; } else { txId = TXId.newTXId(this.cache); } final TXStateProxy txState = this.hostedTXStates.create(txId, txStateProxyCreator, isolationLevel, txFlags, false); context.setTXState(txState); // For snapshot isolation, create tx state at the beginning if (txState.isSnapshot()) { txState.getTXStateForRead(); context.setSnapshotTXState(txState); } return txState; }
/** * Roll back the transaction associated with the current thread. When this * method completes, the thread is no longer associated with a transaction. */ public final void rollback(final TXStateInterface tx, Object callbackArg, final boolean isRemoteRollback) { checkClosed(); if (tx == null) { throw new IllegalTransactionStateException(LocalizedStrings .TXManagerImpl_THREAD_DOES_NOT_HAVE_AN_ACTIVE_TRANSACTION .toLocalizedString()); } if (tx.isJTA()) { throw new IllegalTransactionStateException(LocalizedStrings .TXManagerImpl_CAN_NOT_ROLLBACK_THIS_TRANSACTION_IS_ENLISTED_WITH_A_JTA_TRANSACTION_USE_THE_JTA_MANAGER_TO_PERFORM_THE_ROLLBACK .toLocalizedString()); } final long opStart = CachePerfStats.getStatTime(); final long lifeTime = opStart - tx.getBeginTime(); TXManagerImpl.TXContext context = TXManagerImpl.currentTXContext(); if (context != null) { context.clearTXStateAll(); } tx.rollback(callbackArg); noteRollbackSuccess(opStart, lifeTime, tx, isRemoteRollback); }
final int commitPhase, TXContext ctx, boolean isRemoteCommit) throws TransactionException { checkClosed();