use of com.arjuna.ats.arjuna.coordinator.AbstractRecord in project narayana by jbosstm.
the class LockManager method cleanUp.
protected final void cleanUp() {
if (txojLogger.logger.isTraceEnabled()) {
txojLogger.logger.trace("LockManager::cleanUp() for object-id " + get_uid());
}
if (lockMutex()) {
if (hasBeenLocked) {
if ((super.objectModel == ObjectModel.MULTIPLE) && (systemKey == null)) {
initialise();
}
/*
* Unlike in the original version of Arjuna, we don't check to see
* if the invoking thread is within a transaction. We look at
* whether this object has been used within a transaction, and then
* act accordingly.
*/
BasicAction current = BasicAction.Current();
synchronized (super.usingActions) {
if (super.usingActions != null) {
Enumeration e = super.usingActions.elements();
while (e.hasMoreElements()) {
BasicAction action = (BasicAction) e.nextElement();
if (// shouldn't be null!!
action != null) {
/*
* Pop actions off using list. Don't check if action
* is running below so that cadavers can be created
* in commit protocol too.
*/
/*
* We need to create a cadaver lock record to
* maintain the locks because this object is being
* deleted.
*/
AbstractRecord A = new CadaverLockRecord(lockStore, this, action);
if (action.add(A) != AddOutcome.AR_ADDED) {
A = null;
}
}
}
}
}
hasBeenLocked = false;
}
unlockMutex();
}
}
use of com.arjuna.ats.arjuna.coordinator.AbstractRecord 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));
}
}
}
}
use of com.arjuna.ats.arjuna.coordinator.AbstractRecord in project narayana by jbosstm.
the class ActionBean method findParticipants.
/**
* create MBean representations of the participants of this transaction
* @param recuids some transaction participants are represented in the ObjectStore
* - if this is the case then recuids contains a list of MBean wrappers representing them.
* Otherwise this list will be empty.
* @param list the records representing the participants
* @param listType indicates the type of the records in list (PREPARED, PENDING, FAILED, READONLY, HEURISTIC)
*/
private void findParticipants(List<UidWrapper> recuids, RecordList list, ParticipantStatus listType) {
if (list != null) {
for (AbstractRecord rec = list.peekFront(); rec != null; rec = list.peekNext(rec)) {
LogRecordWrapper lw;
int i = recuids == null ? -1 : recuids.indexOf(new UidWrapper(ra.getUid(rec)));
if (i != -1) {
OSEntryBean p = recuids.get(i).getMBean();
if (p instanceof LogRecordWrapper) {
lw = (LogRecordWrapper) p;
lw.init(this, rec, listType);
} else {
if (tsLogger.logger.isTraceEnabled())
tsLogger.logger.trace("participant record is not a LogRecordWrapper");
lw = createParticipant(rec, listType, recuids.get(i));
}
} else {
lw = createParticipant(rec, listType);
}
lw.activate();
participants.add(lw);
}
}
}
use of com.arjuna.ats.arjuna.coordinator.AbstractRecord in project narayana by jbosstm.
the class AtomicActionTestBase method executeTest.
protected AtomicAction executeTest(boolean isCommit, int expectedResult, SyncRecord[] syncs, AbstractRecord... records) {
AtomicAction A = new AtomicAction();
A.begin();
for (AbstractRecord record : records) {
A.add(record);
}
if (syncs != null) {
for (SyncRecord sync : syncs) Assert.assertEquals(AddOutcome.AR_ADDED, A.addSynchronization(sync));
Assert.assertEquals(syncs.length, A.getSynchronizations().size());
}
if (isCommit) {
Assert.assertEquals(expectedResult, A.commit());
} else {
Assert.assertEquals(expectedResult, A.abort());
}
return A;
}
use of com.arjuna.ats.arjuna.coordinator.AbstractRecord in project narayana by jbosstm.
the class AtomicActionTestBase method testPrepareWithLRRFailOn2PCAwareResourceCommit.
protected void testPrepareWithLRRFailOn2PCAwareResourceCommit() {
OnePhase onePhase = new OnePhase();
AbstractRecord lastResourceRecord = new LastResourceRecord(onePhase);
AbstractRecord shutdownRecord = new ShutdownRecord(ShutdownRecord.FAIL_IN_COMMIT);
executeTest(true, ActionStatus.COMMITTED, null, lastResourceRecord, shutdownRecord);
Assert.assertEquals(OnePhase.COMMITTED, onePhase.status());
}
Aggregations