Search in sources :

Example 16 with BasicAction

use of com.arjuna.ats.arjuna.coordinator.BasicAction in project narayana by jbosstm.

the class AtomicAction method suspend.

/**
 * Suspend all transaction association from the invoking thread. When this
 * operation returns, the thread will be associated with no transactions.
 *
 * If the current transaction is not an AtomicAction then this method will
 * not suspend.
 *
 * @return a handle on the current AtomicAction (if any) so that the thread
 *         can later resume association if required.
 */
public static final AtomicAction suspend() {
    BasicAction curr = ThreadActionData.currentAction();
    if (curr != null) {
        if (curr instanceof AtomicAction)
            ThreadActionData.purgeActions();
        else {
            tsLogger.i18NLogger.warn_ats_atomicaction_1(curr.toString());
            curr = null;
        }
    }
    return (AtomicAction) curr;
}
Also used : BasicAction(com.arjuna.ats.arjuna.coordinator.BasicAction)

Example 17 with BasicAction

use of com.arjuna.ats.arjuna.coordinator.BasicAction in project narayana by jbosstm.

the class TransactionMonitor method main.

public static void main(String[] args) {
    String root = null;
    for (int i = 0; i < args.length; i++) {
        if (args[i].compareTo("-help") == 0) {
            usage();
            System.exit(0);
        } else {
            if (args[i].compareTo("-root") == 0) {
                root = args[i + 1];
                i++;
            } else {
                System.out.println("Unknown option " + args[i]);
                usage();
                System.exit(0);
            }
        }
    }
    /* Determine transaction (BasicAction) type name */
    BasicAction ba = new BasicAction();
    String baType = ba.type();
    if (baType.charAt(0) == '/')
        baType = baType.substring(1);
    try {
        RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
        InputObjectState types = new InputObjectState();
        if (recoveryStore.allTypes(types)) {
            String theName = null;
            int count = 0;
            try {
                boolean endOfList = false;
                while (!endOfList) {
                    theName = types.unpackString();
                    if (theName.compareTo("") == 0)
                        endOfList = true;
                    else if (theName.startsWith(baType)) {
                        count++;
                        System.out.println(count + ": " + theName);
                        InputObjectState uids = new InputObjectState();
                        if (recoveryStore.allObjUids(theName, uids)) {
                            Uid theUid = new Uid(Uid.nullUid());
                            try {
                                boolean endOfUids = false;
                                while (!endOfUids) {
                                    theUid = UidHelper.unpackFrom(uids);
                                    if (theUid.equals(Uid.nullUid()))
                                        endOfUids = true;
                                    else {
                                        System.out.print("\t" + theUid + " state is ");
                                        System.out.print(StateStatus.stateStatusString(recoveryStore.currentState(theUid, theName)));
                                        System.out.println();
                                    }
                                }
                            } catch (Exception e) {
                            // end of uids!
                            }
                        }
                        System.out.println();
                    }
                }
            } catch (Exception e) {
                System.err.println(e);
            // end of list!
            }
        }
    } catch (Exception e) {
        System.err.println("Caught unexpected exception: " + e);
    }
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) Uid(com.arjuna.ats.arjuna.common.Uid) BasicAction(com.arjuna.ats.arjuna.coordinator.BasicAction) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore)

Example 18 with BasicAction

use of com.arjuna.ats.arjuna.coordinator.BasicAction in project narayana by jbosstm.

the class BadAction method test.

@Test
public void test() {
    AtomicAction A = new AtomicAction();
    AtomicAction B = new AtomicAction();
    A.begin();
    B.begin();
    A.commit();
    B.commit();
    BasicAction current = BasicAction.Current();
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) BasicAction(com.arjuna.ats.arjuna.coordinator.BasicAction) Test(org.junit.Test)

Example 19 with BasicAction

use of com.arjuna.ats.arjuna.coordinator.BasicAction in project narayana by jbosstm.

the class LockManager method doRelease.

/*
     * doRelease: Does all the hard work of lock release. Either releases all
     * locks for a given tx uid, or simply one lock with a given uid as
     * appropriate.
     */
