Search in sources :

Example 11 with Inactive

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

the class GenericRecoveryCoordinator method get_status.

private static Status get_status(Uid actionUid, Uid processUid) throws Inactive {
    Status status = Status.StatusUnknown;
    boolean transactionActive = true;
    try {
        status = StatusChecker.get_current_status(actionUid, processUid);
    } catch (Inactive e) {
        // original process is dead.
        transactionActive = false;
    }
    boolean hasBeenRecovering = false;
    for (; ; ) {
        if (transactionActive) {
            Object o = com.arjuna.ats.internal.jts.recovery.transactions.RecoveredTransactionReplayer.isPresent(actionUid);
            if (o != null) {
                hasBeenRecovering = true;
                synchronized (o) {
                    try {
                        o.wait();
                    } catch (Exception e) {
                    }
                }
            } else {
                if (hasBeenRecovering)
                    throw new Inactive();
                else
                    break;
            }
        } else
            throw new Inactive();
    }
    return status;
}
Also used : StateStatus(com.arjuna.ats.arjuna.objectstore.StateStatus) Status(org.omg.CosTransactions.Status) Inactive(org.omg.CosTransactions.Inactive) SystemException(org.omg.CORBA.SystemException) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException)

Example 12 with Inactive

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

the class StatusChecker method getStatus.

/**
 *  try to get the status from a factory and convert to our way.
 *  factory must not be null
 *  itemUid is the store id as in _itemFromUid
 */
