Search in sources :

Example 1 with GlobalTransactionInfo

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

the class TransactionFactoryImple method getGlobalInfo.

/*
	 * @return information on the transactions known by this object.
	 * 
	 * @since JTS 2.1.
	 */
public GlobalTransactionInfo getGlobalInfo() throws SystemException {
    GlobalTransactionInfo info = new GlobalTransactionInfo();
    info.totalNumberOfTransactions = (int) com.arjuna.ats.arjuna.coordinator.TxStats.getInstance().getNumberOfTransactions();
    info.numberOfCommittedTransactions = (int) com.arjuna.ats.arjuna.coordinator.TxStats.getInstance().getNumberOfCommittedTransactions();
    info.numberOfAbortedTransactions = (int) com.arjuna.ats.arjuna.coordinator.TxStats.getInstance().getNumberOfAbortedTransactions();
    if (info.totalNumberOfTransactions > 0)
        info.averageLifetime = (float) (TransactionReaper.transactionLifetime() / info.totalNumberOfTransactions);
    else
        info.averageLifetime = (float) 0.0;
    info.numberOfHeuristics = (int) com.arjuna.ats.arjuna.coordinator.TxStats.getInstance().getNumberOfHeuristics();
    TransactionReaper reaper = TransactionReaper.transactionReaper();
    if (reaper.checkingPeriod() == Long.MAX_VALUE)
        info.reaperTimeout = 0;
    else
        info.reaperTimeout = (int) reaper.checkingPeriod();
    info.defaultTimeout = TxControl.getDefaultTimeout();
    return info;
}
Also used : TransactionReaper(com.arjuna.ats.arjuna.coordinator.TransactionReaper) GlobalTransactionInfo(com.arjuna.ArjunaOTS.GlobalTransactionInfo)

Example 2 with GlobalTransactionInfo

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

the class TransactionFactoryUnitTest method testBasic.

@Test
public void testBasic() throws Exception {
    TransactionFactoryImple factory = new TransactionFactoryImple("test");
    arjPropertyManager.getCoordinatorEnvironmentBean().setEnableStatistics(true);
    try {
        factory.numberOfTransactions(TransactionType.TransactionTypeActive);
    // fail();
    } catch (final Inactive ex) {
    } catch (final NoTransaction ex) {
    }
    ControlImple tx = factory.createLocal(1000);
    assertTrue(tx != null);
    org.omg.CosTransactions.otid_t[] txId = null;
    try {
        txId = factory.numberOfTransactions(TransactionType.TransactionTypeActive);
    } catch (final Throwable ex) {
        fail();
    }
    try {
        if (factory.getChildTransactions(txId[0]) != null)
            fail();
    } catch (final Throwable ex) {
        fail();
    }
    org.omg.CosTransactions.Status status = factory.getCurrentStatus(txId[0]);
    assertTrue(status == org.omg.CosTransactions.Status.StatusActive);
    assertTrue(factory.getStatus(txId[0]) == org.omg.CosTransactions.Status.StatusActive);
    Control proxy = factory.createProxy(tx.get_coordinator(), tx.get_terminator());
    assertTrue(proxy != null);
    Control propagated = factory.createPropagatedControl(tx.get_coordinator());
    assertTrue(propagated != null);
    assertTrue(Utility.getUid(proxy).equals(Utility.getUid(propagated)));
    GlobalTransactionInfo info = factory.getGlobalInfo();
    assertTrue(info != null);
    assertEquals(info.totalNumberOfTransactions, 1);
    assertEquals(info.numberOfHeuristics, 0);
    factory.numberOfTransactions(TransactionType.TransactionTypeUnresolved);
    try {
        tx.getImplHandle().rollback();
    } catch (final Throwable ex) {
    }
}
Also used : NoTransaction(org.omg.CosTransactions.NoTransaction) CosTransactions.otid_t(org.omg.CosTransactions.otid_t) GlobalTransactionInfo(com.arjuna.ArjunaOTS.GlobalTransactionInfo) Control(org.omg.CosTransactions.Control) TransactionFactoryImple(com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple) Status(org.omg.CosTransactions.Status) Inactive(org.omg.CosTransactions.Inactive) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Aggregations

GlobalTransactionInfo (com.arjuna.ArjunaOTS.GlobalTransactionInfo)2 TransactionReaper (com.arjuna.ats.arjuna.coordinator.TransactionReaper)1 ControlImple (com.arjuna.ats.internal.jts.orbspecific.ControlImple)1 TransactionFactoryImple (com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple)1 Test (org.junit.Test)1 Control (org.omg.CosTransactions.Control)1 Inactive (org.omg.CosTransactions.Inactive)1 NoTransaction (org.omg.CosTransactions.NoTransaction)1 Status (org.omg.CosTransactions.Status)1 CosTransactions.otid_t (org.omg.CosTransactions.otid_t)1