Search in sources :

Example 6 with UidWrapper

use of com.arjuna.ats.arjuna.tools.osb.mbean.UidWrapper in project narayana by jbosstm.

the class NewTypeTest method testInstrumentNewType.

@Test
public void testInstrumentNewType() throws MBeanException {
    OSBTypeHandler osbTypeHandler = new OSBTypeHandler(true, "com.arjuna.ats.internal.jta.tools.osb.mbean.jts.ArjunaTransactionImpleWrapper", "com.arjuna.ats.internal.jta.tools.osb.mbean.jts.JTSActionBean", "StateManager/BasicAction/TwoPhaseCoordinator/ArjunaTransactionImple/ServerTransaction/JCA", JCAServerTransactionHeaderReader.class.getName());
    JCAServerTransactionHeaderReader headerStateReader = (JCAServerTransactionHeaderReader) osbTypeHandler.getHeaderStateReader();
    // , new XidImple(new Uid()))
    RecoveringSubordinateServerTransaction txn = new RecoveringSubordinateServerTransaction(new Uid());
    ObjStoreBrowser osb = createObjStoreBrowser(false);
    osb.registerHandler(osbTypeHandler);
    generatedHeuristicHazard(txn);
    osb.probe();
    UidWrapper w = osb.findUid(txn.get_uid());
    assertNotNull(w);
    assertTrue(headerStateReader.isWasInvoked());
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) JCAServerTransactionHeaderReader(com.arjuna.ats.internal.jta.tools.osb.mbean.jts.JCAServerTransactionHeaderReader) OSBTypeHandler(com.arjuna.ats.arjuna.tools.osb.mbean.OSBTypeHandler) UidWrapper(com.arjuna.ats.arjuna.tools.osb.mbean.UidWrapper) ObjStoreBrowser(com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBrowser) Test(org.junit.Test)

Example 7 with UidWrapper

use of com.arjuna.ats.arjuna.tools.osb.mbean.UidWrapper in project narayana by jbosstm.

the class ObjStoreBrowserTest method getTransactionBean.

private JTAActionBean getTransactionBean(ObjStoreBrowser osb, TransactionImple tx, boolean present) {
    // there should be one MBean corresponding to the Transaction tx
    UidWrapper w = osb.findUid(tx.get_uid());
    if (!present) {
        assertNull(w);
        return null;
    }
    assertNotNull(w);
    OSEntryBean ai = w.getMBean();
    assertNotNull(ai);
    // the MBean should wrap a JTAActionBean
    assertTrue(ai instanceof JTAActionBean);
    return (JTAActionBean) ai;
}
Also used : OSEntryBean(com.arjuna.ats.arjuna.tools.osb.mbean.OSEntryBean) UidWrapper(com.arjuna.ats.arjuna.tools.osb.mbean.UidWrapper) JTAActionBean(com.arjuna.ats.internal.jta.tools.osb.mbean.jta.JTAActionBean)

Example 8 with UidWrapper

use of com.arjuna.ats.arjuna.tools.osb.mbean.UidWrapper in project narayana by jbosstm.

the class JTSXARTest method validateChildBeans.

private Set<UidWrapper> validateChildBeans(ObjStoreBrowser osb, String name, int expectedNumberOfChildBeans, int expectedXAE) throws MalformedObjectNameException, ReflectionException, InstanceNotFoundException, AttributeNotFoundException, MBeanException {
    MBeanServer mbs = JMXServer.getAgent().getServer();
    ObjectName txnON = new ObjectName(name);
    Object aid = mbs.getAttribute(txnON, "Id");
    assertNotNull(aid);
    Uid uidOfTxn = new Uid(aid.toString());
    Set<ObjectName> participants = mbs.queryNames(new ObjectName(name + ",puid=*"), null);
    assertEquals(expectedNumberOfChildBeans, participants.size());
    Set<UidWrapper> wrappers = new HashSet<UidWrapper>();
    for (ObjectName on : participants) {
        // mbs.getAttributes(on, new String[] {"Id", "Type", "Status", "HeuristicStatus", "FormatId", "GlobalTransactionId", "NodeName", "BranchQualifier"});
        AttributeList al = mbs.getAttributes(on, new String[] { "Id", "Status", "HeuristicStatus", "GlobalTransactionId" });
        for (Attribute a : al.asList()) {
            if ("Id".equals(a.getName())) {
                Uid uid = new Uid(a.getValue().toString());
                UidWrapper w = osb.findUid(uid);
                // assert that the wrapper is in the mbean wrapper cache
                assertNotNull(w);
                wrappers.add(w);
            } else if ("GlobalTransactionId".equals(a.getName())) {
                byte[] gtid = (byte[]) a.getValue();
                Uid txOfXar = new Uid(gtid);
                // assert that the gtid of the participant matches the parent action
                assertEquals(txOfXar, uidOfTxn);
            } else if ("HeuristicStatus".equals(a.getName())) {
                HeuristicStatus hs = HeuristicStatus.valueOf(a.getValue().toString());
                // assert that the instrumented heuristic status has the expected value
                assertEquals(hs.getXAErrorCode(), expectedXAE);
            }
        }
    }
    return wrappers;
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) HeuristicStatus(com.arjuna.ats.arjuna.tools.osb.mbean.HeuristicStatus) UidWrapper(com.arjuna.ats.arjuna.tools.osb.mbean.UidWrapper) HashSet(java.util.HashSet)

Aggregations

UidWrapper (com.arjuna.ats.arjuna.tools.osb.mbean.UidWrapper)8 OSEntryBean (com.arjuna.ats.arjuna.tools.osb.mbean.OSEntryBean)5 ObjStoreBrowser (com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBrowser)5 Uid (com.arjuna.ats.arjuna.common.Uid)4 ActionBean (com.arjuna.ats.arjuna.tools.osb.mbean.ActionBean)2 LogRecordWrapper (com.arjuna.ats.arjuna.tools.osb.mbean.LogRecordWrapper)2 JTAActionBean (com.arjuna.ats.internal.jta.tools.osb.mbean.jta.JTAActionBean)2 Test (org.junit.Test)2 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)1 AbstractRecord (com.arjuna.ats.arjuna.coordinator.AbstractRecord)1 RecordTypeMap (com.arjuna.ats.arjuna.coordinator.abstractrecord.RecordTypeMap)1 HeuristicStatus (com.arjuna.ats.arjuna.tools.osb.mbean.HeuristicStatus)1 OSBTypeHandler (com.arjuna.ats.arjuna.tools.osb.mbean.OSBTypeHandler)1 JCAServerTransactionHeaderReader (com.arjuna.ats.internal.jta.tools.osb.mbean.jts.JCAServerTransactionHeaderReader)1 TransactionImple (com.arjuna.ats.internal.jta.transaction.jts.TransactionImple)1 TransactionManagerImple (com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple)1 CrashRecord (com.hp.mwtests.ts.arjuna.resources.CrashRecord)1 ExtendedCrashRecord (com.hp.mwtests.ts.jta.jts.common.ExtendedCrashRecord)1 HashSet (java.util.HashSet)1 DataSource (javax.sql.DataSource)1