Search in sources :

Example 6 with ServerTopLevelAction

use of com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction in project narayana by jbosstm.

the class Interposition method setupHierarchy.

/*
     * Assume that all actions in the imported hierarchy are of the same
     * type, i.e., all JBoss transactions.
     *
     * Because of the way garbage collection works in the ORB we have to
     * run an explicit garbage collection phase for finished hierarchies.
     */
public synchronized ControlImple setupHierarchy(PropagationContext context) throws SystemException {
    ControlImple controlPtr = null;
    Uid theUid = null;
    ServerTopLevelAction proxyAction = null;
    if (context.parents.length == 0)
        theUid = Utility.otidToUid(context.current.otid);
    else
        theUid = Utility.otidToUid(context.parents[context.parents.length - 1].otid);
    proxyAction = present(theUid);
    if (proxyAction == null) {
        /*
	     * Create a new proxyAction element and return the
	     * "current" transaction.
	     */
        controlPtr = createHierarchy(context, theUid);
    } else {
        /*
	     * Check hierarchy of existing element.
	     */
        controlPtr = checkHierarchy(proxyAction, context);
        proxyAction = null;
    }
    return controlPtr;
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) ServerTopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple)

Example 7 with ServerTopLevelAction

use of com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction in project narayana by jbosstm.

the class RestrictedInterposition method createHierarchy.

protected synchronized ControlImple createHierarchy(PropagationContext ctx, Uid tlUid) throws SystemException {
    /*
         * Start at the parent and work our way down to "current". The current
         * transaction is not in the IDL sequence, but sent as separate field of
         * the propagation context. This tends to make the code more complex
         * than it would be if the entire hierarchy was represented in one
         * place.
         */
    int depth = ctx.parents.length;
    ServerTopLevelAction tlAction = null;
    Coordinator tmpCoord = null;
    Terminator tmpTerm = null;
    if (depth == 0) {
        tmpCoord = ctx.current.coord;
        tmpTerm = ctx.current.term;
    } else {
        tmpCoord = ctx.parents[depth - 1].coord;
        tmpTerm = ctx.parents[depth - 1].term;
    }
    ServerControl control = ServerFactory.create_transaction(tlUid, null, null, tmpCoord, tmpTerm, ctx.timeout);
    tlAction = new ServerRestrictedTopLevelAction(control);
    if (!tlAction.valid()) {
        try {
            tlAction.rollback();
            tlAction = null;
        } catch (Exception e) {
        }
        throw new TRANSACTION_ROLLEDBACK();
    }
    ServerTopLevelAction newElement = tlAction;
    super._head.add(newElement);
    if (// current is a nested transaction
    depth > 0) {
        /*
             * Now deal with any nested transactions. As we create, register
             * with the original transactions.
             */
        ServerRestrictedNestedAction nestedAction = null;
        for (int i = depth - 2; i >= 0; i--) {
            tmpCoord = ctx.parents[i].coord;
            tmpTerm = ctx.parents[i].term;
            control = ServerFactory.create_subtransaction(Utility.otidToUid(ctx.parents[i].otid), tmpCoord, tmpTerm, control);
            nestedAction = new ServerRestrictedNestedAction(control);
            if (!nestedAction.valid()) {
                try {
                    nestedAction.rollback();
                    nestedAction = null;
                } catch (Exception e) {
                }
                throw new TRANSACTION_ROLLEDBACK();
            }
            /*
                 * Add transaction resource to list.
                 */
            tlAction.addChild(nestedAction);
        }
        /*
             * Now deal with current transaction. If there is only one
             * transaction we do nothing.
             */
        tmpCoord = ctx.current.coord;
        tmpTerm = ctx.current.term;
        control = ServerFactory.create_subtransaction(Utility.otidToUid(ctx.current.otid), tmpCoord, tmpTerm, control);
        nestedAction = new ServerRestrictedNestedAction(control);
        if (!nestedAction.valid()) {
            try {
                nestedAction.rollback();
                nestedAction = null;
            } catch (Exception e) {
            }
            throw new TRANSACTION_ROLLEDBACK();
        }
        tlAction.addChild(nestedAction);
    }
    return control;
}
Also used : ServerTopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ServerRestrictedTopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.restricted.ServerRestrictedTopLevelAction) Terminator(org.omg.CosTransactions.Terminator) ServerRestrictedNestedAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.restricted.ServerRestrictedNestedAction) Coordinator(org.omg.CosTransactions.Coordinator) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK) SystemException(org.omg.CORBA.SystemException)

Example 8 with ServerTopLevelAction

use of com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction in project narayana by jbosstm.

the class StrictInterposition method createHierarchy.

