Search in sources :

Example 11 with Status

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

the class TransactionCache method get_status.

/**
 * Get the status of a transaction
 */
public static Status get_status(Uid actionUid, String theType) throws SystemException {
    Status theStatus = Status.StatusUnknown;
    TransactionCacheItem cacheItem = get(actionUid, theType);
    if (cacheItem != null) {
        synchronized (cacheItem) {
            RecoveringTransaction theTransaction = cacheItem.freshTransaction();
            if (theTransaction != null) {
                theStatus = theTransaction.get_status();
                // remember the status in the cacheitem
                cacheItem.setStatus(theStatus);
            }
        }
    }
    return theStatus;
}
Also used : Status(org.omg.CosTransactions.Status)

Example 12 with Status

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

the class RecoveredServerTransaction method getStatusFromParent.

private Status getStatusFromParent() {
    org.omg.CosTransactions.Status theStatus = org.omg.CosTransactions.Status.StatusUnknown;
    // This variable is applied with Orbix
    int not_exist_count;
    if ((super._recoveryCoordinator != null) && (get_status() == org.omg.CosTransactions.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 = org.omg.CosTransactions.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 : ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) OBJECT_NOT_EXIST(org.omg.CORBA.OBJECT_NOT_EXIST) Status(org.omg.CosTransactions.Status) 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)

Example 13 with Status

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

the class RecoveredTransaction method replayPhase2.

/**
 * Causes phase 2 of the commit protocol to be replayed.
 */
public void replayPhase2() {
    _recoveryStatus = RecoveryStatus.REPLAYING;
    Status theStatus = get_status();
    if (jtsLogger.logger.isDebugEnabled()) {
        jtsLogger.logger.debug("RecoveredTransaction.replayPhase2 (" + get_uid() + ") - status = " + Utility.stringStatus(theStatus));
    }
    if ((theStatus == Status.StatusPrepared) || (theStatus == Status.StatusCommitting) || (theStatus == Status.StatusCommitted)) {
        phase2Commit(_reportHeuristics);
        _recoveryStatus = RecoveryStatus.REPLAYED;
        _txStatus = Status.StatusCommitted;
    } else if ((theStatus == Status.StatusRolledBack) || (theStatus == Status.StatusRollingBack) || (theStatus == Status.StatusMarkedRollback)) {
        phase2Abort(_reportHeuristics);
        _recoveryStatus = RecoveryStatus.REPLAYED;
        _txStatus = Status.StatusRolledBack;
    } else {
        jtsLogger.i18NLogger.warn_recovery_transactions_RecoveredTransaction_6(Utility.stringStatus(theStatus));
        _recoveryStatus = RecoveryStatus.REPLAY_FAILED;
    }
    if (jtsLogger.logger.isDebugEnabled()) {
        jtsLogger.logger.debug("RecoveredTransaction.replayPhase2 (" + get_uid() + ") - status = " + Utility.stringStatus(theStatus));
    }
}
Also used : StateStatus(com.arjuna.ats.arjuna.objectstore.StateStatus) Status(org.omg.CosTransactions.Status)

Example 14 with Status

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

the class ServerTransactionRecoveryModule method recoverTransaction.

protected void recoverTransaction(Uid tranUid) {
    if (jtsLogger.logger.isDebugEnabled()) {
        jtsLogger.logger.debug("ServerTransactionRecoveryModule.recoverTransaction()" + tranUid + ")");
    }
    Status currentStatus = Status.StatusUnknown;
    CachedRecoveredTransaction cachedRecoveredTransaction = new CachedRecoveredTransaction(tranUid, _transactionType);
    currentStatus = cachedRecoveredTransaction.get_status();
    if (jtsLogger.logger.isDebugEnabled()) {
        jtsLogger.logger.debug("Activated transaction " + tranUid + " status = " + Utility.stringStatus(currentStatus));
    }
    // but first check that the original transaction isn't in mid-flight
    if (cachedRecoveredTransaction.originalBusy() && (currentStatus != Status.StatusPrepared)) {
        if (jtsLogger.logger.isDebugEnabled()) {
            jtsLogger.logger.debug("Transaction " + tranUid + " still busy");
        }
        return;
    }
    cachedRecoveredTransaction.replayPhase2();
    cachedRecoveredTransaction = null;
}
Also used : StateStatus(com.arjuna.ats.arjuna.objectstore.StateStatus) Status(org.omg.CosTransactions.Status)

Example 15 with Status

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

the class SynchTest method test.

@Test
public void test() {
    org.omg.CosTransactions.Status status = Status.StatusUnknown;
    tranobject_i localObject = null;
    demosync sync = null;
    ORB myORB = null;
    RootOA myOA = null;
    try {
        ServerORB orb = new ServerORB();
        myORB = orb.getORB();
        myOA = orb.getOA();
        Control myControl = null;
        org.omg.CosTransactions.Current current = OTSManager.get_current();
        Coordinator coord = null;
        sync = new demosync();
        localObject = new tranobject_i();
        current.begin();
        myControl = current.get_control();
        coord = myControl.get_coordinator();
        coord.register_resource(localObject.getReference());
        coord.register_synchronization(sync.getReference());
        try {
            current.commit(true);
        } catch (TRANSACTION_ROLLEDBACK e1) {
            System.out.println("Transaction rolledback");
        }
        try {
            status = coord.get_status();
        } catch (SystemException ex) {
            // assume reference no longer valid!
            status = Status.StatusUnknown;
        }
    } catch (UserException e1) {
        fail("Caught UserException: " + e1);
        e1.printStackTrace();
    } catch (SystemException e2) {
        fail("Caught SystemException: " + e2);
        e2.printStackTrace();
    }
    System.out.print("Final action status: " + com.arjuna.ats.jts.utils.Utility.stringStatus(status));
    System.out.println("\nTest completed successfully.");
    myOA.shutdownObject(sync);
    myOA.shutdownObject(localObject);
    myOA.destroy();
    myORB.shutdown();
}
Also used : com.hp.mwtests.ts.jts.orbspecific.resources.tranobject_i(com.hp.mwtests.ts.jts.orbspecific.resources.tranobject_i) com.hp.mwtests.ts.jts.orbspecific.resources.demosync(com.hp.mwtests.ts.jts.orbspecific.resources.demosync) RootOA(com.arjuna.orbportability.RootOA) Coordinator(org.omg.CosTransactions.Coordinator) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) Control(org.omg.CosTransactions.Control) SystemException(org.omg.CORBA.SystemException) Status(org.omg.CosTransactions.Status) UserException(org.omg.CORBA.UserException) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Aggregations

Status (org.omg.CosTransactions.Status)18 SystemException (org.omg.CORBA.SystemException)9 StateStatus (com.arjuna.ats.arjuna.objectstore.StateStatus)8 Test (org.junit.Test)5 Control (org.omg.CosTransactions.Control)5 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)4 ORB (com.arjuna.orbportability.ORB)4 RootOA (com.arjuna.orbportability.RootOA)4 Coordinator (org.omg.CosTransactions.Coordinator)4 Inactive (org.omg.CosTransactions.Inactive)4 NotPrepared (org.omg.CosTransactions.NotPrepared)4 OBJECT_NOT_EXIST (org.omg.CORBA.OBJECT_NOT_EXIST)3 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)3 TRANSIENT (org.omg.CORBA.TRANSIENT)3 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)2 TransactionFactoryImple (com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple)2 ServerControl (com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl)2 ServerRecoveryTopLevelAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerRecoveryTopLevelAction)2 RecoveryStatus (com.arjuna.ats.internal.jts.recovery.transactions.RecoveryStatus)2 AtomicResource (com.hp.mwtests.ts.jts.orbspecific.resources.AtomicResource)2