Search in sources :

Example 6 with CurrentImple

use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.

the class AtomicTransaction method commit.

/*
	 * Commit the transaction. If the current transaction associated with the
	 * thread is not this transaction, then this transaction is rolled back and
	 * leave current alone.
	 * 
	 * @param report_heuristics indicates whether heuristic reporting is
	 * desired.
	 * 
	 * @exception org.omg.CosTransactions.NoTransaction if the transaction has
	 * already been terminated.
	 * 
	 * @exception org.omg.CORBA.TRANSACTION_ROLLEDBACK if the transaction rolls
	 * back.
	 * 
	 * @exception org.omg.CosTransactions.HeuristicMixed if some of the
	 * transaction participants committed, while some rolled back.
	 * 
	 * @exception org.omg.CosTransactions.HeuristicHazard if some of the
	 * transaction participants committed, some rolled back, and the outcome of
	 * others is indeterminate.
	 * 
	 * @exception org.omg.CORBA.WRONG_TRANSACTION if the current transaction is
	 * not this transaction.
	 */
public void commit(boolean report_heuristics) throws NoTransaction, HeuristicMixed, HeuristicHazard, WrongTransaction, SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("AtomicTransaction::commit ( " + report_heuristics + " ) for " + _theAction);
    }
    synchronized (_theStatus) {
        if (_theAction == null) {
            throw new NoTransaction();
        }
    }
    if (!validTransaction()) {
        throw new WrongTransaction();
    }
    /*
		 * OK to use current since we have just guaranteed that the transaction
		 * is the same as current. Use current rather than saved control since
		 * it will do thread tracking for us.
		 */
    CurrentImple current = OTSImpleManager.current();
    try {
        current.commit(report_heuristics);
        _theStatus = Status.StatusCommitted;
    } catch (NoTransaction e) {
        _theStatus = Status.StatusNoTransaction;
        throw e;
    } catch (HeuristicMixed e) {
        _theStatus = getStatus();
        throw e;
    } catch (HeuristicHazard e) {
        _theStatus = getStatus();
        throw e;
    } catch (TRANSACTION_ROLLEDBACK e) {
        _theStatus = Status.StatusRolledBack;
        throw e;
    } catch (SystemException e) {
        _theStatus = getStatus();
        throw e;
    }
}
Also used : NoTransaction(org.omg.CosTransactions.NoTransaction) WrongTransaction(org.omg.CORBA.WrongTransaction) SystemException(org.omg.CORBA.SystemException) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) HeuristicMixed(org.omg.CosTransactions.HeuristicMixed) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK) HeuristicHazard(org.omg.CosTransactions.HeuristicHazard)

Example 7 with CurrentImple

use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.

the class AtomicTransaction method rollback.

/*
	 * Rollback the transaction. If the current transaction associated with the
	 * thread is not this transaction, then this transaction is rolled back and
	 * leave current alone.
	 * 
	 * @exception org.omg.CosTransactions.NoTransaction if the transaction has
	 * already been terminated.
	 * 
	 * @exception org.omg.CORBA.WRONG_TRANSACTION if the current transaction is
	 * not this transaction.
	 */
public void rollback() throws NoTransaction, WrongTransaction, SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("AtomicTransaction::rollback for " + _theAction);
    }
    synchronized (_theStatus) {
        if (_theAction == null) {
            throw new NoTransaction();
        }
    }
    if (!validTransaction()) {
        throw new WrongTransaction();
    }
    /*
		 * OK to use current since we have just guaranteed that the transaction
		 * is the same as current. Use current rather than saved control since
		 * it will do thread tracking for us.
		 */
    CurrentImple current = OTSImpleManager.current();
    try {
        current.rollback();
        _theStatus = Status.StatusRolledBack;
    } catch (NoTransaction e) {
        _theStatus = Status.StatusNoTransaction;
        throw e;
    } catch (TRANSACTION_ROLLEDBACK e) {
        _theStatus = Status.StatusRolledBack;
    } catch (SystemException e) {
        _theStatus = getStatus();
        throw e;
    }
}
Also used : NoTransaction(org.omg.CosTransactions.NoTransaction) WrongTransaction(org.omg.CORBA.WrongTransaction) SystemException(org.omg.CORBA.SystemException) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK)

