Search in sources :

Example 16 with BAD_PARAM

use of org.omg.CORBA.BAD_PARAM in project wildfly by wildfly.

the class SASClientIdentityInterceptor method receive_exception.

@Override
public void receive_exception(ClientRequestInfo ri) {
    try {
        ServiceContext sc = ri.get_reply_service_context(sasContextId);
        Any msg = codec.decode_value(sc.context_data, SASContextBodyHelper.type());
        SASContextBody contextBody = SASContextBodyHelper.extract(msg);
        // At this point contextBody may contain either a CompleteEstablishContext message or a ContextError message.
        // Neither message requires any treatment. We decoded the contextbody just to check that it contains a
        // well-formed message.
        IIOPLogger.ROOT_LOGGER.tracef("receive_exception: got SAS reply, type %d", contextBody.discriminator());
    } catch (BAD_PARAM e) {
    // no service context with sasContextId: do nothing.
    } catch (FormatMismatch e) {
        throw IIOPLogger.ROOT_LOGGER.errorParsingSASReply(e, 0, CompletionStatus.COMPLETED_MAYBE);
    } catch (TypeMismatch e) {
        throw IIOPLogger.ROOT_LOGGER.errorParsingSASReply(e, 0, CompletionStatus.COMPLETED_MAYBE);
    }
}
Also used : ServiceContext(org.omg.IOP.ServiceContext) BAD_PARAM(org.omg.CORBA.BAD_PARAM) SASContextBody(org.omg.CSI.SASContextBody) Any(org.omg.CORBA.Any) FormatMismatch(org.omg.IOP.CodecPackage.FormatMismatch) TypeMismatch(org.omg.IOP.CodecPackage.TypeMismatch)

Example 17 with BAD_PARAM

use of org.omg.CORBA.BAD_PARAM in project wildfly by wildfly.

the class SASClientInterceptor method receive_reply.

@Override
public void receive_reply(ClientRequestInfo ri) {
    try {
        ServiceContext sc = ri.get_reply_service_context(sasContextId);
        Any msg = codec.decode_value(sc.context_data, SASContextBodyHelper.type());
        SASContextBody contextBody = SASContextBodyHelper.extract(msg);
        // At this point contextBody should contain a CompleteEstablishContext message, which does not require any
        // treatment. ContextError messages should arrive via receive_exception().
        IIOPLogger.ROOT_LOGGER.tracef("receive_reply: got SAS reply, type %d", contextBody.discriminator());
        if (contextBody.discriminator() == MTContextError.value) {
            // should not happen.
            throw IIOPLogger.ROOT_LOGGER.unexpectedContextErrorInSASReply(0, CompletionStatus.COMPLETED_YES);
        }
    } catch (BAD_PARAM e) {
    // no service context with sasContextId: do nothing
    } catch (FormatMismatch e) {
        throw IIOPLogger.ROOT_LOGGER.errorParsingSASReply(e, 0, CompletionStatus.COMPLETED_YES);
    } catch (TypeMismatch e) {
        throw IIOPLogger.ROOT_LOGGER.errorParsingSASReply(e, 0, CompletionStatus.COMPLETED_YES);
    }
}
Also used : ServiceContext(org.omg.IOP.ServiceContext) BAD_PARAM(org.omg.CORBA.BAD_PARAM) SASContextBody(org.omg.CSI.SASContextBody) Any(org.omg.CORBA.Any) FormatMismatch(org.omg.IOP.CodecPackage.FormatMismatch) TypeMismatch(org.omg.IOP.CodecPackage.TypeMismatch)

Example 18 with BAD_PARAM

use of org.omg.CORBA.BAD_PARAM in project wildfly by wildfly.

the class SASClientInterceptor method receive_exception.

