Search in sources :

Example 1 with BasicAction

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

the class LogWriteStateManager method modified.

protected synchronized boolean modified() {
    if (tsLogger.logger.isTraceEnabled()) {
        tsLogger.logger.trace("StateManager::modified() for object-id " + get_uid());
    }
    if ((super.objectType() == ObjectType.RECOVERABLE) && (super.objectModel == ObjectModel.SINGLE))
        return super.modified();
    BasicAction action = BasicAction.Current();
    if ((super.objectType() == ObjectType.NEITHER) || (super.status() == ObjectStatus.DESTROYED)) /*  NEITHER => no recovery info */
    {
        return true;
    }
    if (super.status() == ObjectStatus.PASSIVE) {
        tsLogger.i18NLogger.warn_StateManager_10();
        activate();
    }
    if (status() == ObjectStatus.PASSIVE_NEW)
        setStatus(ObjectStatus.ACTIVE_NEW);
    if (action != null) {
        /*
	     * Check if this is the first call to modified in this action.
	     * BasicList insert returns FALSE if the entry is already
	     * present.
	     */
        createLists();
        synchronized (modifyingActions) {
            if ((modifyingActions.size() > 0) && (modifyingActions.get(action.get_uid()) != null)) {
                return true;
            } else
                modifyingActions.put(action.get_uid(), action);
        }
        /* If here then its a new action */
        OutputObjectState state = new OutputObjectState(objectUid, type());
        int rStatus = AddOutcome.AR_ADDED;
        if (save_state(state, ObjectType.RECOVERABLE)) {
            TxLogWritePersistenceRecord record = new TxLogWritePersistenceRecord(state, super.getStore(), this);
            if ((rStatus = action.add(record)) != AddOutcome.AR_ADDED) {
                synchronized (modifyingActions) {
                    // remember to unregister with action
                    modifyingActions.remove(action.get_uid());
                }
                record = null;
                return false;
            }
        } else
            return false;
    }
    return true;
}
Also used : BasicAction(com.arjuna.ats.arjuna.coordinator.BasicAction) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState)

Example 2 with BasicAction

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

the class ArjunaTransactionImple method register_resource.

/**
 * Resources are only registered with the current transaction, whereas
 * subtransaction aware resources are registered with their parents when the
 * current transaction ends.
 */
