Search in sources :

Example 1 with ArjunaTransactionImple

use of com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple in project narayana by jbosstm.

the class GenericRecoveryCreator method create.

/**
 * Create a new RecoveryCoordinator for Resource res. The params
 * array is used to pass additional data. Currently params[0] is
 * the ArjunaTransactionImple ref. When create returns additional data is
 * passed back using params. Currently returned params[0] is the
 * RecoveryCoordinator Uid.
 */
public RecoveryCoordinator create(Resource res, Object[] params) throws SystemException {
    RecoveryCoordinator recoveryCoordinator = null;
    if (jtsLogger.logger.isDebugEnabled()) {
        jtsLogger.logger.debug("GenericRecoveryCreator.create()");
    }
    // we dont use the res parameter in this version
    if ((params != null) && (params[0] != null)) {
        int index = 0;
        ArjunaTransactionImple otsTransaction = (ArjunaTransactionImple) params[index++];
        // Get the Uid of the top-level transaction. This will be
        // the top-level interposed transaction in the case of
        // interposition.
        BasicAction rootAction = otsTransaction;
        while ((rootAction.parent()) != null) rootAction = rootAction.parent();
        Uid rootActionUid = rootAction.getSavingUid();
        // Uid processUid = Utility.getProcessUid();
        Uid processUid = com.arjuna.ats.arjuna.utils.Utility.getProcessUid();
        // Create a Uid for the new RecoveryCoordinator
        Uid RCUid = new Uid();
        // Is this transaction a ServerTransaction?
        boolean isServerTransaction = (otsTransaction instanceof ServerTransaction);
        // Now ask the orb-specific bit to make the RecoveryCoordinator IOR
        // (it may or may not actually make the RC itself)
        recoveryCoordinator = _orbSpecificManager.makeRC(RCUid, rootActionUid, processUid, isServerTransaction);
        // Tidy up
        otsTransaction = null;
        rootAction = null;
        // Pass the RecoveryCoordinator Uid back
        params[0] = RCUid;
    } else {
        jtsLogger.i18NLogger.warn_recovery_recoverycoordinators_GenericRecoveryCreator_1();
    }
    return recoveryCoordinator;
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) BasicAction(com.arjuna.ats.arjuna.coordinator.BasicAction) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) RecoveryCoordinator(org.omg.CosTransactions.RecoveryCoordinator) ServerTransaction(com.arjuna.ats.internal.jts.orbspecific.interposition.coordinator.ServerTransaction)

Example 2 with ArjunaTransactionImple

use of com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple in project narayana by jbosstm.

the class ServerControlUnitTest method test.

@Test
public void test() throws Exception {
    ControlImple cont = new ControlImple(null, null);
    Control theControl = cont.getControl();
    ArjunaTransactionImple tx = cont.getImplHandle();
    ServerControl sc = new ServerControl(tx.get_uid(), theControl, tx, theControl.get_coordinator(), theControl.get_terminator());
    assertTrue(sc.isWrapper());
    assertTrue(sc.get_coordinator() != null);
    assertTrue(sc.get_terminator() != null);
    assertEquals(sc.getParentImple(), null);
    assertTrue(sc.forgetHeuristics());
    assertTrue(sc.toString() != null);
    sc.destroy();
}
Also used : Control(org.omg.CosTransactions.Control) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Example 3 with ArjunaTransactionImple

use of com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple in project narayana by jbosstm.

the class ServerNestedOSIActionUnitTest method testCommit.

@Test
public void testCommit() throws Exception {
    ControlImple cont = new ControlImple(null, null);
    Control theControl = cont.getControl();
    ArjunaTransactionImple tx = cont.getImplHandle();
    ServerControl sc = new ServerControl(tx.get_uid(), theControl, tx, theControl.get_coordinator(), theControl.get_terminator());
    ServerOSINestedAction act = new ServerOSINestedAction(sc, true);
    assertFalse(act.interposeResource());
    act.commit_subtransaction(null);
}
Also used : Control(org.omg.CosTransactions.Control) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) ServerOSINestedAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSINestedAction) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Example 4 with ArjunaTransactionImple

use of com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple in project narayana by jbosstm.

the class ServerFactory method create_subtransaction.

public static ServerControl create_subtransaction(Uid actUid, Coordinator realCoord, Terminator realTerm, ServerControl parent) {
    if (parent == null) {
        jtsLogger.i18NLogger.warn_interposition_sfnoparent("ServerFactory.create_subtransaction");
        return null;
    }
    ServerControl toReturn = null;
    try {
        Control handle = parent.getControl();
        ArjunaTransactionImple tranHandle = parent.getImplHandle();
        toReturn = new ServerControl(actUid, handle, tranHandle, realCoord, realTerm);
        handle = null;
        tranHandle = null;
    } catch (Exception e) {
        if (toReturn != null) {
            try {
                // will delete itself
                toReturn.destroy();
            } catch (Exception ex) {
            }
        }
    }
    return toReturn;
}
Also used : ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) Control(org.omg.CosTransactions.Control) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) SystemException(org.omg.CORBA.SystemException) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException)