protected synchronized ControlImple createHierarchy(PropagationContext ctx, Uid currentUid) throws SystemException {
    /*
	 * Start at the parent and work our way down to "current". The current
	 * transaction is not in the IDL sequence, but sent as separate field
	 * of the propagation context. This tends to make the code more
	 * complex than it would be if the entire hierarchy was represented in
	 * one place.
	 */
    /*
	 * We only ever register the current transaction with its parent, and
	 * as each transaction commits, it registers its parent with the
	 * "real" parent.
	 */
    int depth = ctx.parents.length;
    ServerResource action = null;
    Coordinator tmpCoord = null;
    Terminator tmpTerm = null;
    if (depth == 0) {
        tmpCoord = ctx.current.coord;
        tmpTerm = ctx.current.term;
    } else {
        tmpCoord = ctx.parents[depth - 1].coord;
        tmpTerm = ctx.parents[depth - 1].term;
    }
    if (// terminator my correctory be null
    tmpCoord == null)
        return null;
    ServerControl control = ServerFactory.create_transaction(currentUid, null, null, tmpCoord, tmpTerm, ctx.timeout);
    action = new ServerStrictTopLevelAction(control, ((depth == 0) ? true : false));
    if (!action.valid()) {
        try {
            // does dispose as well!
            ((ServerStrictTopLevelAction) action).rollback();
            action = null;
        } catch (Exception e) {
        }
        throw new TRANSACTION_ROLLEDBACK();
    }
    ServerTopLevelAction newElement = (ServerStrictTopLevelAction) action;
    _head.add(newElement);
    if (// current is a nested transaction
    depth > 0) {
        /*
	     * Now deal with any nested transactions.
	     * As we create, register with the original transactions.
	     */
        ServerResource nestedAction = null;
        for (int i = depth - 2; i >= 0; i--) {
            tmpCoord = ctx.parents[i].coord;
            tmpTerm = ctx.parents[i].term;
            control = ServerFactory.create_subtransaction(Utility.otidToUid(ctx.parents[i].otid), tmpCoord, tmpTerm, control);
            // not current, so don't register
            nestedAction = new ServerStrictNestedAction(control, false);
            if (!nestedAction.valid()) {
                try {
                    // does dispose as well!
                    ((ServerStrictNestedAction) nestedAction).rollback_subtransaction();
                    nestedAction = null;
                } catch (Exception e) {
                }
                throw new TRANSACTION_ROLLEDBACK();
            }
            /*
		 * Add transaction resource to list.
		 */
            action.addChild((ServerStrictNestedAction) nestedAction);
            action = nestedAction;
        }
        /*
	     * Now deal with current transaction. If there is
	     * only one transaction we do nothing.
	     */
        tmpCoord = ctx.current.coord;
        tmpTerm = ctx.current.term;
        control = ServerFactory.create_subtransaction(Utility.otidToUid(ctx.current.otid), tmpCoord, tmpTerm, control);
        // current, so register
        nestedAction = new ServerStrictNestedAction(control, true);
        if (!nestedAction.valid()) {
            try {
                // does dispose as well!
                ((ServerStrictNestedAction) nestedAction).rollback_subtransaction();
                nestedAction = null;
            } catch (Exception e) {
            }
            throw new TRANSACTION_ROLLEDBACK();
        }
        action.addChild((ServerStrictNestedAction) nestedAction);
    }
    if (jtsLogger.logger.isTraceEnabled())
        compareHierarchies(ctx, newElement);
    return control;
}
Also used : ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ServerTopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction) ServerStrictNestedAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.strict.ServerStrictNestedAction) ServerResource(com.arjuna.ats.internal.jts.interposition.resources.arjuna.ServerResource) Terminator(org.omg.CosTransactions.Terminator) ServerStrictTopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.strict.ServerStrictTopLevelAction) Coordinator(org.omg.CosTransactions.Coordinator) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK) SystemException(org.omg.CORBA.SystemException)

Example 9 with ServerTopLevelAction

use of com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction in project narayana by jbosstm.

the class ServerTopLevelActionUnitTest method testCommit.

@Test
public void testCommit() throws Exception {
    ControlImple cont = new ControlImple(null, null);
    Control theControl = cont.getControl();
    ArjunaTransactionImple tx = cont.getImplHandle();
    ServerControl sc = new ServerControl(tx.get_uid(), theControl, tx, theControl.get_coordinator(), theControl.get_terminator());
    ServerTopLevelAction act = new ServerTopLevelAction(sc);
    assertEquals(act.prepare(), Vote.VoteReadOnly);
    try {
        act.commit();
        fail();
    } catch (final INVALID_TRANSACTION ex) {
    }
    assertTrue(act.getReference() != null);
}
Also used : Control(org.omg.CosTransactions.Control) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ServerTopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Example 10 with ServerTopLevelAction

use of com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction in project narayana by jbosstm.

the class ServerTopLevelActionUnitTest method testCommitOnePhase.

@Test
public void testCommitOnePhase() throws Exception {
    ControlImple cont = new ControlImple(null, null);
    Control theControl = cont.getControl();
    ArjunaTransactionImple tx = cont.getImplHandle();
    ServerControl sc = new ServerControl(tx.get_uid(), theControl, tx, theControl.get_coordinator(), theControl.get_terminator());
    ServerTopLevelAction act = new ServerTopLevelAction(sc);
    act.commit_one_phase();
    assertTrue(act.type() != null);
}
Also used : Control(org.omg.CosTransactions.Control) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ServerTopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Aggregations

ServerTopLevelAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction)11 ServerControl (com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl)8 ControlImple (com.arjuna.ats.internal.jts.orbspecific.ControlImple)7 Uid (com.arjuna.ats.arjuna.common.Uid)4 ArjunaTransactionImple (com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple)4 Test (org.junit.Test)4 SystemException (org.omg.CORBA.SystemException)4 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)4 Control (org.omg.CosTransactions.Control)4 Coordinator (org.omg.CosTransactions.Coordinator)4 Terminator (org.omg.CosTransactions.Terminator)4 ServerResource (com.arjuna.ats.internal.jts.interposition.resources.arjuna.ServerResource)2 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)2 ManagedSynchronizationImple (com.arjuna.ats.internal.jta.resources.jts.orbspecific.ManagedSynchronizationImple)1 TransactionImple (com.arjuna.ats.internal.jta.transaction.jts.TransactionImple)1 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)1 InterpositionCreator (com.arjuna.ats.internal.jts.interposition.resources.arjuna.InterpositionCreator)1 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)1 ServerNestedAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerNestedAction)1 ServerOSINestedAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSINestedAction)1