@Override
public void receive_exception(ClientRequestInfo ri) {
    try {
        ServiceContext sc = ri.get_reply_service_context(sasContextId);
        Any msg = codec.decode_value(sc.context_data, SASContextBodyHelper.type());
        SASContextBody contextBody = SASContextBodyHelper.extract(msg);
        // At this point contextBody may contain either a CompleteEstablishContext message or a ContextError message.
        // Neither message requires any treatment. We decoded the context body just to check that it contains
        // a well-formed message.
        IIOPLogger.ROOT_LOGGER.tracef("receive_exception: got SAS reply, type %d", contextBody.discriminator());
    } catch (BAD_PARAM e) {
    // no service context with sasContextId: do nothing.
    } catch (FormatMismatch e) {
        throw IIOPLogger.ROOT_LOGGER.errorParsingSASReply(e, 0, CompletionStatus.COMPLETED_MAYBE);
    } catch (TypeMismatch e) {
        throw IIOPLogger.ROOT_LOGGER.errorParsingSASReply(e, 0, CompletionStatus.COMPLETED_MAYBE);
    }
}
Also used : ServiceContext(org.omg.IOP.ServiceContext) BAD_PARAM(org.omg.CORBA.BAD_PARAM) SASContextBody(org.omg.CSI.SASContextBody) Any(org.omg.CORBA.Any) FormatMismatch(org.omg.IOP.CodecPackage.FormatMismatch) TypeMismatch(org.omg.IOP.CodecPackage.TypeMismatch)

Example 19 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 20 with BAD_PARAM

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

the class NCPublisher method init.

/**
	 * Initializes NCPublisher
	 * @param namingService Naming service
	 * @throws AcsJException
	 *             There are literally dozens of CORBA exceptions that could be
	 *             thrown by the NCPublisher class. Instead, these are
	 *             converted into an ACS Error System exception for the
	 *             developer's convenience.
	 */
