Search in sources :

Example 6 with Inactive

use of org.omg.CosTransactions.Inactive in project narayana by jbosstm.

the class TransactionFactoryImple method getChildTransactions.

/**
 * @return the list of child transactions.
 */
public org.omg.CosTransactions.otid_t[] getChildTransactions(otid_t parent) throws Inactive, NoTransaction, SystemException {
    Uid u = Utility.otidToUid(parent);
    org.omg.CosTransactions.otid_t[] ctx = null;
    if (u == null)
        throw new BAD_PARAM("otid_t " + jtsLogger.i18NLogger.get_orbspecific_otiderror());
    else {
        BasicAction act = ActionManager.manager().get(u);
        if (act == null)
            throw new NoTransaction();
        else {
            if (act.status() == ActionStatus.RUNNING) {
                Object[] children = act.childTransactions();
                int size = ((children == null) ? 0 : children.length);
                if (size > 0) {
                    ctx = new org.omg.CosTransactions.otid_t[size];
                    for (int i = 0; i < size; i++) {
                        ctx[i] = Utility.uidToOtid((Uid) children[i]);
                    }
                }
            } else
                throw new Inactive();
        }
    }
    return ctx;
}
Also used : NoTransaction(org.omg.CosTransactions.NoTransaction) BasicAction(com.arjuna.ats.arjuna.coordinator.BasicAction) CosTransactions.otid_t(org.omg.CosTransactions.otid_t) BAD_PARAM(org.omg.CORBA.BAD_PARAM) Uid(com.arjuna.ats.arjuna.common.Uid) Inactive(org.omg.CosTransactions.Inactive)

Example 7 with Inactive

use of org.omg.CosTransactions.Inactive in project narayana by jbosstm.

the class ControlWrapper method register_subtran_aware.

public final void register_subtran_aware(SubtransactionAwareResource sr) throws Inactive, NotSubtransaction, SystemException {
    try {
        if (_controlImpl != null)
            _controlImpl.getImplHandle().register_subtran_aware(sr);
        else {
            try {
                Coordinator coord = _control.get_coordinator();
                coord.register_subtran_aware(sr);
            } catch (Unavailable e2) {
                throw new Inactive();
            } catch (SystemException e3) {
                throw new UNKNOWN();
            } catch (final NullPointerException ex) {
                throw new UNKNOWN();
            }
        }
    } catch (NullPointerException e1) {
        throw new Inactive();
    }
}
Also used : SystemException(org.omg.CORBA.SystemException) Inactive(org.omg.CosTransactions.Inactive) UNKNOWN(org.omg.CORBA.UNKNOWN) UidCoordinator(com.arjuna.ArjunaOTS.UidCoordinator) Coordinator(org.omg.CosTransactions.Coordinator) SynchronizationUnavailable(org.omg.CosTransactions.SynchronizationUnavailable) SubtransactionsUnavailable(org.omg.CosTransactions.SubtransactionsUnavailable) Unavailable(org.omg.CosTransactions.Unavailable)

Example 8 with Inactive

use of org.omg.CosTransactions.Inactive in project narayana by jbosstm.

the class ControlWrapper method register_synchronization.

public final void register_synchronization(Synchronization sync) throws Inactive, SynchronizationUnavailable, SystemException {
    try {
        if (_controlImpl != null)
            _controlImpl.getImplHandle().register_synchronization(sync);
        else {
            try {
                Coordinator coord = _control.get_coordinator();
                coord.register_synchronization(sync);
            } catch (final Unavailable e2) {
                throw new Inactive();
            } catch (final Exception e3) {
                throw new UNKNOWN();
            }
        }
    } catch (final NullPointerException e1) {
        throw new Inactive();
    }
}
Also used : Inactive(org.omg.CosTransactions.Inactive) UNKNOWN(org.omg.CORBA.UNKNOWN) UidCoordinator(com.arjuna.ArjunaOTS.UidCoordinator) 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)

Example 9 with Inactive

use of org.omg.CosTransactions.Inactive in project narayana by jbosstm.

the class CurrentImple method begin.

