Search in sources :

Example 16 with AbstractRecord

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();
    }
}
Also used : Enumeration(java.util.Enumeration) BasicAction(com.arjuna.ats.arjuna.coordinator.BasicAction) CadaverLockRecord(com.arjuna.ats.internal.txoj.abstractrecords.CadaverLockRecord) AbstractRecord(com.arjuna.ats.arjuna.coordinator.AbstractRecord)

Example 17 with AbstractRecord

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

Example 18 with AbstractRecord

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);
        }
    }
}
Also used : AbstractRecord(com.arjuna.ats.arjuna.coordinator.AbstractRecord)

Example 19 with AbstractRecord

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;
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) AbstractRecord(com.arjuna.ats.arjuna.coordinator.AbstractRecord)

Example 20 with AbstractRecord

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());
}
Also used : LastResourceRecord(com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord) AbstractRecord(com.arjuna.ats.arjuna.coordinator.AbstractRecord)

Aggregations

AbstractRecord (com.arjuna.ats.arjuna.coordinator.AbstractRecord)31 RecordListIterator (com.arjuna.ats.arjuna.coordinator.RecordListIterator)10 Coordinator (org.omg.CosTransactions.Coordinator)5 RecordTypeMap (com.arjuna.ats.arjuna.coordinator.abstractrecord.RecordTypeMap)4 OTSAbstractRecord (com.arjuna.ArjunaOTS.OTSAbstractRecord)3 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)3 Uid (com.arjuna.ats.arjuna.common.Uid)3 BasicAction (com.arjuna.ats.arjuna.coordinator.BasicAction)3 LastResourceRecord (com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord)3 BAD_PARAM (org.omg.CORBA.BAD_PARAM)3 UidCoordinator (com.arjuna.ArjunaOTS.UidCoordinator)2 IOException (java.io.IOException)2 Enumeration (java.util.Enumeration)2 Test (org.junit.Test)2 SystemException (org.omg.CORBA.SystemException)2 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)2 UNKNOWN (org.omg.CORBA.UNKNOWN)2 Inactive (org.omg.CosTransactions.Inactive)2 RecoveryCoordinator (org.omg.CosTransactions.RecoveryCoordinator)2 SubtransactionsUnavailable (org.omg.CosTransactions.SubtransactionsUnavailable)2