Search in sources :

Example 1 with ProxyNotFound

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

the class EventModel method getChannelStatistics.

/**
	 * Called by NotifyServiceUpdateJob (single/periodic refresh of service summary / channel tree).
	 */
public synchronized boolean getChannelStatistics() {
    if (false == discoverNotifyServicesAndChannels()) {
        return false;
    }
    for (NotifyServiceData nsData : notifyServices.values()) {
        if (!nsData.isReachable()) {
            // we skip services that were unreachable already in the above discoverNotifyServicesAndChannels call
            continue;
        }
        // especially if we don't want to display the admin objects as tree nodes to show consumer allocation to the shared admins.
        for (ChannelData channelData : nsData.getChannels()) {
            String channelName = channelData.getQualifiedName();
            EventChannel ec = channelData.getCorbaRef();
            // initial or previous count of consumers / suppliers
            int[] consAndSupp = { 0, 0 };
            if (channelData.isNewNc()) {
                lastConsumerAndSupplierCount.put(channelName, consAndSupp);
            } else if (lastConsumerAndSupplierCount.containsKey(channelName)) {
                consAndSupp = lastConsumerAndSupplierCount.get(channelName);
            }
            // for consumers we must count the proxies, cannot just deduce their number from the consumer admins
            int consumerCount = 0;
            for (int consumerAdminId : ec.get_all_consumeradmins()) {
                try {
                    ConsumerAdmin consumerAdmin = ec.get_consumeradmin(consumerAdminId);
                    int[] push_suppliers_ids = consumerAdmin.push_suppliers();
                    for (int proxyID : push_suppliers_ids) {
                        try {
                            ProxySupplier proxy = consumerAdmin.get_proxy_supplier(proxyID);
                            if (!NCSubscriber.AdminReuseCompatibilityHack.isDummyProxy(proxy)) {
                                consumerCount++;
                            }
                        } catch (ProxyNotFound ex) {
                            m_logger.log(AcsLogLevel.NOTICE, "Proxy with ID='" + proxyID + "' not found for consumer admin with ID='" + consumerAdminId + "', " + "even though this Id got listed a moment ago.", ex);
                        }
                    }
                } catch (AdminNotFound ex) {
                    ex.printStackTrace();
                }
            }
            final String[] roleNames = { "consumer", "supplier" };
            int[] proxyCounts = new int[2];
            int[] proxyDeltas = new int[2];
            proxyCounts[0] = consumerCount;
            // currently for suppliers we have 1 admin object per supplier
            proxyCounts[1] = ec.get_all_supplieradmins().length;
            // same code for consumer and supplier
            for (int i = 0; i < proxyCounts.length; i++) {
                String cstr = channelName;
                int cdiff = proxyCounts[i] - consAndSupp[i];
                if (cdiff != 0) {
                    if (cdiff > 0) {
                        cstr += " has added " + cdiff + " " + roleNames[i];
                    } else if (cdiff < 0) {
                        cstr += " has removed " + (-cdiff) + " " + roleNames[i];
                    }
                    cstr += (Math.abs(cdiff) != 1 ? "s." : ".");
                    m_logger.info(cstr);
                }
                proxyDeltas[i] = cdiff;
            }
            lastConsumerAndSupplierCount.put(channelName, proxyCounts);
            //m_logger.info("Channel: " + channelName + " has " + adminCounts[0] + " consumers and " + adminCounts[1] + " suppliers.");
            channelData.setNumberConsumers(proxyCounts[0]);
            channelData.setNumberSuppliers(proxyCounts[1]);
            channelData.setDeltaConsumers(proxyDeltas[0]);
            channelData.setDeltaSuppliers(proxyDeltas[1]);
        }
    }
    return true;
}
Also used : EventChannel(org.omg.CosNotifyChannelAdmin.EventChannel) ProxyNotFound(org.omg.CosNotifyChannelAdmin.ProxyNotFound) ConsumerAdmin(org.omg.CosNotifyChannelAdmin.ConsumerAdmin) ProxySupplier(org.omg.CosNotifyChannelAdmin.ProxySupplier) AdminNotFound(org.omg.CosNotifyChannelAdmin.AdminNotFound)

Aggregations

AdminNotFound (org.omg.CosNotifyChannelAdmin.AdminNotFound)1 ConsumerAdmin (org.omg.CosNotifyChannelAdmin.ConsumerAdmin)1 EventChannel (org.omg.CosNotifyChannelAdmin.EventChannel)1 ProxyNotFound (org.omg.CosNotifyChannelAdmin.ProxyNotFound)1 ProxySupplier (org.omg.CosNotifyChannelAdmin.ProxySupplier)1