Search in sources :

Example 1 with ExtendedCrashRecord

use of com.hp.mwtests.ts.jta.jts.common.ExtendedCrashRecord in project narayana by jbosstm.

the class JTSOSBTestBase method generatedHeuristicHazard.

/**
 * Generate a transaction log that contains a heuristic hazard
 * @param txn a transaction of the desired type
 * @return the number of participants that that will have generated a heuristic hazard
 */
protected int generatedHeuristicHazard(ArjunaTransactionImple txn) {
    ThreadActionData.purgeActions();
    ExtendedCrashRecord[] recs = { new ExtendedCrashRecord(ExtendedCrashRecord.CrashLocation.NoCrash, ExtendedCrashRecord.CrashType.Normal), new ExtendedCrashRecord(ExtendedCrashRecord.CrashLocation.CrashInCommit, ExtendedCrashRecord.CrashType.HeuristicHazard) };
    txn.start();
    for (ExtendedCrashRecord rec : recs) txn.add(rec);
    txn.end(true);
    return 1;
}
Also used : ExtendedCrashRecord(com.hp.mwtests.ts.jta.jts.common.ExtendedCrashRecord)

Example 2 with ExtendedCrashRecord

use of com.hp.mwtests.ts.jta.jts.common.ExtendedCrashRecord in project narayana by jbosstm.

the class JTSObjStoreBrowserTest method jtsReplayTest.

/**
 * Similar to aaReplayTest but uses a JTS transaction instead of an AtomicAction
 * @throws Exception if test fails unexpectedly
 */
// TODO for replay to work on JTS participants ExtendedCrashReocrd needs to extend XAResourceRecord
// TODO @Test
public void jtsReplayTest() throws Exception {
    ArjunaTransactionImple A = new ArjunaTransactionImple(null);
    ExtendedCrashRecord[] recs = startTest(A);
    int outcome = ActionStatus.COMMITTED;
    try {
        A.commit(true);
    } catch (HeuristicHazard e) {
        outcome = ActionStatus.H_HAZARD;
    }
    assertEquals(ActionStatus.H_HAZARD, outcome);
    finishTest(A, true, recs);
}
Also used : ExtendedCrashRecord(com.hp.mwtests.ts.jta.jts.common.ExtendedCrashRecord) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) HeuristicHazard(org.omg.CosTransactions.HeuristicHazard)

Example 3 with ExtendedCrashRecord

use of com.hp.mwtests.ts.jta.jts.common.ExtendedCrashRecord 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();
}
Also used : ExtendedCrashRecord(com.hp.mwtests.ts.jta.jts.common.ExtendedCrashRecord) OSEntryBean(com.arjuna.ats.arjuna.tools.osb.mbean.OSEntryBean) UidWrapper(com.arjuna.ats.arjuna.tools.osb.mbean.UidWrapper) ObjStoreBrowser(com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBrowser) LogRecordWrapper(com.arjuna.ats.arjuna.tools.osb.mbean.LogRecordWrapper) ActionBean(com.arjuna.ats.arjuna.tools.osb.mbean.ActionBean)

Example 4 with ExtendedCrashRecord

use of com.hp.mwtests.ts.jta.jts.common.ExtendedCrashRecord in project narayana by jbosstm.

the class JTSObjStoreBrowserTest method aaRemoveTest.

/**
 * Similar to @aaReplayTest except that the whole transaction record is removed from the object store
 * (instead of replaying the record that generates a heuristic).
 * @throws Exception if test fails unexpectedly
 */
@Test
public void aaRemoveTest() throws Exception {
    AtomicAction A = new AtomicAction();
    ExtendedCrashRecord[] recs = startTest(A);
    int outcome = A.commit();
    assertEquals(ActionStatus.H_HAZARD, outcome);
    finishTest(A, false, recs);
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) ExtendedCrashRecord(com.hp.mwtests.ts.jta.jts.common.ExtendedCrashRecord) Test(org.junit.Test)

Example 5 with ExtendedCrashRecord

use of com.hp.mwtests.ts.jta.jts.common.ExtendedCrashRecord in project narayana by jbosstm.

the class JTSObjStoreBrowserTest method aaReplayTest.

/*
		 TODO JTS test-compile doesn't pull in com.arjuna.common.tests.simple
	@Test
	public void testXAResourceRecordBean() throws Exception {
		com.arjuna.common.tests.simple.EnvironmentBeanTest.testBeanByReflection(new XAResourceRecordBean(new UidWrapper(Uid.nullUid())));
	}
	*/
/**
 * Create an atomic action with two participants, one of which will generate a heuristic during phase 2.
 * The test will move the heuristic back into the prepared state and trigger recovery to replay phase 2.
 * The test then asserts that the corresponding MBeans have been unregistered.
 * @throws Exception if test fails unexpectedly
 */
@Test
public void aaReplayTest() throws Exception {
    AtomicAction A = new AtomicAction();
    ExtendedCrashRecord[] recs = startTest(A);
    int outcome = A.commit();
    assertEquals(ActionStatus.H_HAZARD, outcome);
    finishTest(A, true, recs);
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) ExtendedCrashRecord(com.hp.mwtests.ts.jta.jts.common.ExtendedCrashRecord) Test(org.junit.Test)

Aggregations

ExtendedCrashRecord (com.hp.mwtests.ts.jta.jts.common.ExtendedCrashRecord)7 Test (org.junit.Test)3 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)2 ArjunaTransactionImple (com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple)2 HeuristicHazard (org.omg.CosTransactions.HeuristicHazard)2 AbstractRecord (com.arjuna.ats.arjuna.coordinator.AbstractRecord)1 RecordTypeMap (com.arjuna.ats.arjuna.coordinator.abstractrecord.RecordTypeMap)1 ActionBean (com.arjuna.ats.arjuna.tools.osb.mbean.ActionBean)1 LogRecordWrapper (com.arjuna.ats.arjuna.tools.osb.mbean.LogRecordWrapper)1 OSEntryBean (com.arjuna.ats.arjuna.tools.osb.mbean.OSEntryBean)1 ObjStoreBrowser (com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBrowser)1 UidWrapper (com.arjuna.ats.arjuna.tools.osb.mbean.UidWrapper)1 AfterClass (org.junit.AfterClass)1 BeforeClass (org.junit.BeforeClass)1