Search in sources :

Example 46 with BAD_PARAM

use of org.omg.CORBA.BAD_PARAM in project ACS by ACS-Community.

the class CommonPropertyImpl method getHistory.

protected Object getHistory(int lastValues, TimeSeqHolder timeSeqHolder) {
    // check bad parameter
    if (lastValues < 0)
        throw new BAD_PARAM("lastValues < 0");
    synchronized (historyValue) {
        int length, first;
        if (historyTurnaround) {
            length = historySize;
            first = historyPosition;
        } else {
            length = historyPosition;
            first = 0;
        }
        // last n values (and not first n values)
        if (lastValues > length)
            lastValues = length;
        first = (first + length - lastValues) % historySize;
        // get required number of values
        if (lastValues < length)
            length = lastValues;
        timeSeqHolder.value = new long[length];
        Object values = Array.newInstance(propertyType, length);
        // no history case
        if (length == 0)
            return values;
        // copy
        if (first + length < historySize) {
            System.arraycopy(historyTime, first, timeSeqHolder.value, 0, length);
            System.arraycopy(historyValue, first, values, 0, length);
        } else {
            int split = historySize - first;
            System.arraycopy(historyTime, first, timeSeqHolder.value, 0, split);
            System.arraycopy(historyValue, first, values, 0, split);
            System.arraycopy(historyTime, 0, timeSeqHolder.value, split, length - split);
            System.arraycopy(historyValue, 0, values, split, length - split);
        }
        return values;
    }
}
Also used : BAD_PARAM(org.omg.CORBA.BAD_PARAM)

Example 47 with BAD_PARAM

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

the class CurrentImple method resume.

/**
 * To support checked transactions we can only resume if the action is local
 * or we received it implicitly.
 *
 * If the control refers to a nested transaction then we must recreate the
 * entire hierarchy, i.e., the effect of a suspend/resume on the same
 * control should be the same as never calling suspend in the first place.
 *
 * If the control is for a local transaction then it is simple to recreate
 * the hierarchy. Otherwise we rely upon the PropagationContext to recreate
 * it.
 *
 * If this control is a "proxy" then create a new proxy instance, so we can
 * delete proxies whenever suspend is called.
 *
 * Should check if "new" transaction is not actually the current one anyway.
 * If so, just return. The spec. doesn't mention what to do in this case, so
 * for now we go to the overhead of the work regardless.
 */
public void resume(Control which) throws InvalidControl, SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("CurrentImple::resume ( " + which + " )");
    }
    /*
		 * We must now "forget" any current transaction information. This is
		 * because when we end this transaction we must be associated with no
		 * transaction.
		 */
    _theManager.purgeActions();
    if (// if null then return
    which == null) {
        ThreadAssociationControl.updateAssociation(null, TX_RESUMED);
        return;
    }
    /*
		 * Must duplicate because it is an 'in' parameter which we want to keep.
		 */
    org.omg.CosTransactions.Control cont = which;
    boolean invalidControl = false;
    try {
        Coordinator coord = cont.get_coordinator();
        if (!coord.is_top_level_transaction()) {
            /*
				 * Is the Control an ActionControl? If so then it has methods to
				 * allow us to get the parent directly. Otherwise, rely on the
				 * PropagationContext.
				 */
            ActionControl actControl = null;
            try {
                actControl = com.arjuna.ArjunaOTS.ActionControlHelper.narrow(cont);
                if (actControl == null)
                    throw new BAD_PARAM();
            } catch (Exception e) {
                /*
					 * Not an ActionControl.
					 */
                actControl = null;
            }
            if (actControl != null) {
                invalidControl = _theManager.addActionControlHierarchy(actControl);
            } else {
                invalidControl = _theManager.addRemoteHierarchy(cont);
            }
        }
        coord = null;
    } catch (OBJECT_NOT_EXIST one) {
    // throw new InvalidControl();
    } catch (// JacORB 1.4.5 bug
    UNKNOWN ue) {
    } catch (// JacORB 2.0 beta 2 bug
    org.omg.CORBA.OBJ_ADAPTER oae) {
    } catch (SystemException sysEx) {
        throw new InvalidControl();
    } catch (UserException usrEx) {
        throw new InvalidControl();
    } catch (NullPointerException npx) {
        throw new InvalidControl();
    } catch (Exception ex) {
        throw new BAD_OPERATION("CurrentImple.resume: " + ex.toString());
    }
    try {
        if (!invalidControl) {
            ControlWrapper wrap = new ControlWrapper(cont);
            ThreadAssociationControl.updateAssociation(wrap, TX_RESUMED);
            _theManager.pushAction(wrap);
        }
    } catch (NullPointerException npx) {
        invalidControl = true;
    }
    cont = null;
    if (invalidControl)
        throw new InvalidControl();
}
Also used : Control(org.omg.CosTransactions.Control) BAD_PARAM(org.omg.CORBA.BAD_PARAM) Coordinator(org.omg.CosTransactions.Coordinator) SystemException(org.omg.CORBA.SystemException) UserException(org.omg.CORBA.UserException) InvalidControl(org.omg.CosTransactions.InvalidControl) ActionControl(com.arjuna.ArjunaOTS.ActionControl) OBJECT_NOT_EXIST(org.omg.CORBA.OBJECT_NOT_EXIST) SystemException(org.omg.CORBA.SystemException) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) UNKNOWN(org.omg.CORBA.UNKNOWN) UserException(org.omg.CORBA.UserException) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION)

