Search in sources :

Example 6 with Coordinator

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

the class ServerTransaction method register_synchronization.

/**
 * Registering a synchronization with interposition is a bit complicated!
 * Synchronizations must be called prior to prepare; if no
 * interposed-synchronization is used then either synchronizations would be
 * registered locally (and then ignored by the commit protocol) or they
 * would need to be registered remotely, which would mean a cross-address
 * space call for each synchronization!
 *
 * The first time a synchronization is registered locally, we register a
 * proxy back with the real coordinator. When that transaction commits, it
 * will call this proxy, which will then drive the locally registered
 * synchronizations (actually it calls appropriate on the transaction to do
 * this.)
 *
 * However, one-phase commit complicates matters even more since we call
 * commit on the interposed coordinator, which runs through the commit and
 * then the after_completion code before returning to the real coordinator's
 * commit call. Rather than separate commit and synchronization code
 * completely from the transaction (in which case we could just call the
 * commit portion here) we let after_completion get called before returning
 * the commit response, and simply ignore the real coordinator's subsequent
 * call to after_completion.
 */
public synchronized void register_synchronization(Synchronization theSync) throws Inactive, SynchronizationUnavailable, SystemException {
    if (// are we a top-level transaction?
    !is_top_level_transaction()) {
        throw new SynchronizationUnavailable();
    } else {
        if (_interposedSynch) {
            if (_sync == null) {
                _sync = new ServerSynchronization(this);
                Coordinator realCoord = null;
                try {
                    ServerControl control = (ServerControl) super.controlHandle;
                    if (controlHandle != null) {
                        realCoord = control.originalCoordinator();
                        if (realCoord != null) {
                            realCoord.register_synchronization(_sync.getSynchronization());
                        } else
                            throw new BAD_OPERATION(ExceptionCodes.NO_TRANSACTION, CompletionStatus.COMPLETED_NO);
                    } else
                        throw new BAD_OPERATION(ExceptionCodes.NO_TRANSACTION, CompletionStatus.COMPLETED_NO);
                } catch (Inactive e1) {
                    realCoord = null;
                    throw e1;
                } catch (SynchronizationUnavailable e2) {
                    realCoord = null;
                    throw e2;
                } catch (SystemException e3) {
                    realCoord = null;
                    throw e3;
                }
                realCoord = null;
            }
        }
        /*
			 * Now register the synchronization locally.
			 */
        super.register_synchronization(theSync);
    }
}
Also used : ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) SystemException(org.omg.CORBA.SystemException) ServerSynchronization(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.ServerSynchronization) Inactive(org.omg.CosTransactions.Inactive) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION) Coordinator(org.omg.CosTransactions.Coordinator) RecoveryCoordinator(org.omg.CosTransactions.RecoveryCoordinator) SynchronizationUnavailable(org.omg.CosTransactions.SynchronizationUnavailable)

Example 7 with Coordinator

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

the class OTSManager method destroyControl.

/**
 * Destroy the transaction control.
 */
public static void destroyControl(Control control) throws ActiveTransaction, ActiveThreads, BadControl, Destroyed, SystemException {
    if (control == null)
        throw new BadControl();
    ControlImple lCont = Helper.localControl(control);
    if (lCont != null) {
        destroyControl(lCont);
    } else {
        /*
	     * Just in case control is a top-level transaction, and has
	     * been registered with the reaper, we need to get it removed.
	     *
	     */
        Coordinator coord = null;
        try {
            coord = control.get_coordinator();
        } catch (Exception e) {
            // nothing else we can do!
            coord = null;
        }
        if (coord != null) {
            try {
                if (coord.is_top_level_transaction()) {
                    // wrap the control so it gets compared against reaper list entries using the correct test
                    PseudoControlWrapper wrapper = new PseudoControlWrapper(control);
                    TransactionReaper.transactionReaper().remove(wrapper);
                }
            } catch (Exception e) {
            }
            coord = null;
        }
        if (jtsLogger.logger.isTraceEnabled()) {
            jtsLogger.logger.trace("OTS::destroyControl - remote control.");
        }
        /*
	     * Remote transaction, so memory management is different!
	     */
        ActionControl action = null;
        try {
            action = com.arjuna.ArjunaOTS.ActionControlHelper.narrow(control);
            if (action == null)
                throw new BAD_PARAM();
        } catch (Exception e) {
            action = null;
        }
        if (action != null) {
            if (jtsLogger.logger.isTraceEnabled()) {
                jtsLogger.logger.trace("OTS::destroyControl - Arjuna control.");
            }
            /*
		 * Is an Arjuna control, so we can call destroy on it?
		 */
            action.destroy();
            action = null;
            control = null;
        } else {
            /*
		 * Just call release on the control.
		 *
		 * We could throw a BadControl exception, but
		 * what would that do for the programmer?
		 */
            control = null;
        }
    }
}
Also used : ActionControl(com.arjuna.ArjunaOTS.ActionControl) BAD_PARAM(org.omg.CORBA.BAD_PARAM) BadControl(com.arjuna.ArjunaOTS.BadControl) PseudoControlWrapper(com.arjuna.ats.internal.jts.PseudoControlWrapper) Coordinator(org.omg.CosTransactions.Coordinator) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) SystemException(org.omg.CORBA.SystemException)