private Status getStatus(Uid transactionUid, FactoryContactItem item, boolean checkTheObjectStore) throws Inactive {
    if (jtsLogger.logger.isDebugEnabled()) {
        jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ", " + item + ", " + checkTheObjectStore + ")");
    }
    ArjunaFactory factory = item.getFactory();
    if (factory != null) {
        Status otsStatus = Status.StatusUnknown;
        boolean originalDead = false;
        try {
            otid_t otid = Utility.uidToOtid(transactionUid);
            otsStatus = factory.getCurrentStatus(otid);
            if (jtsLogger.logger.isDebugEnabled()) {
                jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ") - current status = " + Utility.stringStatus(otsStatus));
            }
            if (otsStatus == Status.StatusNoTransaction) {
                otsStatus = factory.getStatus(otid);
                if (jtsLogger.logger.isDebugEnabled()) {
                    jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ") - stored status = " + Utility.stringStatus(otsStatus));
                }
                switch(otsStatus.value()) {
                    case Status._StatusNoTransaction:
                        // return Status.StatusRolledBack;
                        return otsStatus;
                    case Status._StatusUnknown:
                        return otsStatus;
                    default:
                        {
                            /*
                * We got an answer! This probably means that the
                * factory has just finished with the transaction, but
                * the state hasn't been removed by the file system yet
                * - we don't sync the removal to improve performance.
                */
                            jtsLogger.i18NLogger.warn_recovery_contact_StatusChecker_3(transactionUid);
                            otsStatus = Status.StatusUnknown;
                        }
                        break;
                }
            }
            if (jtsLogger.logger.isDebugEnabled()) {
                jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ") - Status = " + Utility.stringStatus(otsStatus));
            }
            item.markAsAlive();
        } catch (NO_IMPLEMENT ex_noimp) {
            if (jtsLogger.logger.isDebugEnabled()) {
                jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ") - NO_IMPLEMENT = dead");
            }
            originalDead = true;
        // orbix seems to count unreachable as transient. Over infinite time, all
        // addresses are valid
        } catch (TRANSIENT ex_trans) {
            if (ORBInfo.getOrbEnumValue() == ORBType.JACORB) {
                // the original application has (probably) died
                if (jtsLogger.logger.isDebugEnabled()) {
                    jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ") - TRANSIENT = dead");
                }
                originalDead = true;
            }
        } catch (COMM_FAILURE ex_comm) {
            if (ORBInfo.getOrbEnumValue() == ORBType.JAVAIDL) {
                // the original application has (probably) died
                if (jtsLogger.logger.isDebugEnabled()) {
                    jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ") - COMM_FAILURE = dead");
                }
                originalDead = true;
            } else /*
	     * Probably the original application has died, but only just - do
	     * not mark either way.
	     */
            if (jtsLogger.logger.isDebugEnabled()) {
                jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ") - COMM_FAILURE = live");
            }
        } catch (OBJECT_NOT_EXIST ex_noobj) {
            // the original process must have gone away, and another one
            // come up in the same place
            // (or, just possibly, the original closed the ots)
            originalDead = true;
            if (jtsLogger.logger.isDebugEnabled()) {
                jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ") - OBJECT_NOT_EXIST = dead");
            }
        } catch (BAD_PARAM ex_badparam) {
            jtsLogger.i18NLogger.warn_recovery_contact_StatusChecker_9();
        // the transactionUid is invalid !
        } catch (NoTransaction ex_notran) {
            jtsLogger.i18NLogger.warn_recovery_contact_StatusChecker_10();
        // the transactionUid is invalid !
        // no transaction
        } catch (SystemException ex_corba) {
            // why did this happen ?
            if (ORBInfo.getOrbEnumValue() == ORBType.JAVAIDL) {
                // the original application has (probably) died
                if (jtsLogger.logger.isDebugEnabled()) {
                    jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ") - COMM_FAILURE = dead");
                }
                originalDead = true;
            }
            jtsLogger.i18NLogger.warn_recovery_contact_StatusChecker_11(ex_corba);
        } catch (Exception ex_other) {
            // this really shouldn't happen
            jtsLogger.i18NLogger.warn_recovery_contact_StatusChecker_12(ex_other);
        }
        if (originalDead) {
            item.markAsDead();
            throw new Inactive();
        } else {
            return otsStatus;
        }
    } else {
        // factory in item is null - process already dead
        if (jtsLogger.logger.isDebugEnabled()) {
            jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ") -  no factory, process previously dead");
        }
        if (checkTheObjectStore) {
            try {
                Status s = OTSManager.factory().getStatus(transactionUid);
                if (s == Status.StatusCommitting)
                    return Status.StatusCommitted;
                else {
                    if (s == Status.StatusRollingBack)
                        return Status.StatusRolledBack;
                }
                return s;
            } catch (NoTransaction e1) {
                return Status.StatusNoTransaction;
            } catch (SystemException e2) {
                return Status.StatusUnknown;
            }
        } else {
            throw new Inactive();
        }
    }
}
Also used : Status(org.omg.CosTransactions.Status) NO_IMPLEMENT(org.omg.CORBA.NO_IMPLEMENT) NoTransaction(org.omg.CosTransactions.NoTransaction) COMM_FAILURE(org.omg.CORBA.COMM_FAILURE) CosTransactions.otid_t(org.omg.CosTransactions.otid_t) BAD_PARAM(org.omg.CORBA.BAD_PARAM) SystemException(org.omg.CORBA.SystemException) OBJECT_NOT_EXIST(org.omg.CORBA.OBJECT_NOT_EXIST) SystemException(org.omg.CORBA.SystemException) Inactive(org.omg.CosTransactions.Inactive) ArjunaFactory(com.arjuna.ArjunaOTS.ArjunaFactory) TRANSIENT(org.omg.CORBA.TRANSIENT)

Example 13 with Inactive

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

the class ServerTopLevelAction method registerResource.

