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;
}
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) {
}
}
Aggregations