Search in sources :

Example 1 with TransactionInfo

use of com.arjuna.ArjunaOTS.TransactionInfo in project narayana by jbosstm.

the class TransactionFactoryImple method getTransactionInfo.

/**
 * @return information on a specific transaction.
 * @since JTS 2.1.2.
 */
public TransactionInfo getTransactionInfo(Uid u) throws org.omg.CosTransactions.NoTransaction, SystemException {
    if (!u.valid())
        throw new BAD_PARAM(jtsLogger.i18NLogger.get_orbspecific_invaliduid() + " " + u);
    else {
        try {
            synchronized (ControlImple.allControls) {
                ControlImple ctx = (ControlImple) ControlImple.allControls.get(u);
                if (ctx != null) {
                    TransactionInfo info = new TransactionInfo();
                    info.currentDepth = ctx.getImplHandle().getHierarchy().depth();
                    TransactionReaper reaper = TransactionReaper.transactionReaper();
                    info.timeout = reaper.getTimeout(ctx);
                    info.numberOfThreads = ctx.getImplHandle().activeThreads();
                    return info;
                } else
                    throw new NoTransaction();
            }
        } catch (NoTransaction ex) {
            throw ex;
        } catch (Exception e) {
            e.printStackTrace();
            throw new UNKNOWN();
        }
    }
}
Also used : NoTransaction(org.omg.CosTransactions.NoTransaction) BAD_PARAM(org.omg.CORBA.BAD_PARAM) TransactionInfo(com.arjuna.ArjunaOTS.TransactionInfo) GlobalTransactionInfo(com.arjuna.ArjunaOTS.GlobalTransactionInfo) UNKNOWN(org.omg.CORBA.UNKNOWN) TransactionReaper(com.arjuna.ats.arjuna.coordinator.TransactionReaper) SystemException(org.omg.CORBA.SystemException) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException)

Example 2 with TransactionInfo

use of com.arjuna.ArjunaOTS.TransactionInfo in project narayana by jbosstm.

the class TransactionFactoryUnitTest method testInfo.

@Test
public void testInfo() throws Exception {
    TransactionFactoryImple factory = new TransactionFactoryImple("test");
    ControlImple tx = factory.createLocal(1000);
    TransactionInfo info = factory.getTransactionInfo(Utility.uidToOtid(tx.get_uid()));
    assertEquals(info.currentDepth, 1);
    assertEquals(info.timeout, 0);
    assertEquals(info.numberOfThreads, 0);
    try {
        tx.getImplHandle().rollback();
    } catch (final Throwable ex) {
    }
}
Also used : TransactionFactoryImple(com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple) TransactionInfo(com.arjuna.ArjunaOTS.TransactionInfo) GlobalTransactionInfo(com.arjuna.ArjunaOTS.GlobalTransactionInfo) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Aggregations

GlobalTransactionInfo (com.arjuna.ArjunaOTS.GlobalTransactionInfo)2 TransactionInfo (com.arjuna.ArjunaOTS.TransactionInfo)2 TransactionReaper (com.arjuna.ats.arjuna.coordinator.TransactionReaper)1 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)1 ControlImple (com.arjuna.ats.internal.jts.orbspecific.ControlImple)1 TransactionFactoryImple (com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple)1 Test (org.junit.Test)1 BAD_PARAM (org.omg.CORBA.BAD_PARAM)1 SystemException (org.omg.CORBA.SystemException)1 UNKNOWN (org.omg.CORBA.UNKNOWN)1 NoTransaction (org.omg.CosTransactions.NoTransaction)1