Search in sources :

Example 21 with BAD_PARAM

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

the class Consumer method createConsumer.

/**
	 * Handles the CORBA creation of a consumer.
	 * Changed to private because only ctor of this class call this method as of Alma 5.0.2
	 * 
	 * @throws AcsJException
	 *            Any CORBA exceptions encountered are converted to an
	 *            AcsJException for developer's ease of use.
	 */
private void createConsumer() throws AcsJException {
    IntHolder consumerAdminIDHolder = new IntHolder();
    // get the Consumer admin object (no reuse of admin obj. This gets addressed in the new NCSubscriber class)
    // We don't need to use the TAO extension method "named_new_for_consumers" because only the proxy object will get a name from us.
    m_consumerAdmin = m_channel.new_for_consumers(InterFilterGroupOperator.AND_OP, consumerAdminIDHolder);
    // sanity check
    if (m_consumerAdmin == null) {
        String reason = "The '" + m_channelName + "' channel: null consumer admin";
        throw new alma.ACSErrTypeJavaNative.wrappers.AcsJJavaLangEx(reason);
    }
    // get the Supplier proxy
    proxyID = new IntHolder();
    gov.sandia.NotifyMonitoringExt.ConsumerAdmin consumerAdminExt = null;
    try {
        consumerAdminExt = gov.sandia.NotifyMonitoringExt.ConsumerAdminHelper.narrow(m_consumerAdmin);
    } catch (BAD_PARAM ex) {
    // Don't care, we won't be able to create the proxy with a name, but that's it
    // HSO: Actually this should never happen, because without TAO extension present, 
    // already getting the NotifyFactory reference would have failed.
    }
    if (consumerAdminExt != null) {
        // which could lead to memory leaks
        while (m_proxySupplier == null) {
            String randomizedClientName = m_helper.createRandomizedClientName(m_clientName);
            try {
                // Create the push supplier with a name
                m_proxySupplier = StructuredProxyPushSupplierHelper.narrow(consumerAdminExt.obtain_named_notification_push_supplier(ClientType.STRUCTURED_EVENT, proxyID, randomizedClientName));
                m_logger.fine("Created named proxy supplier '" + randomizedClientName + "'");
            } catch (NameAlreadyUsed e) {
            // Hopefully we won't run into this situation. Still, try to go on in the loop,
            // with a different client name next time.
            } catch (NameMapError e) {
                // Default to the unnamed version
                try {
                    m_proxySupplier = StructuredProxyPushSupplierHelper.narrow(m_consumerAdmin.obtain_notification_push_supplier(ClientType.STRUCTURED_EVENT, proxyID));
                } catch (AdminLimitExceeded e1) {
                    throw new AcsJCORBAProblemEx(e1);
                }
            } catch (AdminLimitExceeded e) {
                throw new AcsJCORBAProblemEx(e);
            }
        }
    } else {
        // Create the push supplier without a name
        try {
            m_proxySupplier = StructuredProxyPushSupplierHelper.narrow(m_consumerAdmin.obtain_notification_push_supplier(ClientType.STRUCTURED_EVENT, proxyID));
        } catch (org.omg.CosNotifyChannelAdmin.AdminLimitExceeded e) {
            // convert it into an exception developers care about
            throw new alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx(e);
        }
    }
    // sanity check
    if (m_proxySupplier == null) {
        String reason = "The '" + m_channelName + "' channel: null proxy supplier";
        throw new alma.ACSErrTypeJavaNative.wrappers.AcsJJavaLangEx(reason);
    }
    LOG_NC_SubscriptionConnect_OK.log(m_logger, m_channelName, m_notifyServiceName);
}
Also used : AcsJCORBAProblemEx(alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx) AdminLimitExceeded(org.omg.CosNotifyChannelAdmin.AdminLimitExceeded) BAD_PARAM(org.omg.CORBA.BAD_PARAM) NameMapError(gov.sandia.NotifyMonitoringExt.NameMapError) IntHolder(org.omg.CORBA.IntHolder) NameAlreadyUsed(gov.sandia.NotifyMonitoringExt.NameAlreadyUsed) AdminLimitExceeded(org.omg.CosNotifyChannelAdmin.AdminLimitExceeded) AcsJCORBAProblemEx(alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx)

Example 22 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 23 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 24 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 25 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)

Aggregations

BAD_PARAM (org.omg.CORBA.BAD_PARAM)31 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 UNKNOWN (org.omg.CORBA.UNKNOWN)13 NO_RESOURCES (org.omg.CORBA.NO_RESOURCES)12 Any (org.omg.CORBA.Any)9 Object (org.omg.CORBA.Object)8 FormatMismatch (org.omg.IOP.CodecPackage.FormatMismatch)8 TypeMismatch (org.omg.IOP.CodecPackage.TypeMismatch)8 ServiceContext (org.omg.IOP.ServiceContext)8 URI (java.net.URI)7 URISyntaxException (java.net.URISyntaxException)7 SASContextBody (org.omg.CSI.SASContextBody)7 AcsJCannotGetComponentEx (alma.maciErrType.wrappers.AcsJCannotGetComponentEx)6 AcsJNarrowFailedEx (alma.ACSErrTypeCORBA.wrappers.AcsJNarrowFailedEx)4 AcsJCORBAProblemEx (alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx)4 Component (com.cosylab.acs.maci.Component)4 ComponentInfo (si.ijs.maci.ComponentInfo)4