public void begin() throws SubtransactionsUnavailable, SystemException {
    ControlWrapper currentAction = _theManager.current();
    if (// no current, so create top-level action
    currentAction == null) {
        if (jtsLogger.logger.isTraceEnabled()) {
            jtsLogger.logger.trace("CurrentImple::begin - creating new top-level transaction.");
        }
        if (OTSImpleManager.localFactory())
            currentAction = new ControlWrapper(OTSImpleManager.factory().createLocal(get_timeout()));
        else
            currentAction = new ControlWrapper(OTSImpleManager.get_factory().create(get_timeout()));
    } else {
        if (jtsLogger.logger.isTraceEnabled()) {
            jtsLogger.logger.trace("CurrentImple::begin - creating new subtransaction.");
        }
        try {
            currentAction = currentAction.create_subtransaction();
        } catch (Unavailable ex) {
            throw new INVALID_TRANSACTION(ExceptionCodes.UNAVAILABLE_COORDINATOR, CompletionStatus.COMPLETED_NO);
        } catch (Inactive e) {
            throw new INVALID_TRANSACTION(ExceptionCodes.INACTIVE_TRANSACTION, CompletionStatus.COMPLETED_NO);
        } catch (NO_MEMORY nme) {
            System.gc();
            throw nme;
        } catch (SystemException sysEx) {
            throw new INVALID_TRANSACTION(ExceptionCodes.INACTIVE_TRANSACTION, CompletionStatus.COMPLETED_NO);
        } catch (OutOfMemoryError me) {
            System.gc();
            throw new NO_MEMORY(0, CompletionStatus.COMPLETED_NO);
        }
    }
    _theManager.pushAction(currentAction);
    try {
        ThreadAssociationControl.updateAssociation(currentAction, TX_BEGUN);
    } catch (Exception e) {
        try {
            rollback_only();
        } catch (Exception ex) {
        }
    }
    currentAction = null;
}
Also used : NO_MEMORY(org.omg.CORBA.NO_MEMORY) SystemException(org.omg.CORBA.SystemException) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) Inactive(org.omg.CosTransactions.Inactive) SystemException(org.omg.CORBA.SystemException) UserException(org.omg.CORBA.UserException) SubtransactionsUnavailable(org.omg.CosTransactions.SubtransactionsUnavailable) Unavailable(org.omg.CosTransactions.Unavailable)

Example 10 with Inactive

use of org.omg.CosTransactions.Inactive in project narayana by jbosstm.

the class GenericRecoveryCoordinator method replay_completion.

/**
 * Respond to a replay_completion request for the RecoveryCoordinator
 * identified by parameter id.
 */
