コード例 #1
0
ファイル: MetricsAdminI.cs プロジェクト: skyccn/ice
        private bool addOrUpdateMap(string mapName, IMetricsMapFactory factory)
        {
            bool updated = false;

            foreach (MetricsViewI v in _views.Values)
            {
                updated |= v.addOrUpdateMap(_properties, mapName, factory, _logger);
            }
            return(updated);
        }
コード例 #2
0
ファイル: MetricsAdminI.cs プロジェクト: skyccn/ice
        internal bool addOrUpdateMap(Ice.Properties properties, string mapName, IMetricsMapFactory factory,
                                     Ice.Logger logger)
        {
            //
            // Add maps to views configured with the given map.
            //
            string viewPrefix = "IceMX.Metrics." + _name + ".";
            string mapsPrefix = viewPrefix + "Map.";
            Dictionary <string, string> mapsProps = properties.getPropertiesForPrefix(mapsPrefix);

            string mapPrefix;
            Dictionary <string, string> mapProps = new Dictionary <string, string>();

            if (mapsProps.Count > 0)
            {
                mapPrefix = mapsPrefix + mapName + ".";
                mapProps  = properties.getPropertiesForPrefix(mapPrefix);
                if (mapProps.Count == 0)
                {
                    // This map isn't configured for this view.
                    return(_maps.Remove(mapName));
                }
            }
            else
            {
                mapPrefix = viewPrefix;
                mapProps  = properties.getPropertiesForPrefix(mapPrefix);
            }

            if (properties.getPropertyAsInt(mapPrefix + "Disabled") > 0)
            {
                // This map is disabled for this view.
                return(_maps.Remove(mapName));
            }

            IMetricsMap m;

            if (_maps.TryGetValue(mapName, out m) &&
                IceUtilInternal.Collections.DictionaryEquals(m.getProperties(), mapProps))
            {
                return(false); // The map configuration didn't change, no need to re-create.
            }

            try
            {
                _maps[mapName] = factory.create(mapPrefix, properties);
            }
            catch (Exception ex)
            {
                logger.warning("unexpected exception while creating metrics map:\n" + ex);
                _maps.Remove(mapName);
            }
            return(true);
        }