Search in sources :

Example 36 with BAD_PARAM

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

the class NCSubscriber method getSharedAdmin.

////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////// Helper methods  ////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
/**
	 * Creates or reuses a shared server-side NC consumer admin object.
	 * 
	 * @throws AcsJException
	 */
private ConsumerAdmin getSharedAdmin() throws AcsJCORBAProblemEx, AcsJNarrowFailedEx {
    ConsumerAdmin ret = null;
    org.omg.CosNotifyChannelAdmin.ConsumerAdmin retBase = null;
    boolean created = false;
    int consumerAdminId = -1;
    AdminReuseCompatibilityHack adminReuseCompatibilityHack = new AdminReuseCompatibilityHack(channelName, logger);
    // while in real life we can have concurrent admin creation requests from different processes.
    synchronized (NCSubscriber.class) {
        // Check if we can reuse an already existing consumer admin
        for (int adminId : channel.get_all_consumeradmins()) {
            try {
                org.omg.CosNotifyChannelAdmin.ConsumerAdmin tmpAdmin = channel.get_consumeradmin(adminId);
                if (adminReuseCompatibilityHack.isSharedAdmin(tmpAdmin)) {
                    // (the -1 goes because of the dummy proxy that is attached to the shared admin)
                    if (tmpAdmin.push_suppliers().length - 1 < PROXIES_PER_ADMIN) {
                        retBase = tmpAdmin;
                        consumerAdminId = adminId;
                        break;
                    }
                }
            } catch (AdminNotFound e) {
                logger.log(AcsLogLevel.NOTICE, "Consumer admin with ID='" + adminId + "' not found for channel '" + channelName + "', " + "will continue anyway to search for shared consumer admins", e);
            }
        }
        // If no suitable consumer admin was found, we create a new one 
        if (retBase == null) {
            // create a new consumer admin
            IntHolder consumerAdminIDHolder = new IntHolder();
            // We use filters only on proxy objects, not on admin objects.
            // An admin object without filters will opt to pass all events.
            // We need a logical AND to be used when comparing the event passing decisions
            // made by the set of proxy supplier filters and by the admin object.
            InterFilterGroupOperator adminProxyFilterLogic = InterFilterGroupOperator.AND_OP;
            retBase = channel.new_for_consumers(adminProxyFilterLogic, consumerAdminIDHolder);
            consumerAdminId = consumerAdminIDHolder.value;
            created = true;
        }
    }
    try {
        // cast to TAO extension type
        ret = ConsumerAdminHelper.narrow(retBase);
    } catch (BAD_PARAM ex) {
        if (created) {
            retBase.destroy();
        }
        LOG_NC_TaoExtensionsSubtypeMissing.log(logger, "ConsumerAdmin for channel " + channelName, ConsumerAdminHelper.id(), org.omg.CosNotifyChannelAdmin.ConsumerAdminHelper.id());
        AcsJNarrowFailedEx ex2 = new AcsJNarrowFailedEx(ex);
        ex2.setNarrowType(ConsumerAdminHelper.id());
        throw ex2;
    }
    if (created) {
        // @TODO: Remove this workaround once it is no longer needed.
        adminReuseCompatibilityHack.markAsSharedAdmin(ret);
    }
    LOG_NC_ConsumerAdminObtained_OK.log(logger, consumerAdminId, (created ? "created" : "reused"), clientName, channelName, getNotificationFactoryName());
    return ret;
}
Also used : ConsumerAdmin(gov.sandia.NotifyMonitoringExt.ConsumerAdmin) InterFilterGroupOperator(org.omg.CosNotifyChannelAdmin.InterFilterGroupOperator) BAD_PARAM(org.omg.CORBA.BAD_PARAM) IntHolder(org.omg.CORBA.IntHolder) AcsJNarrowFailedEx(alma.ACSErrTypeCORBA.wrappers.AcsJNarrowFailedEx) AdminNotFound(org.omg.CosNotifyChannelAdmin.AdminNotFound)

Example 37 with BAD_PARAM

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

the class AcsNcReconnectionCallback method registerForReconnect.

/**
	 * Called by the event subscriber or supplier when connecting to the NC.
	 * Corba-activates this callback object using <code>services</code> and
	 * registers it with the NotifyService's {@link ReconnectionRegistry}.
	 * <p>
	 * @throws AcsJContainerServicesEx 
	 * @throws AcsJIllegalArgumentEx 
	 * @TODO: This call does not do anything if the <code>ecf == null</code>,
	 * which is also mentioned in comments in the calling code. 
	 * This should be cleaned up, e.g. checked if at all and under which circumstances
	 * this null can happen. 
	 */
