/** * Start the transaction running. * * If the transaction is already running or has terminated, then an error * code will be returned. No timeout is associated with the transaction. * * @return <code>ActionStatus</code> indicating outcome. */ public int begin () { return begin(AtomicAction.NO_TIMEOUT); }
/** * Commit the transaction, and have heuristic reporting. Heuristic reporting * via the return code is enabled. * * @return <code>ActionStatus</code> indicating outcome. */ public int commit () { return commit(true); }
/** * Register the current thread with the transaction. This operation is not * affected by the state of the transaction. * * @return <code>true</code> if successful, <code>false</code> * otherwise. */ public boolean addThread () { return addThread(Thread.currentThread()); }
/** * Create a new transaction with the specified timeout. */ public TransactionImple(int timeout) { _theTransaction = new AtomicAction(); _theTransaction.begin(timeout); _resources = new Hashtable(); _duplicateResources = new Hashtable(); _suspendCount = 0; _xaTransactionTimeoutEnabled = getXATransactionTimeoutEnabled(); _txLocalResources = Collections.synchronizedMap(new HashMap()); }
switch (_theTransaction.status()) break; default: throw new IllegalStateException( jtaLogger.i18NLogger.get_transaction_arjunacore_inactive() ); if (!endSuspendedRMs()) _theTransaction.preventCommit(); int status = _theTransaction.end(true); TransactionImple.removeTransaction(this); break; case ActionStatus.H_MIXED: throw new javax.transaction.HeuristicMixedException(); case ActionStatus.H_HAZARD: throw new javax.transaction.HeuristicMixedException(); case ActionStatus.H_ROLLBACK: case ActionStatus.ABORTED: RollbackException rollbackException = new RollbackException( jtaLogger.i18NLogger.get_transaction_arjunacore_commitwhenaborted() ); if (_theTransaction.getDeferredThrowable() != null) rollbackException.initCause(_theTransaction .getDeferredThrowable()); throw new IllegalStateException( jtaLogger.i18NLogger.get_transaction_arjunacore_invalidstate() );
/** * @return the suspended transaction. */ public Transaction suspend() throws javax.transaction.SystemException { if (jtaLogger.logger.isTraceEnabled()) { jtaLogger.logger.trace("TransactionImpleManager.suspend"); } try { TransactionImple tx = TransactionImple.getTransaction(); if (tx != null) { tx.getAtomicAction().suspend(); } return tx; } catch (Exception e) { javax.transaction.SystemException systemException = new javax.transaction.SystemException(e.toString()); systemException.initCause(e); throw systemException; } }
void registerSynchronizationImple(SynchronizationImple synchronizationImple) throws javax.transaction.RollbackException, java.lang.IllegalStateException, javax.transaction.SystemException { if (_theTransaction != null) { if (_theTransaction.addSynchronization(synchronizationImple) != AddOutcome.AR_ADDED) { int status = _theTransaction.status(); switch (status) { case ActionStatus.ABORT_ONLY: case ActionStatus.ABORTED: throw new javax.transaction.RollbackException( jtaLogger.i18NLogger.get_transaction_arjunacore_syncwhenaborted() ); case ActionStatus.CREATED: throw new IllegalStateException( jtaLogger.i18NLogger.get_transaction_arjunacore_inactive(_theTransaction.get_uid()) ); default: throw new IllegalStateException( jtaLogger.i18NLogger.get_transaction_arjunacore_syncsnotallowed() + ActionStatus.stringForm(status)); } } } else throw new IllegalStateException( jtaLogger.i18NLogger.get_transaction_arjunacore_inactive() ); }
switch (_theTransaction.status()) _theTransaction.abort(); // assure thread disassociation throw addSuppressedThrowables(new javax.transaction.RollbackException( jtaLogger.i18NLogger.get_transaction_arjunacore_inactive(_theTransaction.get_uid()) )); _theTransaction.commit(true); // assure thread disassociation return; switch (_theTransaction.commit(true)) break; case ActionStatus.H_MIXED: throw addSuppressedThrowables(new javax.transaction.HeuristicMixedException()); case ActionStatus.H_HAZARD: throw addSuppressedThrowables(new javax.transaction.HeuristicMixedException()); case ActionStatus.H_ROLLBACK: case ActionStatus.ABORTED: case ActionStatus.ABORTING: RollbackException rollbackException = addSuppressedThrowables(new RollbackException( jtaLogger.i18NLogger.get_transaction_arjunacore_commitwhenaborted() )); rollbackException.initCause(preexistingRollbackOnlyCallerStacktrace); } else if(_theTransaction.getDeferredThrowable() != null) { rollbackException.initCause(_theTransaction.getDeferredThrowable()); } else if(_rollbackOnlyCallerStacktrace != null) { throw addSuppressedThrowables(new InvalidTerminationStateException( jtaLogger.i18NLogger.get_transaction_arjunacore_invalidstate() ));
if(_theTransaction.status() == ActionStatus.RUNNING || _theTransaction.status() == ActionStatus.ABORT_ONLY) { int outcome = _theTransaction.abort(); // assure thread disassociation, even if tx is already done. break; default: throw new InactiveTransactionException( jtaLogger.i18NLogger.get_transaction_arjunacore_rollbackstatus() + ActionStatus.stringForm(outcome)); throw new IllegalStateException( jtaLogger.i18NLogger.get_transaction_arjunacore_inactive() ); TransactionImple.removeTransaction(this);
if (_theTransaction.addSynchronization(synchronizationImple) != AddOutcome.AR_ADDED) int status = _theTransaction.status(); throw new javax.transaction.RollbackException( jtaLogger.logMesg .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.syncwhenaborted")); throw new IllegalStateException( jtaLogger.logMesg .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.syncsnotallowed")+ActionStatus.stringForm(status));
tsLogger.logger.debug("RecoverAtomicAction.replayPhase2 recovering "+get_uid()+" ActionStatus is "+ActionStatus.stringForm(_theStatus)); (_theStatus == ActionStatus.H_HAZARD) ) super.phase2Commit( _reportHeuristics ) ; (_theStatus == ActionStatus.ABORT_ONLY) ) super.phase2Abort( _reportHeuristics ) ; tsLogger.i18NLogger.warn_recovery_RecoverAtomicAction_2(ActionStatus.stringForm(_theStatus));
switch (_theTransaction.status()) break; default: throw new IllegalStateException( jtaLogger.i18NLogger.get_transaction_arjunacore_inactive() ); boolean endSuspendedFailed = !endSuspendedRMs(); jtaLogger.i18NLogger.warn_transaction_arjunacore_endsuspendfailed1(); int outcome = _theTransaction.cancel(); // use cancel of TransactionImple.removeTransaction(this); break; default: throw new IllegalStateException( jtaLogger.i18NLogger.get_transaction_arjunacore_rollbackstatus() + ActionStatus.stringForm(outcome));
public Void call() throws InvalidTransactionException, javax.transaction.RollbackException, javax.transaction.HeuristicMixedException, javax.transaction.HeuristicRollbackException, java.lang.SecurityException, javax.transaction.SystemException, java.lang.IllegalStateException { if (AtomicAction.suspend() != null) { System.err .println("WARNING - A PREVIOUS TRANSACTION WAS ON THE THREAD UNSUSPENDED"); } if (!AtomicAction.resume(theTransaction.getAtomicAction())) throw new InvalidTransactionException(); theTransaction.commitAndDisassociate(); return null; } });
public Future<Void> commitAsync() { final TransactionImple theTransaction = TransactionImple .getTransaction(); if (theTransaction == null) throw new IllegalStateException("BaseTransaction.commit - " + jtaLogger.i18NLogger.get_transaction_arjunacore_notx()); AtomicAction.suspend(); return wrap(new Callable<Void>() { public Void call() throws InvalidTransactionException, javax.transaction.RollbackException, javax.transaction.HeuristicMixedException, javax.transaction.HeuristicRollbackException, java.lang.SecurityException, javax.transaction.SystemException, java.lang.IllegalStateException { if (AtomicAction.suspend() != null) { System.err .println("WARNING - A PREVIOUS TRANSACTION WAS ON THE THREAD UNSUSPENDED"); } if (!AtomicAction.resume(theTransaction.getAtomicAction())) throw new InvalidTransactionException(); theTransaction.commitAndDisassociate(); return null; } }); }
super.setHeuristicDecision(TwoPhaseOutcome.FINISH_OK); super.updateState();
public STMVerticle () { transactionalObject = theContainer.create(new SampleLockable(10)); System.out.println("Object name: "+theContainer.getIdentifier(transactionalObject)); AtomicAction A = new AtomicAction(); /* * Flush state to disk (for this example). */ A.begin(); transactionalObject.increment(); A.commit(); }
public int getStatus() throws javax.transaction.SystemException { if (jtaLogger.logger.isTraceEnabled()) { jtaLogger.logger.trace("TransactionImple.getStatus"); } int status = javax.transaction.Status.STATUS_NO_TRANSACTION; if (_theTransaction != null) { return StatusConverter.convert(_theTransaction.status()); } return status; }
/** * Unregister the current thread from the transaction. This operation is not * affected by the state of the transaction. * * @return <code>true</code> if successful, <code>false</code> * otherwise. */ public boolean removeThread () { return removeThread(Thread.currentThread()); }
/** * Suspend all transaction association from the invoking thread. When this * operation returns, the thread will be associated with no transactions. * * If the current transaction is not an AtomicAction then this method will * not suspend. * * Note, we do not provide an async version of suspend because it would be * wrong for an application thread to proceed under the assumption it had * succeeded/happened yet. Ordering of events makes a difference here. * * @return a handle on the current AtomicAction (if any) so that the thread * can later resume association if required. * */ public static final Transaction suspend () { return new Transaction(AtomicAction.suspend()); }
protected void updateState () { if (_previous == null) super.savedIntentionList = false; super.updateState(); }