use of com.arjuna.ats.arjuna.tools.osb.mbean.LogRecordWrapper in project narayana by jbosstm.
the class ObjStoreBrowserTest method getHeuristicMBean.
private XAResourceRecordBeanMBean getHeuristicMBean(ObjStoreBrowser osb, TransactionImple tx, FailureXAResource failureXAResource) throws Exception {
generateHeuristic(tx, failureXAResource);
osb.probe();
// there should be one MBean corresponding to the Transaction
JTAActionBean actionBean = getTransactionBean(osb, tx, true);
assertNotNull(actionBean);
// and the transaction should contain only one participant (namely the FailureXAResource that generated the heuristic):
Collection<LogRecordWrapper> participants = actionBean.getParticipants();
assertEquals(1, participants.size());
assertNotNull(failureXAResource.getXid());
LogRecordWrapper participant = participants.iterator().next();
assertTrue(participant.isHeuristic());
assertTrue(participant instanceof XAResourceRecordBeanMBean);
return (XAResourceRecordBeanMBean) participant;
}
use of com.arjuna.ats.arjuna.tools.osb.mbean.LogRecordWrapper in project narayana by jbosstm.
the class ObjStoreBrowserTest method aaTest.
public void aaTest(boolean replay) throws Exception {
ObjStoreBrowser osb = createObjStoreBrowser();
AtomicAction A = new AtomicAction();
CrashRecord[] recs = { new CrashRecord(CrashRecord.CrashLocation.NoCrash, CrashRecord.CrashType.Normal), new CrashRecord(CrashRecord.CrashLocation.CrashInCommit, CrashRecord.CrashType.HeuristicHazard) };
// register CrashRecord record type so that it is persisted in the object store correctly
RecordTypeManager.manager().add(new RecordTypeMap() {
public Class<? extends AbstractRecord> getRecordClass() {
return CrashRecord.class;
}
public int getType() {
return RecordType.USER_DEF_FIRST0;
}
});
// create an atomic action, register crash records with it and then commit
A.begin();
for (CrashRecord rec : recs) A.add(rec);
int outcome = A.commit();
// the second participant should have generated a heuristic during commit
assertEquals(ActionStatus.H_HAZARD, outcome);
// generate MBeans representing the atomic action that was just committed
osb.start();
osb.probe();
// there should be one MBean corresponding to the AtomicAction A
UidWrapper w = osb.findUid(A.get_uid());
assertNotNull(w);
OSEntryBean ai = w.getMBean();
assertNotNull(ai);
// the MBean should wrap an ActionBean
assertTrue(ai instanceof ActionBean);
ActionBean actionBean = (ActionBean) ai;
// and there should be one MBean corresponding to the CrashRecord that got the heuristic:
int recCount = 0;
for (CrashRecord rec : recs) {
LogRecordWrapper lw = actionBean.getParticipant(rec);
if (lw != null) {
recCount += 1;
assertTrue(lw.isHeuristic());
// put the participant back onto the pending list
lw.setStatus("PREPARED");
// and check that the record is no longer in a heuristic state
assertFalse(lw.isHeuristic());
}
}
assertEquals(1, recCount);
if (!replay) {
actionBean.remove();
} else {
/*
* prompt the recovery manager to replay the record that was
* moved off the heuristic list and back onto the prepared list
*/
rcm.scan();
}
/*
* Since the recovery scan (or explicit remove request) will have successfully removed the record from
* the object store another probe should cause the MBean representing the record to be unregistered
*/
osb.probe();
// look up the MBean and verify that it no longer exists
w = osb.findUid(A.get_uid());
assertNull(w);
osb.dump(new StringBuilder());
osb.stop();
}
use of com.arjuna.ats.arjuna.tools.osb.mbean.LogRecordWrapper in project narayana by jbosstm.
the class ObjStoreBrowserTest method getHeuristicMBean.
private XAResourceRecordBeanMBean getHeuristicMBean(ObjStoreBrowser osb, TransactionImple tx, FailureXAResource failureXAResource) throws Exception {
generateHeuristic(tx, failureXAResource);
osb.probe();
// there should be one MBean corresponding to the Transaction
JTAActionBean actionBean = getTransactionBean(osb, tx, true);
assertNotNull(actionBean);
// and the transaction should contain only one participant (namely the FailureXAResource that generated the heuristic):
Collection<LogRecordWrapper> participants = actionBean.getParticipants();
assertEquals(1, participants.size());
assertNotNull(failureXAResource.getXid());
LogRecordWrapper participant = participants.iterator().next();
assertTrue(participant.isHeuristic());
assertTrue(participant instanceof XAResourceRecordBeanMBean);
return (XAResourceRecordBeanMBean) participant;
}
use of com.arjuna.ats.arjuna.tools.osb.mbean.LogRecordWrapper in project narayana by jbosstm.
the class JTSObjStoreBrowserTest method finishTest.
/*
* Make sure there is an MBean corresponding to A and that at least one of recs has a heuristic.
* Then either remove the action or replay (via the MBean) the record that got the heuristic
* checking that the MBeans have all been unregistered from the MBeanServer.
*/
private void finishTest(TwoPhaseCoordinator A, boolean replay, ExtendedCrashRecord... recs) throws Exception {
ObjStoreBrowser osb = createObjStoreBrowser(false);
// there should now be an entry in the object store containing two participants
osb.start();
osb.probe();
// there should be one MBean corresponding to the AtomicAction A
UidWrapper w = osb.findUid(A.get_uid());
assertNotNull(w);
OSEntryBean ai = w.getMBean();
assertNotNull(ai);
// the MBean should wrap an ActionBean
assertTrue(ai instanceof ActionBean);
ActionBean actionBean = (ActionBean) ai;
// and there should be one MBean corresponding to the CrashRecord that got the heuristic:
int recCount = 0;
for (ExtendedCrashRecord rec : recs) {
LogRecordWrapper lw = actionBean.getParticipant(rec);
if (lw != null) {
recCount += 1;
if (lw.isHeuristic()) {
if (replay) {
rec.forget();
lw.setStatus("PREPARED");
// the participant record should no longer be on the heuristic list
assertFalse(lw.isHeuristic());
}
}
}
}
assertEquals(1, recCount);
if (!replay) {
actionBean.remove();
} else {
/*
* prompt the recovery manager to have a go at replaying the record that was
* moved off the heuristic list and back onto the prepared list
*/
recoveryManager.scan();
}
// another probe should no longer find the record that got the heuristic
// (since it was either removed or the RecoveryManager replayed the commit
// phase) so its corresponding MBean will have been unregistered
osb.probe();
// look up the MBean and verify that it no longer exists
w = osb.findUid(A.get_uid());
assertNull(w);
osb.stop();
}
Aggregations