Example 8 with Coordinator

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

the class Helper method getUidCoordinator.

public static final UidCoordinator getUidCoordinator(org.omg.CosTransactions.Control control) {
    if (control == null)
        return null;
    UidCoordinator toReturn = null;
    try {
        Coordinator coord = control.get_coordinator();
        if (coord != null) {
            toReturn = getUidCoordinator(coord);
            coord = null;
        } else
            throw new BAD_PARAM(0, CompletionStatus.COMPLETED_NO);
    } catch (Exception e) {
        /*
	     * Can't be an Arjuna action, so ignore.
	     */
        toReturn = null;
    }
    return toReturn;
}
Also used : UidCoordinator(com.arjuna.ArjunaOTS.UidCoordinator) BAD_PARAM(org.omg.CORBA.BAD_PARAM) UidCoordinator(com.arjuna.ArjunaOTS.UidCoordinator) Coordinator(org.omg.CosTransactions.Coordinator)

Example 9 with Coordinator

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

the class RecoveredServerTransaction method addResourceRecord.

/**
 * Allows a new Resource to be added to the transaction. Typically this is
 * used to replace a Resource that has failed and cannot be recovered on
 * it's original IOR.
 */
public void addResourceRecord(Uid rcUid, Resource r) {
    Coordinator coord = null;
    AbstractRecord corbaRec = createOTSRecord(true, r, coord, rcUid);
    addRecord(corbaRec);
}
Also used : AbstractRecord(com.arjuna.ats.arjuna.coordinator.AbstractRecord) Coordinator(org.omg.CosTransactions.Coordinator)

Example 10 with Coordinator

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

the class RecoveredServerTransaction method addResourceRecord.

/**
 * Allows a new Resource to be added to the transaction. Typically this is
 * used to replace a Resource that has failed and cannot be recovered on
 * it's original IOR.
 */
public void addResourceRecord(Uid rcUid, Resource r) {
    Coordinator coord = null;
    AbstractRecord corbaRec = createOTSRecord(true, r, coord, rcUid);
    addRecord(corbaRec);
}
Also used : AbstractRecord(com.arjuna.ats.arjuna.coordinator.AbstractRecord) Coordinator(org.omg.CosTransactions.Coordinator)

Aggregations

Coordinator (org.omg.CosTransactions.Coordinator)47 SystemException (org.omg.CORBA.SystemException)32 UNKNOWN (org.omg.CORBA.UNKNOWN)15 Control (org.omg.CosTransactions.Control)14 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)13 BAD_PARAM (org.omg.CORBA.BAD_PARAM)12 Unavailable (org.omg.CosTransactions.Unavailable)11 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)10 Terminator (org.omg.CosTransactions.Terminator)10 ServerControl (com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl)9 UidCoordinator (com.arjuna.ArjunaOTS.UidCoordinator)6 Uid (com.arjuna.ats.arjuna.common.Uid)6 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)6 ORB (com.arjuna.orbportability.ORB)6 Any (org.omg.CORBA.Any)6 TRANSACTION_REQUIRED (org.omg.CORBA.TRANSACTION_REQUIRED)6 TransactionalObject (org.omg.CosTransactions.TransactionalObject)6 ServiceContext (org.omg.IOP.ServiceContext)6 AbstractRecord (com.arjuna.ats.arjuna.coordinator.AbstractRecord)5 PropagationContext (org.omg.CosTransactions.PropagationContext)5