Ejemplo n.º 1
0
        public CommunicatorObserverI(Communicator communicator, Logger logger)
        {
            _metrics     = new MetricsAdminI(communicator, logger);
            _delegate    = communicator.Observer;
            _connections = new ObserverFactoryWithDelegate <ConnectionMetrics, ConnectionObserverI,
                                                            Ice.Instrumentation.ConnectionObserver>(_metrics, "Connection");
            _dispatch = new ObserverFactoryWithDelegate <DispatchMetrics, DispatchObserverI,
                                                         Ice.Instrumentation.DispatchObserver>(_metrics, "Dispatch");
            _invocations = new ObserverFactoryWithDelegate <InvocationMetrics, InvocationObserverI,
                                                            Ice.Instrumentation.InvocationObserver>(_metrics, "Invocation");
            _threads = new ObserverFactoryWithDelegate <ThreadMetrics, ThreadObserverI,
                                                        Ice.Instrumentation.ThreadObserver>(_metrics, "Thread");
            _connects = new ObserverFactoryWithDelegate <Metrics, ObserverWithDelegateI,
                                                         Ice.Instrumentation.Observer>(_metrics, "ConnectionEstablishment");
            _endpointLookups = new ObserverFactoryWithDelegate <Metrics, ObserverWithDelegateI,
                                                                Ice.Instrumentation.Observer>(_metrics, "EndpointLookup");

            try
            {
                Type cl = typeof(InvocationMetrics);
                _invocations.registerSubMap <RemoteMetrics>("Remote", cl.GetField("remotes"));
                _invocations.registerSubMap <CollocatedMetrics>("Collocated", cl.GetField("collocated"));
            }
            catch (System.Exception)
            {
                Debug.Assert(false);
            }
        }
Ejemplo n.º 2
0
        internal MetricsMap(string mapPrefix, Ice.Properties props, Dictionary <string, ISubMapFactory> subMaps)
        {
            MetricsAdminI.validateProperties(mapPrefix, props);
            _properties = props.getPropertiesForPrefix(mapPrefix);

            _retain            = props.getPropertyAsIntWithDefault(mapPrefix + "RetainDetached", 10);
            _accept            = parseRule(props, mapPrefix + "Accept");
            _reject            = parseRule(props, mapPrefix + "Reject");
            _groupByAttributes = new List <string>();
            _groupBySeparators = new List <string>();

            string groupBy = props.getPropertyWithDefault(mapPrefix + "GroupBy", "id");

            if (groupBy.Length > 0)
            {
                string v         = "";
                bool   attribute = char.IsLetter(groupBy[0]) || char.IsDigit(groupBy[0]);
                if (!attribute)
                {
                    _groupByAttributes.Add("");
                }

                foreach (char p in groupBy)
                {
                    bool isAlphaNum = char.IsLetter(p) || char.IsDigit(p) || p == '.';
                    if (attribute && !isAlphaNum)
                    {
                        _groupByAttributes.Add(v);
                        v         = "" + p;
                        attribute = false;
                    }
                    else if (!attribute && isAlphaNum)
                    {
                        _groupBySeparators.Add(v);
                        v         = "" + p;
                        attribute = true;
                    }
                    else
                    {
                        v += p;
                    }
                }

                if (attribute)
                {
                    _groupByAttributes.Add(v);
                }
                else
                {
                    _groupBySeparators.Add(v);
                }
            }

            if (subMaps != null && subMaps.Count > 0)
            {
                _subMaps = new Dictionary <string, ISubMapCloneFactory>();

                List <string> subMapNames = new List <string>();
                foreach (KeyValuePair <string, ISubMapFactory> e in subMaps)
                {
                    subMapNames.Add(e.Key);
                    string subMapsPrefix = mapPrefix + "Map.";
                    string subMapPrefix  = subMapsPrefix + e.Key + '.';
                    if (props.getPropertiesForPrefix(subMapPrefix).Count == 0)
                    {
                        if (props.getPropertiesForPrefix(subMapsPrefix).Count == 0)
                        {
                            subMapPrefix = mapPrefix;
                        }
                        else
                        {
                            continue; // This sub-map isn't configured.
                        }
                    }

                    _subMaps.Add(e.Key, e.Value.createCloneFactory(subMapPrefix, props));
                }
            }
            else
            {
                _subMaps = null;
            }
        }
Ejemplo n.º 3
0
 public ObserverFactory(IceInternal.MetricsAdminI metrics, string name)
 {
     _metrics = metrics;
     _name    = name;
     _metrics.registerMap <T>(name, this.update);
 }
Ejemplo n.º 4
0
 public ObserverFactoryWithDelegate(MetricsAdminI metrics, string name)
     : base(metrics, name)
 {
 }