Search in sources :

Example 1 with TransactionImple

use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.

the class JtsTransactionImple method getTransactionIOR.

/**
 * If the current transaction represents an OTS transaction then return it IOR
 *
 * @return the IOR or null if the current transaction is not an OTS transaction
 * @throws NamingException
 * @throws org.omg.CORBA.SystemException
 * @throws SystemException
 * @throws Unavailable
 */
public static String getTransactionIOR() throws org.omg.CORBA.SystemException, SystemException, Unavailable {
    log.debug("getTransactionIOR");
    TransactionImpl curr = TransactionImpl.current();
    if (curr != null) {
        log.debug("have JtsTransactionImple");
        return curr.getControlIOR();
    } else if (hasTransaction()) {
        log.debug("have tx mgr");
        Transaction tx = tm.getTransaction();
        log.debug("have arjuna tx");
        TransactionImple atx = (TransactionImple) tx;
        ControlWrapper cw = atx.getControlWrapper();
        log.debug("lookup control");
        Control c = cw.get_control();
        String ior = ORBManager.getORB().orb().object_to_string(c);
        log.debug("getTransactionIOR: ior: " + ior);
        return ior;
    } else {
        return null;
    }
}
Also used : Control(org.omg.CosTransactions.Control) Transaction(javax.transaction.Transaction) AtomicTransaction(com.arjuna.ats.internal.jta.transaction.jts.AtomicTransaction) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) TransactionImpl(org.jboss.narayana.blacktie.jatmibroker.core.tx.TransactionImpl)

Example 2 with TransactionImple

use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.

the class ObjStoreBrowserTest method testMBeanHeuristic.

/**
 * Test that resources that generate heuristics are instrumented correctly
 * @throws Exception
 */
@Test
public void testMBeanHeuristic() throws Exception {
    // generates a heuristic on commit
    FailureXAResource failureXAResource = new FailureXAResource(FailureXAResource.FailLocation.commit);
    getHeuristicMBean(osb, new TransactionImple(), failureXAResource);
}
Also used : FailureXAResource(com.hp.mwtests.ts.jta.tools.FailureXAResource) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) Test(org.junit.Test)

Example 3 with TransactionImple

use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.

the class ObjStoreBrowserTest method getHeuristic.

private HeuristicTestData getHeuristic() throws Exception {
    // generates a heuristic on commit
    FailureXAResource failureXAResource = new FailureXAResource(FailureXAResource.FailLocation.commit);
    TransactionImple tx = new TransactionImple();
    XAResourceRecordBeanMBean resourceBean = getHeuristicMBean(osb, tx, failureXAResource);
    JTAActionBean txnMBean = getTransactionBean(osb, tx, true);
    Set<ObjectName> participants;
    String resourceBeanName;
    String txnBeanName;
    assertNotNull(txnMBean);
    assertNotNull(resourceBean);
    txnBeanName = String.format("jboss.jta:type=ObjectStore,itype=%s,uid=%s", txnMBean.type(), txnMBean.getId().replace(':', '_'));
    resourceBeanName = String.format("%s,puid=%s", txnBeanName, resourceBean.getId().replace(':', '_'));
    participants = JMXServer.getAgent().queryNames(resourceBeanName, null);
    assertEquals(1, participants.size());
    return new HeuristicTestData(tx, failureXAResource, txnMBean, resourceBean, participants.iterator().next(), txnBeanName, resourceBeanName);
}
Also used : XAResourceRecordBeanMBean(com.arjuna.ats.internal.jta.tools.osb.mbean.jts.XAResourceRecordBeanMBean) FailureXAResource(com.hp.mwtests.ts.jta.tools.FailureXAResource) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) JTAActionBean(com.arjuna.ats.internal.jta.tools.osb.mbean.jta.JTAActionBean) ObjectName(javax.management.ObjectName)

Example 4 with TransactionImple

use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.

the class TransactionImpleUnitTest method testEnlist.

@Test
public void testEnlist() throws Exception {
    ThreadActionData.purgeActions();
    OTSImpleManager.current().contextManager().purgeActions();
    TransactionImple tx = new TransactionImple();
    tx.setRollbackOnly();
    try {
        tx.enlistResource(null);
        fail();
    } catch (final SystemException ex) {
    }
    try {
        tx.enlistResource(new DummyXA(false));
        fail();
    } catch (final RollbackException ex) {
    }
    try {
        tx.commit();
        fail();
    } catch (final RollbackException ex) {
    }
    try {
        tx.enlistResource(new DummyXA(false));
        fail();
    } catch (final IllegalStateException ex) {
    }
    Control suspend = OTSImpleManager.current().suspend();
    tx = new TransactionImple();
    DummyXA res = new DummyXA(false);
    tx.enlistResource(res);
    tx.delistResource(res, XAResource.TMSUSPEND);
    tx.enlistResource(res);
    tx.commit();
}
Also used : Control(org.omg.CosTransactions.Control) DummyXA(com.hp.mwtests.ts.jta.jts.common.DummyXA) SystemException(javax.transaction.SystemException) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) RollbackException(javax.transaction.RollbackException) Test(org.junit.Test)

Example 5 with TransactionImple

use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.

the class TransactionImpleUnitTest method testDelist.

@Test
public void testDelist() throws Exception {
    ThreadActionData.purgeActions();
    OTSImpleManager.current().contextManager().purgeActions();
    TransactionImple tx = new TransactionImple();
    try {
        tx.delistResource(null, XAResource.TMSUCCESS);
        fail();
    } catch (final SystemException ex) {
    }
    DummyXA xares = new DummyXA(false);
    try {
        assertFalse(tx.delistResource(xares, XAResource.TMSUCCESS));
    } catch (final Throwable ex) {
        fail();
    }
    tx.enlistResource(xares);
    assertTrue(tx.delistResource(xares, XAResource.TMSUCCESS));
    tx.commit();
    try {
        tx.delistResource(xares, XAResource.TMSUCCESS);
        fail();
    } catch (final IllegalStateException ex) {
    }
}
Also used : DummyXA(com.hp.mwtests.ts.jta.jts.common.DummyXA) SystemException(javax.transaction.SystemException) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) Test(org.junit.Test)

Aggregations

TransactionImple (com.arjuna.ats.internal.jta.transaction.jts.TransactionImple)28 Test (org.junit.Test)23 DummyXA (com.hp.mwtests.ts.jta.jts.common.DummyXA)9 Uid (com.arjuna.ats.arjuna.common.Uid)7 XAResourceRecord (com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord)7 Transaction (javax.transaction.Transaction)5 XidImple (com.arjuna.ats.jta.xa.XidImple)4 DummyRecoverableXAConnection (com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection)4 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)3 FailureXAResource (com.hp.mwtests.ts.jta.common.FailureXAResource)3 Synchronization (javax.transaction.Synchronization)3 SystemException (javax.transaction.SystemException)3 WorkSynchronization (com.arjuna.ats.internal.jta.transaction.jts.jca.WorkSynchronization)2 FailureXAResource (com.hp.mwtests.ts.jta.tools.FailureXAResource)2 RollbackException (javax.transaction.RollbackException)2 XAException (javax.transaction.xa.XAException)2 Xid (javax.transaction.xa.Xid)2 Control (org.omg.CosTransactions.Control)2 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)1 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)1