Search in sources :

Example 1 with InterFilterGroupOperator

use of org.omg.CosNotifyChannelAdmin.InterFilterGroupOperator in project ACS by ACS-Community.

the class ACSRemoteAccess method createConsumerAdmin.

/**
	 * Creates a consumer admin on the server, that is used only by this jlog instance.
	 * @see #consumerAdmin
	 */
private boolean createConsumerAdmin() {
    listenersDispatcher.publishReport("Creating Consumer Admin...");
    try {
        InterFilterGroupOperator ifgo = org.omg.CosNotifyChannelAdmin.InterFilterGroupOperator.OR_OP;
        org.omg.CORBA.IntHolder adminID = new org.omg.CORBA.IntHolder();
        consumerAdmin = ConsumerAdminHelper.narrow(eventChannel.new_for_consumers(ifgo, adminID));
    } catch (Exception e) {
        listenersDispatcher.publishReport("Exception occurred when creating Consumer Admin.");
        System.out.println("Exception in ACSRemoteAccess::createConsumerAdmin(): " + e);
        return false;
    }
    listenersDispatcher.publishReport("Consumer Admin created.");
    return true;
}
Also used : InterFilterGroupOperator(org.omg.CosNotifyChannelAdmin.InterFilterGroupOperator)

Example 2 with InterFilterGroupOperator

use of org.omg.CosNotifyChannelAdmin.InterFilterGroupOperator 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)

Aggregations

InterFilterGroupOperator (org.omg.CosNotifyChannelAdmin.InterFilterGroupOperator)2 AcsJNarrowFailedEx (alma.ACSErrTypeCORBA.wrappers.AcsJNarrowFailedEx)1 ConsumerAdmin (gov.sandia.NotifyMonitoringExt.ConsumerAdmin)1 BAD_PARAM (org.omg.CORBA.BAD_PARAM)1 IntHolder (org.omg.CORBA.IntHolder)1 AdminNotFound (org.omg.CosNotifyChannelAdmin.AdminNotFound)1