Example 48 with BAD_PARAM

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

the class ArjunaTransactionImple method createOTSRecord.

protected final AbstractRecord createOTSRecord(boolean propagate, Resource resource, Coordinator coord, Uid recCoordUid) {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ArjunaTransactionImple::createOTSRecord for " + get_uid());
    }
    /*
		 * If the resource is an ArjunaOTS.OTSAbstractRecord or an
		 * ArjunaOTS.ArjunaSubtranAwareResource then we can do better record
		 * manipulation, and proper nested actions.
		 *
		 * Based on the type of resource we create the right abstract record to
		 * handle it, rather than a single abstract record which switches
		 * protocols internally.
		 */
    ArjunaSubtranAwareResource absRec = null;
    AbstractRecord corbaRec = null;
    if (resource != null) {
        try {
            absRec = com.arjuna.ArjunaOTS.ArjunaSubtranAwareResourceHelper.narrow(resource);
            if (absRec == null)
                throw new BAD_PARAM(0, CompletionStatus.COMPLETED_NO);
        } catch (Exception e) {
            // can't be an ArjunaOTS.ArjunaSubtranAwareResource
            absRec = null;
        }
    }
    if (absRec == null) {
        corbaRec = new ResourceRecord(propagate, resource, coord, recCoordUid, this);
    } else {
        Uid u = null;
        OTSAbstractRecord otsRec;
        try {
            otsRec = com.arjuna.ArjunaOTS.OTSAbstractRecordHelper.narrow(absRec);
            if (otsRec == null)
                throw new BAD_PARAM(0, CompletionStatus.COMPLETED_NO);
        } catch (Exception e) {
            otsRec = null;
        }
        if (otsRec != null) {
            try {
                u = new Uid(otsRec.uid());
            } catch (Exception e) {
                u = null;
            }
            if (u == null) {
                jtsLogger.i18NLogger.warn_orbspecific_coordinator_uidfail("ArjunaTransactionImple.createOTSRecord");
            }
        }
        if (u == null)
            u = new Uid();
        corbaRec = new ExtendedResourceRecord(propagate, u, absRec, coord, recCoordUid, this);
        otsRec = null;
        absRec = null;
        u = null;
    }
    return corbaRec;
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) ExtendedResourceRecord(com.arjuna.ats.internal.jts.resources.ExtendedResourceRecord) ArjunaSubtranAwareResource(com.arjuna.ArjunaOTS.ArjunaSubtranAwareResource) OTSAbstractRecord(com.arjuna.ArjunaOTS.OTSAbstractRecord) OTSAbstractRecord(com.arjuna.ArjunaOTS.OTSAbstractRecord) AbstractRecord(com.arjuna.ats.arjuna.coordinator.AbstractRecord) BAD_PARAM(org.omg.CORBA.BAD_PARAM) ResourceRecord(com.arjuna.ats.internal.jts.resources.ResourceRecord) ExtendedResourceRecord(com.arjuna.ats.internal.jts.resources.ExtendedResourceRecord) SystemException(org.omg.CORBA.SystemException)

Example 49 with BAD_PARAM

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

the class ArjunaTransactionImple method propagationContext.

/*
	 * The caller should delete the context.
	 *
	 * The propagation context is specified on a per client thread basis.
	 * Therefore, at the server side we must maintain a hierarchy for each
	 * thread. However, the server cannot simply tear down this hierarchy
	 * whenever it receives a completely new one from the same thread, since the
	 * OTS lets a thread suspend/resume contexts at will. Potential for memory
	 * leaks in C++ version, but not Java!!
	 *
	 * Currently we assume that the hierarchy will be JBoss transactions so we
	 * can get the parents of transactions. If it is not then we could simply
	 * just call get_txcontext on the control!
	 */
