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