public void registerForReconnect(ContainerServicesBase services, EventChannelFactory ecf) throws AcsJContainerServicesEx, AcsJIllegalArgumentEx {
    // TODO: This is strange...
    if (ecf == null) {
        return;
    }
    if (services == null) {
        AcsJIllegalArgumentEx ex = new AcsJIllegalArgumentEx();
        ex.setVariable("services");
        ex.setValue("null");
        throw ex;
    }
    this.services = services;
    ReconnectionRegistry registry = null;
    try {
        registry = ReconnectionRegistryHelper.narrow(ecf);
    } catch (BAD_PARAM ex) {
        // TODO: Or should we just return, same deal as above with ecf == null?
        AcsJIllegalArgumentEx ex2 = new AcsJIllegalArgumentEx(ex);
        ex2.setErrorDesc("The given EventChannelFactory is not a NotifyExt.ReconnectionRegistry. Make sure TAO extensions are used!");
        throw ex2;
    }
    ecf_ = ecf;
    ReconnectionCallback callback = ReconnectionCallbackHelper.narrow(services.activateOffShoot(this));
    callback_id_ = registry.register_callback(callback);
    id_is_valid_ = true;
}
Also used : ReconnectionCallback(NotifyExt.ReconnectionCallback) BAD_PARAM(org.omg.CORBA.BAD_PARAM) AcsJIllegalArgumentEx(alma.ACSErrTypeCommon.wrappers.AcsJIllegalArgumentEx) ReconnectionRegistry(NotifyExt.ReconnectionRegistry)

Example 38 with BAD_PARAM

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

the class Helper method createNotifyChannel_internal.

/**
	 * Broken out from {@link #createNotificationChannel(String, String, String)}
	 * to give tests better control about the timing when this call to the event factory is made.
	 * @throws NameAlreadyUsed if the call to NotifyFactory#create_named_channel fails with this exception.
	 * @throws AcsJCORBAProblemEx if the TAO extension throws a NameMapError or if the QoS attributes cause a UnsupportedAdmin.
	 */
protected EventChannel createNotifyChannel_internal(Property[] initial_qos, Property[] initial_admin, IntHolder channelIdHolder) throws NameAlreadyUsed, UnsupportedQoS, AcsJNarrowFailedEx, AcsJCORBAProblemEx {
    EventChannel ret = null;
    StopWatch stopwatch = new StopWatch();
    try {
        // The TAO extension of the notify factory that we use declares only the plain EventChannel type, 
        // even though it creates the TAO-extension subtype.
        org.omg.CosNotifyChannelAdmin.EventChannel eventChannelBaseType = notifyFactory.create_named_channel(initial_qos, initial_admin, channelIdHolder, channelName);
        LOG_NC_ChannelCreatedRaw_OK.log(m_logger, channelName, channelIdHolder.value, stopwatch.getLapTimeMillis());
        // re-create the client side corba stub, to get the extension subtype
        ret = gov.sandia.NotifyMonitoringExt.EventChannelHelper.narrow(eventChannelBaseType);
    } catch (BAD_PARAM ex) {
        LOG_NC_TaoExtensionsSubtypeMissing.log(m_logger, channelName, EventChannel.class.getName(), org.omg.CosNotifyChannelAdmin.EventChannelHelper.id());
        AcsJNarrowFailedEx ex2 = new AcsJNarrowFailedEx(ex);
        ex2.setNarrowType(EventChannelHelper.id());
        throw ex2;
    } catch (NameMapError ex) {
        String msg = "Got a TAO extension-specific NameMapError exception that means the TAO NC extension is not usable. Bailing out since we need the extension.";
        m_logger.log(AcsLogLevel.ERROR, msg, ex);
        AcsJCORBAProblemEx ex2 = new AcsJCORBAProblemEx(ex);
        ex2.setInfo(msg);
        throw ex2;
    } catch (UnsupportedAdmin ex) {
        AcsJCORBAProblemEx ex2 = new AcsJCORBAProblemEx(ex);
        ex2.setInfo(createUnsupportedAdminLogMessage(ex));
        throw ex2;
    }
    return ret;
}
Also used : EventChannel(gov.sandia.NotifyMonitoringExt.EventChannel) AcsJCORBAProblemEx(alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx) NameMapError(gov.sandia.NotifyMonitoringExt.NameMapError) BAD_PARAM(org.omg.CORBA.BAD_PARAM) AcsJNarrowFailedEx(alma.ACSErrTypeCORBA.wrappers.AcsJNarrowFailedEx) UnsupportedAdmin(org.omg.CosNotification.UnsupportedAdmin) StopWatch(alma.acs.util.StopWatch)

