Search in sources :

Example 11 with ServerControl

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

the class ServerNestedStrictUnitTest 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());
    ServerStrictNestedAction act = new ServerStrictNestedAction(sc, true);
    assertFalse(act.interposeResource());
    act.commit_subtransaction(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) ServerStrictNestedAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.strict.ServerStrictNestedAction) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Example 12 with ServerControl

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

the class ServerTopLevelOSIActionUnitTest 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());
    ServerOSITopLevelAction act = new ServerOSITopLevelAction(sc, true);
    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) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) ServerOSITopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSITopLevelAction) Test(org.junit.Test)

Example 13 with ServerControl

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

the class ServerTopLevelOSIActionUnitTest 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());
    ServerOSITopLevelAction act = new ServerOSITopLevelAction(sc, true);
    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) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) ServerOSITopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSITopLevelAction) Test(org.junit.Test)

Example 14 with ServerControl

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

the class ServerTopLevelOSIActionUnitTest method testRollback.

@Test
public void testRollback() 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());
    ServerOSITopLevelAction act = new ServerOSITopLevelAction(sc, true);
    assertEquals(act.prepare(), Vote.VoteReadOnly);
    try {
        act.rollback();
        fail();
    } catch (final INVALID_TRANSACTION ex) {
    }
    act.forget();
}
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) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) ServerOSITopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSITopLevelAction) Test(org.junit.Test)

Example 15 with ServerControl

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

the class RecoveredServerTransaction method getStatusFromParent.

private Status getStatusFromParent() {
    Status theStatus = Status.StatusUnknown;
    // This variable is applied with Orbix
    int not_exist_count;
    if ((super._recoveryCoordinator != null) && (get_status() == Status.StatusPrepared)) {
        ServerControl sc = new ServerControl((ServerTransaction) this);
        ServerRecoveryTopLevelAction tla = new ServerRecoveryTopLevelAction(sc);
        if (tla.valid()) {
            try {
                theStatus = super._recoveryCoordinator.replay_completion(tla.getReference());
                if (jtsLogger.logger.isDebugEnabled()) {
                    jtsLogger.logger.debug("RecoveredServerTransaction.getStatusFromParent - replay_completion status = " + Utility.stringStatus(theStatus));
                }
            } catch (TRANSIENT ex_trans) {
                /*
                     * A failure that might not occur again if the request is retried. Not definite.
                     */
                jtsLogger.i18NLogger.warn_recovery_transactions_RecoveredServerTransaction_10(get_uid());
                theStatus = Status.StatusUnknown;
            }// What here what should be done for Orbix2000
             catch (OBJECT_NOT_EXIST ex) {
                // i believe this state should be notran - ots explicitly
                // objnotexist is
                // rollback
                theStatus = Status.StatusRolledBack;
                if (jtsLogger.logger.isDebugEnabled()) {
                    jtsLogger.logger.debug("RecoveredServerTransaction.getStatusFromParent -" + " replay_completion got object_not_exist = " + Utility.stringStatus(theStatus));
                }
            } catch (NotPrepared ex1) {
                jtsLogger.i18NLogger.warn_recovery_transactions_RecoveredServerTransaction_12();
                theStatus = Status.StatusActive;
            } catch (Exception e) {
                // Unknown error, so better to do nothing at this stage.
                jtsLogger.i18NLogger.warn_recovery_transactions_RecoveredServerTransaction_13(e);
            }
        } else {
            jtsLogger.i18NLogger.warn_recovery_transactions_RecoveredServerTransaction_14(get_uid());
        }
        // Make sure we "delete" these objects when we are finished
        // with them or there will be a memory leak. If they are deleted
        // "early", and the root coordinator needs them then it will find
        // them unavailable, and will have to retry recovery later.
        sc = null;
        tla = null;
    } else {
        if (jtsLogger.logger.isDebugEnabled()) {
            jtsLogger.logger.debug("RecoveredServerTransaction:getStatusFromParent - " + "no recovcoord or status not prepared");
        }
    }
    return theStatus;
}
Also used : Status(org.omg.CosTransactions.Status) StateStatus(com.arjuna.ats.arjuna.objectstore.StateStatus) RecoveryStatus(com.arjuna.ats.internal.jts.recovery.transactions.RecoveryStatus) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) OBJECT_NOT_EXIST(org.omg.CORBA.OBJECT_NOT_EXIST) ServerRecoveryTopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerRecoveryTopLevelAction) TRANSIENT(org.omg.CORBA.TRANSIENT) NotPrepared(org.omg.CosTransactions.NotPrepared) SystemException(org.omg.CORBA.SystemException) IOException(java.io.IOException) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException)

Aggregations

ServerControl (com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl)33 ControlImple (com.arjuna.ats.internal.jts.orbspecific.ControlImple)21 ArjunaTransactionImple (com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple)20 Test (org.junit.Test)20 Control (org.omg.CosTransactions.Control)20 SystemException (org.omg.CORBA.SystemException)12 Coordinator (org.omg.CosTransactions.Coordinator)9 ServerTopLevelAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction)8 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)8 Terminator (org.omg.CosTransactions.Terminator)8 Uid (com.arjuna.ats.arjuna.common.Uid)6 ServerNestedAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerNestedAction)5 ServerOSITopLevelAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSITopLevelAction)5 ServerResource (com.arjuna.ats.internal.jts.interposition.resources.arjuna.ServerResource)4 ServerOSINestedAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSINestedAction)4 ServerStrictNestedAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.strict.ServerStrictNestedAction)4 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)4 TransIdentity (org.omg.CosTransactions.TransIdentity)4 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)3 ServerRestrictedNestedAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.restricted.ServerRestrictedNestedAction)3