protected boolean registerResource(Coordinator theCoordinator) {
    boolean result = false;
    if (theCoordinator != null) {
        if (_registered)
            return true;
        try {
            /*
		 * Register resource and pass RecoveryCoordinator reference
		 * to the interposed transaction to save and restore.
		 */
            RecoveryCoordinator recoveryCoord = theCoordinator.register_resource(_resourceRef);
            _registered = true;
            if (!_theControl.isWrapper()) {
                ServerTransaction tx = (ServerTransaction) _theControl.getImplHandle();
                if (tx != null) {
                    tx.setRecoveryCoordinator(recoveryCoord);
                    result = true;
                } else {
                    result = false;
                    jtsLogger.i18NLogger.warn_orbspecific_interposition_resources_arjuna_ipfailed("ServerTopLevelAction");
                }
            } else
                result = true;
        } catch (ClassCastException classCastException) {
            jtsLogger.i18NLogger.warn_orbspecific_interposition_resources_arjuna_generror("ServerTopLevelAction.registerResource", classCastException);
        } catch (Inactive ine) {
            jtsLogger.i18NLogger.warn_server_top_level_action_inactive();
            jtsLogger.i18NLogger.debug_orbspecific_interposition_resources_arjuna_generror("ServerTopLevelAction.registerResource", ine);
            transactionInactive = true;
        } catch (TRANSACTION_ROLLEDBACK ex1) {
            jtsLogger.i18NLogger.warn_orbspecific_interposition_resources_arjuna_generror("ServerTopLevelAction.registerResource", ex1);
        } catch (INVALID_TRANSACTION ex2) {
            jtsLogger.i18NLogger.warn_orbspecific_interposition_resources_arjuna_generror("ServerTopLevelAction.registerResource", ex2);
        } catch (Exception e) {
            jtsLogger.i18NLogger.warn_orbspecific_interposition_resources_arjuna_generror("ServerTopLevelAction.registerResource", e);
        }
    } else {
        jtsLogger.i18NLogger.warn_orbspecific_interposition_resources_arjuna_nocoord("ServerTopLevelAction.registerResource");
    }
    return result;
}
Also used : INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) RecoveryCoordinator(org.omg.CosTransactions.RecoveryCoordinator) Inactive(org.omg.CosTransactions.Inactive) ServerTransaction(com.arjuna.ats.internal.jts.orbspecific.interposition.coordinator.ServerTransaction) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK) SystemException(org.omg.CORBA.SystemException)

Example 14 with Inactive

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

the class TransactionFactoryUnitTest method testBasic.

@Test
public void testBasic() throws Exception {
    TransactionFactoryImple factory = new TransactionFactoryImple("test");
    arjPropertyManager.getCoordinatorEnvironmentBean().setEnableStatistics(true);
    try {
        factory.numberOfTransactions(TransactionType.TransactionTypeActive);
    // fail();
    } catch (final Inactive ex) {
    } catch (final NoTransaction ex) {
    }
    ControlImple tx = factory.createLocal(1000);
    assertTrue(tx != null);
    org.omg.CosTransactions.otid_t[] txId = null;
    try {
        txId = factory.numberOfTransactions(TransactionType.TransactionTypeActive);
    } catch (final Throwable ex) {
        fail();
    }
    try {
        if (factory.getChildTransactions(txId[0]) != null)
            fail();
    } catch (final Throwable ex) {
        fail();
    }
    org.omg.CosTransactions.Status status = factory.getCurrentStatus(txId[0]);
    assertTrue(status == org.omg.CosTransactions.Status.StatusActive);
    assertTrue(factory.getStatus(txId[0]) == org.omg.CosTransactions.Status.StatusActive);
    Control proxy = factory.createProxy(tx.get_coordinator(), tx.get_terminator());
    assertTrue(proxy != null);
    Control propagated = factory.createPropagatedControl(tx.get_coordinator());
    assertTrue(propagated != null);
    assertTrue(Utility.getUid(proxy).equals(Utility.getUid(propagated)));
    GlobalTransactionInfo info = factory.getGlobalInfo();
    assertTrue(info != null);
    assertEquals(info.totalNumberOfTransactions, 1);
    assertEquals(info.numberOfHeuristics, 0);
    factory.numberOfTransactions(TransactionType.TransactionTypeUnresolved);
    try {
        tx.getImplHandle().rollback();
    } catch (final Throwable ex) {
    }
}
Also used : NoTransaction(org.omg.CosTransactions.NoTransaction) CosTransactions.otid_t(org.omg.CosTransactions.otid_t) GlobalTransactionInfo(com.arjuna.ArjunaOTS.GlobalTransactionInfo) Control(org.omg.CosTransactions.Control) TransactionFactoryImple(com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple) Status(org.omg.CosTransactions.Status) Inactive(org.omg.CosTransactions.Inactive) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

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