Search in sources :

Example 51 with BAD_PARAM

use of org.omg.CORBA.BAD_PARAM in project narayana by jbosstm.

the class ArjunaTransactionImple method is_same_transaction.

public boolean is_same_transaction(Coordinator tc) throws SystemException {
    if (tc == null)
        return false;
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ArjunaTransactionImple::is_same_transaction comparing hash codes: < " + tc.hash_transaction() + ", " + hash_transaction() + " >");
    }
    if (tc.hash_transaction() != hash_transaction())
        return false;
    boolean result = false;
    try {
        UidCoordinator ptr = com.arjuna.ArjunaOTS.UidCoordinatorHelper.narrow(tc);
        if (ptr != null) {
            /*
				 * Must be an Arjuna coordinator.
				 */
            String myUid = uid();
            String compareUid = ptr.uid();
            if (jtsLogger.logger.isTraceEnabled()) {
                jtsLogger.logger.trace("ArjunaTransactionImple::is_same_transaction comparing uids < " + compareUid + ", " + myUid + " >");
            }
            if (myUid.compareTo(compareUid) == 0)
                result = true;
            myUid = null;
            compareUid = null;
            ptr = null;
        } else
            throw new BAD_PARAM();
    } catch (SystemException e) {
    /*
			 * Narrow failed, so can't be an Arjuna Uid. Therefore, the answer
			 * must be false.
			 */
    }
    return result;
}
Also used : UidCoordinator(com.arjuna.ArjunaOTS.UidCoordinator) SystemException(org.omg.CORBA.SystemException) BAD_PARAM(org.omg.CORBA.BAD_PARAM)

Example 52 with BAD_PARAM

use of org.omg.CORBA.BAD_PARAM in project narayana by jbosstm.

the class OTSImpleManager method init.

private static final synchronized void init() {
    if (_current == null) {
        if (OTSImpleManager._theFactory == null) {
            /*
				 * Only check once, when the factory is first created.
				 */
            int resolver = Services.CONFIGURATION_FILE;
            boolean requireTransactionManager = false;
            if (jtsPropertyManager.getJTSEnvironmentBean().isTransactionManager()) {
                requireTransactionManager = true;
                String resolveMechanism = opPropertyManager.getOrbPortabilityEnvironmentBean().getResolveService();
                if (resolveMechanism.compareTo("NAME_SERVICE") == 0)
                    resolver = Services.NAME_SERVICE;
                else {
                    if (resolveMechanism.compareTo("BIND_CONNECT") == 0)
                        resolver = Services.BIND_CONNECT;
                }
            }
            if (requireTransactionManager) {
                try {
                    if (resolver != Services.BIND_CONNECT) {
                        String[] params = new String[1];
                        params[0] = Services.otsKind;
                        org.omg.CORBA.Object obj = ORBManager.getServices().getService(Services.transactionService, params, resolver);
                        params = null;
                        OTSImpleManager._theFactoryRef = org.omg.CosTransactions.TransactionFactoryHelper.narrow(obj);
                    } else {
                    }
                    if (OTSImpleManager._theFactoryRef == null)
                        throw new BAD_PARAM();
                } catch (InvalidName e1) {
                    jtsLogger.i18NLogger.warn_otsserverfailed(e1);
                    throw new FatalError(e1.toString(), e1);
                } catch (BAD_PARAM ex1) {
                    jtsLogger.i18NLogger.warn_otsserverfailed(ex1);
                    throw new FatalError(ex1.toString(), ex1);
                } catch (IOException e2) {
                    jtsLogger.i18NLogger.warn_otsservererror(e2);
                    throw new FatalError(e2.toString(), e2);
                } catch (SystemException e3) {
                    jtsLogger.i18NLogger.warn_otsservererror(e3);
                    throw new FatalError(e3.toString(), e3);
                } catch (UserException e4) {
                    jtsLogger.i18NLogger.warn_otsservererror(e4);
                    throw new FatalError(e4.toString(), e4);
                }
            } else {
                /* force to be local */
                OTSImpleManager._theFactory = new TransactionFactoryImple();
            }
        }
        if (OTSImpleManager._current == null) {
            try {
                OTSImpleManager._current = new CurrentImple();
                OTSImpleManager._currentRef = OTSImpleManager._current;
            } catch (Exception e) {
                OTSImpleManager._current = null;
                throw new com.arjuna.ats.arjuna.exceptions.FatalError("OTSImpleManager.current: " + e.toString(), e);
            }
        }
    }
}
Also used : BAD_PARAM(org.omg.CORBA.BAD_PARAM) FatalError(com.arjuna.ats.arjuna.exceptions.FatalError) IOException(java.io.IOException) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) SystemException(org.omg.CORBA.SystemException) UserException(org.omg.CORBA.UserException) IOException(java.io.IOException) FatalError(com.arjuna.ats.arjuna.exceptions.FatalError) InvalidName(org.omg.CORBA.ORBPackage.InvalidName) SystemException(org.omg.CORBA.SystemException) TransactionFactoryImple(com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple) UserException(org.omg.CORBA.UserException)

