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