protected static Status replay_completion(RecoveryCoordinatorId id, Resource res) throws SystemException, NotPrepared {
    if (jtsLogger.logger.isDebugEnabled()) {
        jtsLogger.logger.debug("GenericRecoveryCoordinator(" + id._RCUid + ").replay_completion(" + (res != null ? "resource supplied)" : "null resource)"));
    }
    Status currentStatus = Status.StatusUnknown;
    /* 
	 * First check to see if the transaction is active by asking the 
	 * per-process contact.
	 * If alive, return the status reported by the
	 * transaction.  If not alive then try and recover the
	 * transaction from the intentions list.  
	 */
    boolean transactionActive = true;
    try {
        currentStatus = get_status(id._actionUid, id._originalProcessUid);
    } catch (Inactive e) {
        // original process is dead.
        transactionActive = false;
    }
    if (currentStatus == Status.StatusNoTransaction) {
        /*
	     * There is no intentions list, so the transaction either
	     * committed or rolled back. However, this routine is only
	     * ever called by replay_completion, which means that there
	     * is a resource (hopefully one which was participating in
	     * the transaction) that is in doubt as to the
	     * transaction's outcome. If the transaction had committed,
	     * then this resource would know of the outcome. Therefore,
	     * it must have rolled back!
	     */
        /*
	     * Unfortunately the last statement is wrong. There is a timing
	     * issue here: the resource recovery may be doing an upcall while
	     * the downcall (from coordinator recovery) is going on and
	     * removing the log. What can then happen is that a resource may
	     * see a commit folled by a rollback.
	     */
        currentStatus = Status.StatusRolledBack;
    }
    if (!transactionActive) {
        // original process is dead, so reasonable for us to try to
        // recover
        /*
	     * The RecoveredTransactionReplayer is a threaded object
	     * so we can get the status and return it while the
	     * replayer does the phase 2 commit in a new thread.  
	     */
        String tranType = ((id._isServerTransaction) ? ServerTransaction.typeName() : ArjunaTransactionImple.typeName());
        try {
            if (id._isServerTransaction && (StoreManager.getRecoveryStore().currentState(id._actionUid, ServerTransaction.typeName() + "/JCA") != StateStatus.OS_UNKNOWN)) {
                tranType = tranType + "/JCA";
            }
        } catch (ObjectStoreException e) {
        // Can't read store
        }
        com.arjuna.ats.internal.jts.recovery.transactions.RecoveredTransactionReplayer replayer = new com.arjuna.ats.internal.jts.recovery.transactions.RecoveredTransactionReplayer(id._actionUid, tranType);
        // this will cause the activatation attempt
        currentStatus = replayer.getStatus();
        if ((replayer.getRecoveryStatus() != com.arjuna.ats.internal.jts.recovery.transactions.RecoveryStatus.ACTIVATE_FAILED) && (res != null)) {
            if (jtsLogger.logger.isDebugEnabled()) {
                jtsLogger.logger.debug("GenericRecoveryCoordinator - swapping Resource for RC " + id._RCUid);
            }
            replayer.swapResource(id._RCUid, res);
        }
        if (replayer.getRecoveryStatus() != com.arjuna.ats.internal.jts.recovery.transactions.RecoveryStatus.ACTIVATE_FAILED) {
            replayer.replayPhase2();
        } else {
            replayer.tidyup();
            /*
		 * The transaction didn't activate so we have a
		 * rollback situation but we can't rollback the
		 * resource that we have been given through the
		 * intentions list but we can issue rollback
		 * directly. This is configurable through the System
		 * properties.
		 */
            currentStatus = Status.StatusRolledBack;
        }
    }
    if (currentStatus == Status.StatusRolledBack) {
        if (_issueRecoveryRollback) {
            ResourceCompletor resourceCompletor = new ResourceCompletor(res, ResourceCompletor.ROLLBACK);
            resourceCompletor.start();
        }
    }
    if (currentStatus == Status.StatusActive)
        throw new NotPrepared();
    return currentStatus;
}
Also used : StateStatus(com.arjuna.ats.arjuna.objectstore.StateStatus) Status(org.omg.CosTransactions.Status) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) ResourceCompletor(com.arjuna.ats.internal.jts.recovery.recoverycoordinators.ResourceCompletor) NotPrepared(org.omg.CosTransactions.NotPrepared) Inactive(org.omg.CosTransactions.Inactive)

Aggregations

Inactive (org.omg.CosTransactions.Inactive)14 SystemException (org.omg.CORBA.SystemException)9 UNKNOWN (org.omg.CORBA.UNKNOWN)5 Coordinator (org.omg.CosTransactions.Coordinator)5 SubtransactionsUnavailable (org.omg.CosTransactions.SubtransactionsUnavailable)5 SynchronizationUnavailable (org.omg.CosTransactions.SynchronizationUnavailable)5 Unavailable (org.omg.CosTransactions.Unavailable)5 UidCoordinator (com.arjuna.ArjunaOTS.UidCoordinator)4 BAD_PARAM (org.omg.CORBA.BAD_PARAM)4 NoTransaction (org.omg.CosTransactions.NoTransaction)4 RecoveryCoordinator (org.omg.CosTransactions.RecoveryCoordinator)4 Status (org.omg.CosTransactions.Status)4 CosTransactions.otid_t (org.omg.CosTransactions.otid_t)4 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)3 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)3 OTSAbstractRecord (com.arjuna.ArjunaOTS.OTSAbstractRecord)2 Uid (com.arjuna.ats.arjuna.common.Uid)2 AbstractRecord (com.arjuna.ats.arjuna.coordinator.AbstractRecord)2 BasicAction (com.arjuna.ats.arjuna.coordinator.BasicAction)2 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)2