use of com.arjuna.ats.arjuna.tools.osb.mbean.HeuristicStatus 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