Example 53 with BAD_PARAM

use of org.omg.CORBA.BAD_PARAM in project narayana by jbosstm.

the class ContextManager method createProxy.

public final ControlWrapper createProxy(org.omg.CORBA.Any ctx) throws SystemException {
    String stringRef = null;
    try {
        stringRef = ctx.extract_string();
        if (stringRef.startsWith(IORTag)) {
            org.omg.CORBA.Object obj = ORBManager.getORB().orb().string_to_object(stringRef);
            Coordinator theCoordinator = org.omg.CosTransactions.CoordinatorHelper.narrow(obj);
            if (theCoordinator == null)
                throw new BAD_PARAM();
            return new ControlWrapper(TransactionFactoryImple.createProxy(theCoordinator, null));
        } else
            return null;
    } catch (BAD_PARAM e1) {
        jtsLogger.i18NLogger.warn_context_genfail("ContextManager " + stringRef, e1);
    } catch (Exception e2) {
        jtsLogger.i18NLogger.warn_context_genfail("ContextManager", e2);
        throw new UNKNOWN(e2.toString());
    }
    return null;
}
Also used : ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) BAD_PARAM(org.omg.CORBA.BAD_PARAM) UNKNOWN(org.omg.CORBA.UNKNOWN) Coordinator(org.omg.CosTransactions.Coordinator) SystemException(org.omg.CORBA.SystemException) EmptyStackException(java.util.EmptyStackException)

Example 54 with BAD_PARAM

use of org.omg.CORBA.BAD_PARAM in project narayana by jbosstm.

the class TransactionFactoryImple method getTransactionInfo.

/**
 * @return information on a specific transaction.
 * @since JTS 2.1.2.
 */
public TransactionInfo getTransactionInfo(Uid u) throws org.omg.CosTransactions.NoTransaction, SystemException {
    if (!u.valid())
        throw new BAD_PARAM(jtsLogger.i18NLogger.get_orbspecific_invaliduid() + " " + u);
    else {
        try {
            synchronized (ControlImple.allControls) {
                ControlImple ctx = (ControlImple) ControlImple.allControls.get(u);
                if (ctx != null) {
                    TransactionInfo info = new TransactionInfo();
                    info.currentDepth = ctx.getImplHandle().getHierarchy().depth();
                    TransactionReaper reaper = TransactionReaper.transactionReaper();
                    info.timeout = reaper.getTimeout(ctx);
                    info.numberOfThreads = ctx.getImplHandle().activeThreads();
                    return info;
                } else
                    throw new NoTransaction();
            }
        } catch (NoTransaction ex) {
            throw ex;
        } catch (Exception e) {
            e.printStackTrace();
            throw new UNKNOWN();
        }
    }
}
Also used : NoTransaction(org.omg.CosTransactions.NoTransaction) BAD_PARAM(org.omg.CORBA.BAD_PARAM) TransactionInfo(com.arjuna.ArjunaOTS.TransactionInfo) GlobalTransactionInfo(com.arjuna.ArjunaOTS.GlobalTransactionInfo) UNKNOWN(org.omg.CORBA.UNKNOWN) TransactionReaper(com.arjuna.ats.arjuna.coordinator.TransactionReaper) SystemException(org.omg.CORBA.SystemException) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException)

Example 55 with BAD_PARAM

use of org.omg.CORBA.BAD_PARAM 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)

Aggregations

BAD_PARAM (org.omg.CORBA.BAD_PARAM)69 SystemException (org.omg.CORBA.SystemException)31 UNKNOWN (org.omg.CORBA.UNKNOWN)27 Any (org.omg.CORBA.Any)22 ServiceContext (org.omg.IOP.ServiceContext)21 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)13 BadParametersException (com.cosylab.acs.maci.BadParametersException)13 CoreException (com.cosylab.acs.maci.CoreException)13 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)13 NO_RESOURCES (org.omg.CORBA.NO_RESOURCES)12 TRANSACTION_REQUIRED (org.omg.CORBA.TRANSACTION_REQUIRED)12 Coordinator (org.omg.CosTransactions.Coordinator)12 UidCoordinator (com.arjuna.ArjunaOTS.UidCoordinator)9 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)8 Object (org.omg.CORBA.Object)8 Unavailable (org.omg.CosTransactions.Unavailable)8 FormatMismatch (org.omg.IOP.CodecPackage.FormatMismatch)8 TypeMismatch (org.omg.IOP.CodecPackage.TypeMismatch)8 URI (java.net.URI)7 URISyntaxException (java.net.URISyntaxException)7