protected boolean doRelease(Uid u, boolean all) {
    if (txojLogger.logger.isTraceEnabled()) {
        txojLogger.logger.trace("LockManager::doRelease(" + u + ", " + all + ")");
    }
    if (!lockMutex())
        return false;
    Lock previous = null;
    Lock current = null;
    boolean deleted = false;
    boolean result = false;
    int retryCount = 10;
    boolean loaded = false;
    boolean releasedOK = false;
    BasicAction currAct = BasicAction.Current();
    try {
        synchronized (locksHeldLockObject) {
            do {
                if (loadState()) {
                    loaded = true;
                    /*
                         * Must declare iterator after loadstate or it sees an empty
                         * list!
                         */
                    LockListIterator next = new LockListIterator(locksHeld);
                    /*
                         * Now scan through held lock list to find which locks to
                         * release u is either the unique id of the lock owner
                         * (oneOrAll = ALL_LOCKS) or the uid of the actual lock
                         * itself (oneOrAll = SINGLE_LOCK).
                         */
                    previous = null;
                    while ((current = next.iterate()) != null) {
                        Uid checkUid = null;
                        if (all)
                            checkUid = current.getCurrentOwner();
                        else
                            checkUid = current.get_uid();
                        if (u.equals(checkUid)) {
                            locksHeld.forgetNext(previous);
                            current = null;
                            deleted = true;
                            if (!all) {
                                break;
                            }
                        } else
                            previous = current;
                    }
                    result = true;
                } else {
                    /*
                         * Free state while we still have the lock.
                         */
                    freeState();
                    result = false;
                }
                if (!result) {
                    try {
                        if (tsLogger.logger.isTraceEnabled()) {
                            tsLogger.logger.trace("LockManager.doRelease() Dozing");
                        }
                        Thread.sleep(LockManager.DOZE_TIME);
                    } catch (InterruptedException e) {
                    }
                } else {
                    // if (!stateLoaded)
                    if (!loaded) {
                        txojLogger.i18NLogger.warn_LockManager_7();
                    /*
                             * No need to freeState since we will have done that by now.
                             */
                    } else {
                        if (!deleted) {
                            if (txojLogger.logger.isTraceEnabled()) {
                                txojLogger.logger.trace(" *** CANNOT locate locks  ***");
                            }
                        }
                        int unloadRetryCount = 10;
                        do {
                            if (!unloadState()) {
                                txojLogger.i18NLogger.warn_LockManager_8();
                            } else
                                releasedOK = true;
                        } while ((--unloadRetryCount > 0) && (!releasedOK));
                    }
                }
            } while ((!result) && (--retryCount > 0));
        }
        /*
             * Now signal to any waiting threads that they may try to acquire the
             * lock.
             */
        conflictManager.signal();
    } finally {
        unlockMutex();
    }
    return releasedOK;
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) BasicAction(com.arjuna.ats.arjuna.coordinator.BasicAction) LockListIterator(com.arjuna.ats.internal.txoj.LockListIterator) ReentrantLock(java.util.concurrent.locks.ReentrantLock)

Example 20 with BasicAction

use of com.arjuna.ats.arjuna.coordinator.BasicAction in project narayana by jbosstm.

the class TransactionImple method getTransaction.

public static final TransactionImple getTransaction() {
    TransactionImple tx = null;
    final BasicAction current = BasicAction.Current();
    if (current != null) {
        final Uid txid = current.get_uid();
        tx = (TransactionImple) _transactions.get(txid);
        if (tx == null)
            tx = new TransactionImple(current);
    }
    return tx;
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) BasicAction(com.arjuna.ats.arjuna.coordinator.BasicAction)

Aggregations

BasicAction (com.arjuna.ats.arjuna.coordinator.BasicAction)22 Uid (com.arjuna.ats.arjuna.common.Uid)8 BAD_PARAM (org.omg.CORBA.BAD_PARAM)4 UidCoordinator (com.arjuna.ArjunaOTS.UidCoordinator)3 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)3 AbstractRecord (com.arjuna.ats.arjuna.coordinator.AbstractRecord)3 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)3 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)2 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)2 CadaverActivationRecord (com.arjuna.ats.internal.arjuna.abstractrecords.CadaverActivationRecord)2 CadaverLockRecord (com.arjuna.ats.internal.txoj.abstractrecords.CadaverLockRecord)2 Enumeration (java.util.Enumeration)2 SystemException (org.omg.CORBA.SystemException)2 Inactive (org.omg.CosTransactions.Inactive)2 RecoveryCoordinator (org.omg.CosTransactions.RecoveryCoordinator)2 OTSAbstractRecord (com.arjuna.ArjunaOTS.OTSAbstractRecord)1 ActionHierarchy (com.arjuna.ats.arjuna.coordinator.ActionHierarchy)1 RecoveryStore (com.arjuna.ats.arjuna.objectstore.RecoveryStore)1 ActivationRecord (com.arjuna.ats.internal.arjuna.abstractrecords.ActivationRecord)1 CadaverRecord (com.arjuna.ats.internal.arjuna.abstractrecords.CadaverRecord)1