Search in sources :

Example 1 with CadaverLockRecord

use of com.arjuna.ats.internal.txoj.abstractrecords.CadaverLockRecord 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 2 with CadaverLockRecord

use of com.arjuna.ats.internal.txoj.abstractrecords.CadaverLockRecord in project narayana by jbosstm.

the class CadaverUnitTest method testBasic.

@Test
public void testBasic() throws Exception {
    AtomicAction A = new AtomicAction();
    AtomicObject B = new AtomicObject();
    A.begin();
    CadaverLockRecord clr = new CadaverLockRecord(null, B, A);
    LockRecord lr = new LockRecord(B, A);
    assertTrue(clr.type() != null);
    clr.print(new PrintWriter(new ByteArrayOutputStream()));
    clr.replace(lr);
    A.abort();
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) CadaverLockRecord(com.arjuna.ats.internal.txoj.abstractrecords.CadaverLockRecord) CadaverLockRecord(com.arjuna.ats.internal.txoj.abstractrecords.CadaverLockRecord) LockRecord(com.arjuna.ats.internal.txoj.abstractrecords.LockRecord) AtomicObject(com.hp.mwtests.ts.txoj.common.resources.AtomicObject) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Aggregations

CadaverLockRecord (com.arjuna.ats.internal.txoj.abstractrecords.CadaverLockRecord)2 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)1 AbstractRecord (com.arjuna.ats.arjuna.coordinator.AbstractRecord)1 BasicAction (com.arjuna.ats.arjuna.coordinator.BasicAction)1 LockRecord (com.arjuna.ats.internal.txoj.abstractrecords.LockRecord)1 AtomicObject (com.hp.mwtests.ts.txoj.common.resources.AtomicObject)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintWriter (java.io.PrintWriter)1 Enumeration (java.util.Enumeration)1 Test (org.junit.Test)1