protected synchronized void init(NamingContext namingService) throws AcsJException {
    helper = new Helper(channelName, channelNotifyServiceDomainName, this.services, namingService);
    isTraceEventsEnabled = helper.getChannelProperties().isTraceEventsEnabled(this.channelName);
    // get the channel
    // @TODO: handle Corba TIMEOUT 
    channel = helper.getNotificationChannel(getNotificationFactoryName());
    // Corba NC spec about adminId: a unique identifier assigned by the target EventChannel instance that is unique among all 
    // SupplierAdmin instances currently associated with the channel.
    // We are currently not using it, but it could be logged to help with NC debugging.
    IntHolder adminIdHolder = new IntHolder();
    org.omg.CosNotifyChannelAdmin.SupplierAdmin supplierAdminBase = null;
    try {
        supplierAdminBase = channel.new_for_suppliers(InterFilterGroupOperator.AND_OP, adminIdHolder);
    } catch (TIMEOUT ex) {
        // found in http://jira.alma.cl/browse/COMP-6312
        throw new AcsJCORBAProblemEx(ex);
    }
    if (supplierAdminBase == null) {
        AcsJCORBAReferenceNilEx ex = new AcsJCORBAReferenceNilEx();
        ex.setVariable("supplierAdminBase");
        ex.setContext("Null reference obtained for the supplier admin for channel " + this.channelName);
        throw ex;
    }
    try {
        supplierAdmin = gov.sandia.NotifyMonitoringExt.SupplierAdminHelper.narrow(supplierAdminBase);
    } catch (BAD_PARAM ex) {
        // This should never happen, since we already enforced the presence of TAO extensions in Helper#initializeNotifyFactory
        String specialSupplierAdminId = gov.sandia.NotifyMonitoringExt.SupplierAdminHelper.id();
        String standardSupplierAdminId = org.omg.CosNotifyChannelAdmin.SupplierAdminHelper.id();
        LOG_NC_TaoExtensionsSubtypeMissing.log(logger, channelName + "-SupplierAdmin", specialSupplierAdminId, standardSupplierAdminId);
        AcsJNarrowFailedEx ex2 = new AcsJNarrowFailedEx(ex);
        ex2.setNarrowType(specialSupplierAdminId);
        throw ex2;
    }
    int proxyCreationAttempts = 0;
    while (proxyConsumer == null) {
        String randomizedClientName = Helper.createRandomizedClientName(services.getName());
        // Holder for the unique ID assigned by the admin object. It is different from the name we set, and will be discarded.
        IntHolder proxyIdHolder = new IntHolder();
        proxyCreationAttempts++;
        try {
            // Create the consumer proxy (to which the published events will be fed) with a name.
            // The client type parameter selects a StructuredProxyPushConsumer (based on Structured Events),
            // as opposed to ProxyPushConsumer (based on Anys), or SequenceProxyPushConsumer (based on sequences of Structured Events).
            org.omg.CORBA.Object tempCorbaObj = supplierAdmin.obtain_named_notification_push_consumer(ClientType.STRUCTURED_EVENT, proxyIdHolder, randomizedClientName.toString());
            if (tempCorbaObj == null) {
                AcsJCORBAReferenceNilEx ex = new AcsJCORBAReferenceNilEx();
                ex.setVariable("tempCorbaObj");
                ex.setContext("Null reference obtained for the Proxy Push Consumer for publisher " + services.getName());
                // @TODO destroy supplierAdmin
                throw ex;
            }
            proxyConsumer = StructuredProxyPushConsumerHelper.narrow(tempCorbaObj);
            LOG_NC_ConsumerProxyCreation_OK.log(logger, proxyIdHolder.value, randomizedClientName, proxyCreationAttempts, services.getName(), channelName, getNotificationFactoryName());
        } 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.
            logger.fine("Consumer proxy name '" + randomizedClientName + "' already in use. Will try again with different random number appended.");
        } catch (NameMapError ex) {
            // Default to the unnamed version
            try {
                proxyConsumer = StructuredProxyPushConsumerHelper.narrow(supplierAdmin.obtain_notification_push_consumer(ClientType.STRUCTURED_EVENT, proxyIdHolder));
                LOG_NC_ConsumerProxyCreation_OK.log(logger, proxyIdHolder.value, "-unknown-", proxyCreationAttempts, services.getName(), channelName, getNotificationFactoryName());
            } catch (AdminLimitExceeded ex2) {
                LOG_NC_ConsumerProxyCreation_FAIL.log(logger, services.getName(), channelName, getNotificationFactoryName(), ex2.getMessage());
                // @TODO destroy supplierAdmin
                throw new AcsJCORBAProblemEx(ex2);
            }
        } catch (AdminLimitExceeded e) {
            LOG_NC_ConsumerProxyCreation_FAIL.log(logger, services.getName(), channelName, getNotificationFactoryName(), e.getMessage());
            // @TODO destroy supplierAdmin
            throw new AcsJCORBAProblemEx(e);
        }
    }
    // Avoid future calls from the NC to #subscription_change(EventType[], EventType[]). See Corba spec 3.4.1.3
    // @TODO: If we use ALL_NOW_UPDATES_ON then we could actually suppress sending of event types that no consumer wants to get. 
    proxyConsumer.obtain_subscription_types(ObtainInfoMode.NONE_NOW_UPDATES_OFF);
    // see 3.4.4.1 of Notification Service, v1.1
    try {
        StructuredPushSupplier thisSps = StructuredPushSupplierHelper.narrow(this.services.activateOffShoot(this));
        proxyConsumer.connect_structured_push_supplier(thisSps);
    } catch (AcsJContainerServicesEx e) {
        // @TODO destroy supplierAdmin and proxyConsumer
        throw new AcsJCORBAProblemEx(e);
    } catch (AlreadyConnected e) {
        // @TODO destroy supplierAdmin and proxyConsumer
        throw new AcsJCORBAProblemEx(e);
    }
    reconnectCallback = new AcsNcReconnectionCallback(this, logger);
    reconnectCallback.registerForReconnect(services, helper.getNotifyFactory());
}
Also used : StructuredPushSupplier(org.omg.CosNotifyComm.StructuredPushSupplier) AcsJCORBAProblemEx(alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx) AdminLimitExceeded(org.omg.CosNotifyChannelAdmin.AdminLimitExceeded) AlreadyConnected(org.omg.CosEventChannelAdmin.AlreadyConnected) BAD_PARAM(org.omg.CORBA.BAD_PARAM) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx) EventDescriptionHelper(alma.acsnc.EventDescriptionHelper) StructuredProxyPushConsumerHelper(org.omg.CosNotifyChannelAdmin.StructuredProxyPushConsumerHelper) StructuredPushSupplierHelper(org.omg.CosNotifyComm.StructuredPushSupplierHelper) AcsJCORBAReferenceNilEx(alma.ACSErrTypeCORBA.wrappers.AcsJCORBAReferenceNilEx) NameMapError(gov.sandia.NotifyMonitoringExt.NameMapError) IntHolder(org.omg.CORBA.IntHolder) NameAlreadyUsed(gov.sandia.NotifyMonitoringExt.NameAlreadyUsed) TIMEOUT(org.omg.CORBA.TIMEOUT) AcsJNarrowFailedEx(alma.ACSErrTypeCORBA.wrappers.AcsJNarrowFailedEx)

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