Example 5 with ArjunaTransactionImple

use of com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple in project narayana by jbosstm.

the class HeuristicInformationTest method heuristicInformationTest.

@Test
public void heuristicInformationTest() throws Exception {
    ArjunaTransactionImple A = new ArjunaTransactionImple(null);
    int expectedHeuristic = TwoPhaseOutcome.HEURISTIC_ROLLBACK;
    ThreadActionData.purgeActions();
    UserExtendedCrashRecord[] recs = { new UserExtendedCrashRecord(UserExtendedCrashRecord.CrashLocation.NoCrash, UserExtendedCrashRecord.CrashType.Normal, null), new UserExtendedCrashRecord(UserExtendedCrashRecord.CrashLocation.CrashInCommit, UserExtendedCrashRecord.CrashType.HeuristicHazard, // this value will override HeuristicHazard
    new UserExtendedCrashRecord.HeuristicInformationOverride(expectedHeuristic)) };
    RecordTypeManager.manager().add(new RecordTypeMap() {

        public Class<? extends AbstractRecord> getRecordClass() {
            return UserExtendedCrashRecord.class;
        }

        public int getType() {
            return RecordType.USER_DEF_FIRST1;
        }
    });
    A.start();
    for (UserExtendedCrashRecord rec : recs) A.add(rec);
    try {
        A.commit(true);
        fail("transaction commit should have produced a heuristic hazard");
    } catch (HeuristicHazard e) {
    // expected
    }
    ObjStoreBrowser osb = getOSB();
    osb.start();
    osb.probe();
    // there should now be an MBean entry corresponding to a JTS record, read it via JMX:
    MBeanServer mbs = JMXServer.getAgent().getServer();
    UidWrapper w = osb.findUid(A.get_uid());
    ObjectName txnON = new ObjectName(w.getName());
    Object aid = mbs.getAttribute(txnON, "Id");
    assertNotNull(aid);
    Set<ObjectName> participants = mbs.queryNames(new ObjectName(w.getName() + ",puid=*"), null);
    for (ObjectName on : participants) {
        AttributeList al = mbs.getAttributes(on, new String[] { "Id", "Status", "HeuristicStatus", "GlobalTransactionId" });
        for (Attribute a : al.asList()) {
            if ("HeuristicStatus".equals(a.getName())) {
                HeuristicStatus ahs = HeuristicStatus.valueOf(a.getValue().toString());
                HeuristicStatus ehs = HeuristicStatus.intToStatus(expectedHeuristic);
                // assert that the instrumented heuristic status has the expected value
                assertTrue(ahs.equals(ehs));
            }
        }
    }
}
Also used : AbstractRecord(com.arjuna.ats.arjuna.coordinator.AbstractRecord) HeuristicHazard(org.omg.CosTransactions.HeuristicHazard) RecordTypeMap(com.arjuna.ats.arjuna.coordinator.abstractrecord.RecordTypeMap) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) Test(org.junit.Test)

Aggregations

ArjunaTransactionImple (com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple)33 Test (org.junit.Test)30 ServerControl (com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl)20 Control (org.omg.CosTransactions.Control)20 ControlImple (com.arjuna.ats.internal.jts.orbspecific.ControlImple)19 Uid (com.arjuna.ats.arjuna.common.Uid)9 ExtendedResourceRecord (com.arjuna.ats.internal.jts.resources.ExtendedResourceRecord)7 DemoArjunaResource (com.hp.mwtests.ts.jts.orbspecific.resources.DemoArjunaResource)7 ServerTopLevelAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction)4 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)4 HeuristicHazard (org.omg.CosTransactions.HeuristicHazard)4 ServerNestedAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerNestedAction)3 ServerOSITopLevelAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSITopLevelAction)3 ServerOSINestedAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSINestedAction)2 ServerStrictNestedAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.strict.ServerStrictNestedAction)2 ExtendedCrashRecord (com.hp.mwtests.ts.jta.jts.common.ExtendedCrashRecord)2 RecoveryCoordinator (org.omg.CosTransactions.RecoveryCoordinator)2 AbstractRecord (com.arjuna.ats.arjuna.coordinator.AbstractRecord)1 BasicAction (com.arjuna.ats.arjuna.coordinator.BasicAction)1 RecordTypeMap (com.arjuna.ats.arjuna.coordinator.abstractrecord.RecordTypeMap)1