Example 8 with CurrentImple

use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.

the class AtomicTransaction method begin.

/**
 * Start the transaction.
 *
 * @exception org.omg.CosTransactions.SubtransactionsUnavailable
 *                if subtransactions have been disabled, and the invoking
 *                thread already has a transaction associated with it.
 *
 * @exception org.omg.CORBA.INVALID_TRANSACTION
 *                if the transaction has already begun or has completed.
 */
public void begin() throws SubtransactionsUnavailable, SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("AtomicTransaction::begin ()");
    }
    // already begun?
    CurrentImple current = OTSImpleManager.current();
    synchronized (_theStatus) {
        if (_theAction != null) {
            throw new INVALID_TRANSACTION(ExceptionCodes.ALREADY_BEGUN, CompletionStatus.COMPLETED_NO);
        }
        current.begin();
        _theAction = current.getControlWrapper();
    }
    _theStatus = current.get_status();
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("AtomicTransaction::begin create " + _theAction);
    }
}
Also used : INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple)

Example 9 with CurrentImple

use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.

the class OTSThread method terminate.

/*
     * Can't use finalize since it may be called by
     * some other thread than this one.
     */
public void terminate() {
    try {
        CurrentImple current = OTSImpleManager.current();
        if (current != null) {
            Control c = current.suspend();
            c = null;
        }
    } catch (Exception e) {
    }
}
Also used : Control(org.omg.CosTransactions.Control) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple)

Example 10 with CurrentImple

use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.

the class tx method tx_commit.

public static final synchronized int tx_commit() {
    int toReturn = tx.TX_OK;
    CurrentImple current = OTSImpleManager.current();
    Boolean report_heuristics = (Boolean) __tx_report_heuristics.get(Thread.currentThread());
    if (report_heuristics == null)
        // default TRUE
        report_heuristics = new Boolean(true);
    try {
        boolean when_return = report_heuristics.booleanValue();
        current.commit(when_return);
    } catch (NoTransaction e1) {
        toReturn = tx.TX_NO_BEGIN;
    } catch (HeuristicMixed e2) {
        toReturn = tx.TX_HAZARD;
    } catch (HeuristicHazard e3) {
        toReturn = tx.TX_HAZARD;
    } catch (TRANSACTION_ROLLEDBACK e4) {
        toReturn = tx.TX_ROLLBACK;
    } catch (Exception e5) {
        toReturn = tx.TX_FAIL;
    }
    return toReturn;
}
Also used : NoTransaction(org.omg.CosTransactions.NoTransaction) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) HeuristicMixed(org.omg.CosTransactions.HeuristicMixed) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK) HeuristicHazard(org.omg.CosTransactions.HeuristicHazard)

Aggregations

CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)47 Control (org.omg.CosTransactions.Control)14 SystemException (org.omg.CORBA.SystemException)12 ORB (com.arjuna.orbportability.ORB)9 RootOA (com.arjuna.orbportability.RootOA)9 IOException (java.io.IOException)7 Lock (com.arjuna.ats.txoj.Lock)6 ServerORB (com.hp.mwtests.ts.jts.utils.ServerORB)6 Coordinator (org.omg.CosTransactions.Coordinator)6 Services (com.arjuna.orbportability.Services)5 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)5 ExplicitInterposition (com.arjuna.ats.jts.ExplicitInterposition)4 Test (org.junit.Test)4 TransactionFactoryImple (com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple)3 TestException (com.hp.mwtests.ts.jts.exceptions.TestException)3 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)3 NoTransaction (org.omg.CosTransactions.NoTransaction)3 InterpositionFailed (com.arjuna.ArjunaOTS.InterpositionFailed)2 FatalError (com.arjuna.ats.arjuna.exceptions.FatalError)2 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)2