public RecoveryCoordinator register_resource(Resource r) throws SystemException, Inactive {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ArjunaTransactionImple::register_resource ( " + r + " ) - called for " + get_uid());
    }
    if (r == null)
        throw new BAD_PARAM(0, CompletionStatus.COMPLETED_NO);
    currentStatus = determineStatus(this);
    if (currentStatus != Status.StatusActive) {
        if (jtsLogger.logger.isTraceEnabled()) {
            jtsLogger.logger.trace("ArjunaTransactionImple::register_resource - transaction not active: " + Utility.stringStatus(currentStatus));
        }
        if (currentStatus == Status.StatusMarkedRollback) {
            throw new TRANSACTION_ROLLEDBACK(ExceptionCodes.MARKED_ROLLEDBACK, CompletionStatus.COMPLETED_NO);
        } else
            throw new Inactive();
    }
    AbstractRecord corbaRec = null;
    BasicAction registerIn = this;
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ArjunaTransactionImple " + get_uid() + " ::register_resource: ");
    }
    // 
    // Creation of recovery coordinator (DBI)
    // 
    // 
    // Pack the params:
    // [0] = Transaction* this
    // 
    int index = 0;
    Object[] params = new Object[10];
    params[index++] = this;
    RecoveryCoordinator recoveryCoordinator = null;
    Uid recoveryCoordinatorUid = null;
    try {
        recoveryCoordinator = RecoveryCreator.createRecoveryCoordinator(r, params);
        if (recoveryCoordinator == null)
            throw new BAD_OPERATION("RecoveryCoordinator " + jtsLogger.i18NLogger.get_orbspecific_coordinator_rcnotcreated());
    } catch (NO_IMPLEMENT ex) {
        /*
			 * This is legal, and is meant to show that this ORB or
			 * configuration simply doesn't support crash recovery.
			 */
        recoveryCoordinator = null;
    } catch (SystemException e) {
        jtsLogger.i18NLogger.warn_orbspecific_coordinator_rccreate(get_uid(), e);
        try {
            rollback_only();
        } catch (Inactive ex1) {
        } catch (SystemException ex2) {
            jtsLogger.i18NLogger.warn_orbspecific_coordinator_rbofail("ArjunaTransactionImple.register_resource", get_uid(), ex2);
            throw ex2;
        }
        throw e;
    }
    if (recoveryCoordinator != null) {
        // 
        // We got a RecoveryCoordinator, so unpack the other return values:
        // [0] = RecoveryCoordinator Uid*
        // 
        index = 0;
        recoveryCoordinatorUid = (Uid) params[index++];
    } else {
        // 
        // We didn't get a RecoveryCoordinator, so we don't assume that
        // the other return values have been populated.
        // 
        recoveryCoordinatorUid = Uid.nullUid();
    }
    try {
        SubtransactionAwareResource staResource = org.omg.CosTransactions.SubtransactionAwareResourceHelper.narrow(r);
        if (staResource != null) {
            if (jtsLogger.logger.isTraceEnabled()) {
                jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " - subtransaction aware resource: YES");
            }
            /*
				 * If here the narrow was ok so we have a subtran aware
				 * resource.
				 */
            Coordinator coord = null;
            if (parentHandle != null) {
                /*
					 * If we are a SubTranResource then we get registered with
					 * the current transaction and its parents upon completion.
					 * The first parameter to the record indicates whether we
					 * should be propagated (registered) with the parent
					 * transaction.
					 */
                coord = parentHandle.get_coordinator();
            }
            corbaRec = createOTSRecord(true, r, coord, recoveryCoordinatorUid);
            coord = null;
            staResource = null;
        } else
            throw new BAD_PARAM(0, CompletionStatus.COMPLETED_NO);
    } catch (BAD_PARAM ex) {
        if (jtsLogger.logger.isTraceEnabled()) {
            jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " - subtransaction aware resource: NO");
        }
        if (jtsLogger.logger.isTraceEnabled()) {
            jtsLogger.logger.trace("ArjunaTransactionImple " + get_uid() + " ::register_resource: Simple resource - " + ex);
        }
        corbaRec = createOTSRecord(true, r, null, recoveryCoordinatorUid);
    } catch (Unavailable e1) {
        throw new Inactive();
    } catch (SystemException e2) {
        if (jtsLogger.logger.isTraceEnabled()) {
            jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " : catch (SystemException) - " + e2);
        }
        throw e2;
    } catch (Exception e3) {
        if (jtsLogger.logger.isTraceEnabled()) {
            jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " : catch (...) - " + e3);
        }
        throw new UNKNOWN(e3.toString(), ExceptionCodes.UNKNOWN_EXCEPTION, CompletionStatus.COMPLETED_NO);
    }
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " : try end");
    }
    if (registerIn.add(corbaRec) != AddOutcome.AR_ADDED) {
        corbaRec = null;
        throw new INVALID_TRANSACTION(ExceptionCodes.ADD_FAILED, CompletionStatus.COMPLETED_NO);
    } else {
        if (jtsLogger.logger.isTraceEnabled()) {
            jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " : resource registered");
        }
    }
    return recoveryCoordinator;
}
Also used : NO_IMPLEMENT(org.omg.CORBA.NO_IMPLEMENT) SubtransactionAwareResource(org.omg.CosTransactions.SubtransactionAwareResource) BasicAction(com.arjuna.ats.arjuna.coordinator.BasicAction) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) BAD_PARAM(org.omg.CORBA.BAD_PARAM) OTSAbstractRecord(com.arjuna.ArjunaOTS.OTSAbstractRecord) AbstractRecord(com.arjuna.ats.arjuna.coordinator.AbstractRecord) UidCoordinator(com.arjuna.ArjunaOTS.UidCoordinator) RecoveryCoordinator(org.omg.CosTransactions.RecoveryCoordinator) Coordinator(org.omg.CosTransactions.Coordinator) SystemException(org.omg.CORBA.SystemException) SynchronizationUnavailable(org.omg.CosTransactions.SynchronizationUnavailable) SubtransactionsUnavailable(org.omg.CosTransactions.SubtransactionsUnavailable) Unavailable(org.omg.CosTransactions.Unavailable) Uid(com.arjuna.ats.arjuna.common.Uid) SystemException(org.omg.CORBA.SystemException) Inactive(org.omg.CosTransactions.Inactive) RecoveryCoordinator(org.omg.CosTransactions.RecoveryCoordinator) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION) UNKNOWN(org.omg.CORBA.UNKNOWN) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK)

Example 3 with BasicAction

use of com.arjuna.ats.arjuna.coordinator.BasicAction 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;
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) BasicAction(com.arjuna.ats.arjuna.coordinator.BasicAction) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) RecoveryCoordinator(org.omg.CosTransactions.RecoveryCoordinator) ServerTransaction(com.arjuna.ats.internal.jts.orbspecific.interposition.coordinator.ServerTransaction)

Example 4 with BasicAction

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

the class ThreadActionData method purgeActions.

public static void purgeActions(Thread t, boolean unregister) {
    Deque<BasicAction> txs = _threadList.get();
    _threadList.set(null);
    if (txs != null) {
        if (unregister) {
            while (!txs.isEmpty()) {
                BasicAction act = txs.pop();
                if (act != null) {
                    act.removeChildThread(ThreadUtil.getThreadId(t));
                }
            }
        }
    }
}
Also used : BasicAction(com.arjuna.ats.arjuna.coordinator.BasicAction)

Example 5 with BasicAction

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

the class ThreadActionData method restoreActions.

/**
 * Put back the entire hierarchy, removing whatever is already there.
 */
public static void restoreActions(BasicAction act) {
    purgeActions();
    if (act != null) {
        /*
			 * First get the hierarchy from the bottom up.
			 */
        Deque<BasicAction> s = new ArrayDeque<BasicAction>();
        BasicAction nextLevel = act.parent();
        s.push(act);
        while (nextLevel != null) {
            s.push(nextLevel);
            nextLevel = nextLevel.parent();
        }
        try {
            while (!s.isEmpty()) {
                pushAction(s.pop());
            }
        } catch (Exception ex) {
        }
    }
}
Also used : BasicAction(com.arjuna.ats.arjuna.coordinator.BasicAction) ArrayDeque(java.util.ArrayDeque) NoSuchElementException(java.util.NoSuchElementException)

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