Example 39 with BAD_PARAM

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

the class ManagerProxyImpl method get_component.

/**
	 * Get a Component, activating it if necessary.
	 * The client represented by id (the handle)
	 * must have adequate access rights to access the Component. This is untrue of components:
	 * components always have unlimited access rights to other components.
	 *
	 * @param id Identification of the caller. If this is an invalid handle, or if the caller does not have enough access rights, a maciErrType::NoPermissionEx exception is raised.
	 * @param component_url CURL of the Component whose reference is to be retrieved.
	 * @param activate True if the Component is to be activated in case it does not exist. If set to False, and the Component does not exist, a nil reference is returned and status is set to COMPONENT_NOT_ACTIVATED.
	 * @return Reference to the Component. If the Component could not be activated, an exception is throw.
	 */
public Object get_component(int id, String component_url, boolean activate) throws NoPermissionEx, CannotGetComponentEx, ComponentNotAlreadyActivatedEx, ComponentConfigurationNotFoundEx {
    pendingRequests.incrementAndGet();
    try {
        // returned value
        Object retVal = null;
        // returned status
        StatusHolder statusHolder = new StatusHolder();
        // transform to CORBA specific
        URI uri = null;
        if (component_url != null)
            uri = CURLHelper.createURI(component_url);
        Component component = manager.getComponent(id, uri, activate, statusHolder);
        // extract Component CORBA reference
        if (component != null)
            retVal = (Object) component.getObject();
        /**
			 * @todo GCH 2006.10.11
			 *       notice that we can get a ComponentStatus != COMPONENT_ACTIVATED
			 *       also if the component is properly returned.
			 *       There is an incoherence here in the interfaces that shall be resolved.
			 *       We have to cleanup here or go back to return a status
			 *       to the caller.
			 *       My point is: the caller is interested in more than just 
			 *       getting the component of an indication of failure if not?
			 *       Is it interesting to know that the component was not activated,
			 *       presumably because already active? 
			 */
        if (component == null || component.getObject() == null) {
            if (statusHolder.getStatus() == ComponentStatus.COMPONENT_NOT_ACTIVATED && !activate) {
                AcsJComponentNotAlreadyActivatedEx ex = new AcsJComponentNotAlreadyActivatedEx();
                ex.setCURL(component_url);
                throw ex;
            }
            if (statusHolder.getStatus() == ComponentStatus.COMPONENT_DOES_NO_EXIST) {
                AcsJComponentConfigurationNotFoundEx ex = new AcsJComponentConfigurationNotFoundEx();
                ex.setCURL(component_url);
                throw ex;
            } else {
                AcsJCannotGetComponentEx ex = new AcsJCannotGetComponentEx();
                ex.setCURL(component_url);
                throw ex;
            }
        }
        return retVal;
    } catch (URISyntaxException usi) {
        BadParametersException hbpe = new BadParametersException(usi.getMessage(), usi);
        reportException(hbpe);
        // rethrow CORBA specific
        throw new BAD_PARAM(usi.getMessage());
    } catch (BadParametersException bpe) {
        BadParametersException hbpe = new BadParametersException(bpe.getMessage(), bpe);
        reportException(hbpe);
        // rethrow CORBA specific
        throw new BAD_PARAM(bpe.getMessage());
    } catch (NoResourcesException nre) {
        NoResourcesException hnre = new NoResourcesException(nre.getMessage(), nre);
        reportException(hnre);
        // rethrow CORBA specific
        throw new NO_RESOURCES(nre.getMessage());
    } catch (AcsJCannotGetComponentEx cgce) {
        // rethrow CORBA specific
        throw cgce.toCannotGetComponentEx();
    } catch (AcsJComponentNotAlreadyActivatedEx cnaae) {
        // rethrow CORBA specific
        throw cnaae.toComponentNotAlreadyActivatedEx();
    } catch (AcsJComponentConfigurationNotFoundEx ccnfe) {
        // rethrow CORBA specific
        throw ccnfe.toComponentConfigurationNotFoundEx();
    } catch (AcsJNoPermissionEx npe) {
        // rethrow CORBA specific
        throw npe.toNoPermissionEx();
    } catch (Throwable ex) {
        CoreException hce = new CoreException(ex.getMessage(), ex);
        reportException(hce);
        // rethrow CORBA specific
        throw new UNKNOWN(ex.getMessage());
    } finally {
        pendingRequests.decrementAndGet();
    }
}
Also used : BAD_PARAM(org.omg.CORBA.BAD_PARAM) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) AcsJCannotGetComponentEx(alma.maciErrType.wrappers.AcsJCannotGetComponentEx) StatusHolder(com.cosylab.acs.maci.StatusHolder) AcsJComponentNotAlreadyActivatedEx(alma.maciErrType.wrappers.AcsJComponentNotAlreadyActivatedEx) BadParametersException(com.cosylab.acs.maci.BadParametersException) NoResourcesException(com.cosylab.acs.maci.NoResourcesException) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) CoreException(com.cosylab.acs.maci.CoreException) Object(org.omg.CORBA.Object) AcsJComponentConfigurationNotFoundEx(alma.maciErrType.wrappers.AcsJComponentConfigurationNotFoundEx) UNKNOWN(org.omg.CORBA.UNKNOWN) Component(com.cosylab.acs.maci.Component) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Example 40 with BAD_PARAM

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