private final PropagationContext propagationContext() throws Unavailable, Inactive, SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ArjunaTransactionImple::propagationContext for " + get_uid());
    }
    String theUid = null;
    Control currentControl = controlHandle.getControl();
    PropagationContext context = new PropagationContext();
    // most transactions will be top-level
    int sequenceThreshold = 1;
    int sequenceIncrement = 5;
    context.parents = null;
    context.current = new TransIdentity();
    // uughh!!
    context.implementation_specific_data = ORBManager.getORB().orb().create_any();
    /*
		 * Some ORBs (e.g., JBroker) don't like to pass round an unused Any,
		 * i.e., one which has only been created and had nothing put in it! So
		 * we have to put something in it!!
		 */
    context.implementation_specific_data.insert_short((short) 0);
    try {
        context.current.coord = controlHandle.get_coordinator();
        // will reset later!
        context.timeout = 0;
        if (ArjunaTransactionImple._propagateTerminator) {
            context.current.term = controlHandle.get_terminator();
        } else
            context.current.term = null;
    } catch (Exception e) {
        return null;
    }
    /*
		 * We send the Uid hierarchy as the otid_t part of the TransIdentity.
		 */
    // the sequence should do the memory management for us.
    theUid = controlHandle.get_uid().stringForm();
    context.current.otid = Utility.uidToOtid(theUid);
    context.current.otid.formatID = ArjunaTransactionImple._ipType;
    int index = 0;
    while (currentControl != null) {
        try {
            ActionControl control = com.arjuna.ArjunaOTS.ActionControlHelper.narrow(currentControl);
            if (control != null) {
                /*
					 * Must be an Arjuna control.
					 */
                currentControl = control.getParentControl();
                if (currentControl != null) {
                    if (// first time
                    index == 0) {
                        // initial
                        context.parents = new TransIdentity[sequenceThreshold];
                        for (int ii = 0; ii < sequenceThreshold; ii++) context.parents[ii] = null;
                    }
                    context.parents[index] = new TransIdentity();
                    context.parents[index].coord = currentControl.get_coordinator();
                    if (ArjunaTransactionImple._propagateTerminator)
                        context.parents[index].term = currentControl.get_terminator();
                    else
                        context.parents[index].term = null;
                    /*
						 * Don't bother checking whether narrow works because we
						 * can't cope with mixed transaction types anyway! If we
						 * got here then the root transaction must be an Arjuna
						 * transaction, so the nested transactions *must* also
						 * be JBoss transactions!
						 */
                    UidCoordinator uidCoord = Helper.getUidCoordinator(context.parents[index].coord);
                    theUid = uidCoord.uid();
                    context.parents[index].otid = Utility.uidToOtid(theUid);
                    context.parents[index].otid.formatID = ArjunaTransactionImple._ipType;
                    theUid = null;
                    uidCoord = null;
                    index++;
                    if (index >= sequenceThreshold) {
                        sequenceThreshold = index + sequenceIncrement;
                        context.parents = resizeHierarchy(context.parents, index + sequenceIncrement);
                    }
                } else {
                    if (_propagateRemainingTimeout) {
                        long timeInMills = TransactionReaper.transactionReaper().getRemainingTimeoutMills(control);
                        context.timeout = (int) (timeInMills / 1000L);
                    } else {
                        context.timeout = TransactionReaper.transactionReaper().getTimeout(control);
                    }
                }
                control = null;
            } else
                throw new BAD_PARAM(0, CompletionStatus.COMPLETED_NO);
        } catch (SystemException e) {
            /*
				 * Not an Arjuna control!! Should not happen!!
				 */
            currentControl = null;
        } catch (Exception e) {
            e.printStackTrace();
            currentControl = null;
        }
    }
    try {
        context.parents = resizeHierarchy(context.parents, index);
    } catch (Exception e) {
        jtsLogger.i18NLogger.warn_orbspecific_coordinator_generror("ArjunaTransactionImple.resizeHierarchy", e);
        context = null;
    }
    return context;
}
Also used : TxControl(com.arjuna.ats.arjuna.coordinator.TxControl) Control(org.omg.CosTransactions.Control) ActionControl(com.arjuna.ArjunaOTS.ActionControl) BadControl(com.arjuna.ArjunaOTS.BadControl) ActionControl(com.arjuna.ArjunaOTS.ActionControl) UidCoordinator(com.arjuna.ArjunaOTS.UidCoordinator) PropagationContext(org.omg.CosTransactions.PropagationContext) SystemException(org.omg.CORBA.SystemException) TransIdentity(org.omg.CosTransactions.TransIdentity) BAD_PARAM(org.omg.CORBA.BAD_PARAM) SystemException(org.omg.CORBA.SystemException)

Example 50 with BAD_PARAM

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

the class ArjunaTransactionImple method is_descendant_transaction.

/**
 * Is this transaction a descendant of tc?
 */
public boolean is_descendant_transaction(Coordinator tc) throws SystemException {
    if (tc == null)
        return false;
    try {
        UidCoordinator ptr = com.arjuna.ArjunaOTS.UidCoordinatorHelper.narrow(tc);
        if (ptr != null) {
            /*
				 * Must be an Arjuna coordinator.
				 */
            Uid lookingFor = new Uid(ptr.uid());
            BasicAction lookingAt = this;
            if (jtsLogger.logger.isTraceEnabled()) {
                jtsLogger.logger.trace("ArjunaTransactionImple::is_descendant_transaction - looking for " + lookingFor);
            }
            while (lookingAt != null) {
                if (jtsLogger.logger.isTraceEnabled()) {
                    jtsLogger.logger.trace("ArjunaTransactionImple::is_descendant_transaction - looking for " + lookingAt.get_uid());
                }
                if (lookingAt.get_uid().equals(lookingFor))
                    return true;
                else
                    lookingAt = lookingAt.parent();
            }
            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 false;
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) UidCoordinator(com.arjuna.ArjunaOTS.UidCoordinator) BasicAction(com.arjuna.ats.arjuna.coordinator.BasicAction) SystemException(org.omg.CORBA.SystemException) BAD_PARAM(org.omg.CORBA.BAD_PARAM)

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