the class ManagerProxyImpl method get_service.

/**
	 * Get a service, activating it if necessary (components).
	 * The client represented by id (the handle) must have adequate access rights to access the service.
	 * NOTE: a component is also a service, i.e. a service activated by a container.
	 * 
	 * @param id Identification of the caller. If this is an invalid handle, or if the caller does not have enough access rights, a maciErrType::NoPermissionEx exception is raised.
	 * @param service_url CURL of the service whose reference is to be retrieved.
	 * @param activate True if the component is to be activated in case it does not exist. If set to False, and the Component does not exist, a nil reference is returned and status is set to COMPONENT_NOT_ACTIVATED.
	 * @param status Status of the request. One of COMPONENT_ACTIVATED, COMPONENT_DOES_NO_EXIST and COMPONENT_NOT_ACTIVATED.
	 * @return Reference to the service. If the service could not be obtained, a nil reference is returned,
	 *		  and the status contains an error code detailing the cause of failure (one of the COMPONENT_* constants).
	 * @see #get_component
	 */
public Object get_service(int id, String service_url, boolean activate) throws NoPermissionEx, CannotGetComponentEx {
    pendingRequests.incrementAndGet();
    try {
        // returned value
        Object retVal = null;
        // returned status
        StatusHolder statusHolder = new StatusHolder();
        // transform to CORBA specific
        URI uri = null;
        if (service_url != null)
            uri = CURLHelper.createURI(service_url);
        Component component = manager.getService(id, uri, activate, statusHolder);
        if (component == null || (Object) component.getObject() == null)
            throw new AcsJCannotGetComponentEx();
        retVal = (Object) component.getObject();
        return retVal;
    } catch (URISyntaxException usi) {
        BadParametersException hbpe = new BadParametersException(usi.getMessage(), usi);
        reportException(hbpe);
        // rethrow CORBA specific
        throw new BAD_PARAM(usi.getMessage());
    } catch (BadParametersException bpe) {
        BadParametersException hbpe = new BadParametersException(bpe.getMessage(), bpe);
        reportException(hbpe);
        // rethrow CORBA specific
        throw new BAD_PARAM(bpe.getMessage());
    } catch (NoResourcesException nre) {
        NoResourcesException hnre = new NoResourcesException(nre.getMessage(), nre);
        reportException(hnre);
        // rethrow CORBA specific
        throw new NO_RESOURCES(nre.getMessage());
    } catch (AcsJCannotGetComponentEx cgce) {
        // rethrow CORBA specific
        throw cgce.toCannotGetComponentEx();
    } catch (AcsJNoPermissionEx npe) {
        // rethrow CORBA specific
        throw npe.toNoPermissionEx();
    } catch (Throwable ex) {
        CoreException hce = new CoreException(ex.getMessage(), ex);
        reportException(hce);
        // rethrow CORBA specific
        throw new UNKNOWN(ex.getMessage());
    } finally {
        pendingRequests.decrementAndGet();
    }
}
Also used : BAD_PARAM(org.omg.CORBA.BAD_PARAM) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) AcsJCannotGetComponentEx(alma.maciErrType.wrappers.AcsJCannotGetComponentEx) StatusHolder(com.cosylab.acs.maci.StatusHolder) BadParametersException(com.cosylab.acs.maci.BadParametersException) NoResourcesException(com.cosylab.acs.maci.NoResourcesException) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) CoreException(com.cosylab.acs.maci.CoreException) Object(org.omg.CORBA.Object) UNKNOWN(org.omg.CORBA.UNKNOWN) Component(com.cosylab.acs.maci.Component) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

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