示例#1
0
        public PingPerformancePart(string partID, PingPerformancePartConfig config, PartsLib.Tools.MDRF.Writer.IMDRFWriter mdrfWriter)
            : base(partID, initialSettings: SimpleActivePartBaseSettings.DefaultVersion0.Build(waitTimeLimit: (0.10).FromSeconds(), goOnlineAndOfflineHandling: GoOnlineAndGoOfflineHandling.All))
        {
            Config          = new PingPerformancePartConfig(config);
            this.mdrfWriter = mdrfWriter;

            sampleIntervalTimer = new QpcTimer()
            {
                TriggerInterval = Config.SampleInterval, AutoReset = true
            }.Start();
            aggregationIntervalTimer = new QpcTimer()
            {
                TriggerInterval = Config.AggregationInterval, AutoReset = true
            }.Start();

            AddExplicitDisposeAction(() => Release());

            pingTrackerArray = Config.PingTargetArray.Select(hostNameOrAddress => new PingTracker(hostNameOrAddress, binBoundariesArray, Config, this)).ToArray();

            pingTrackerArray.DoForEach(pt => mdrfWriter.Add(pt.hGrp.GroupInfo));

            noMDRFLogger = new Logging.Logger(PartID).SetDefaultNamedValueSetForEmitter(Logging.LogGate.All, new NamedValueSet()
            {
                { "noMDRF" }
            });
        }
示例#2
0
 public PingPerformancePartConfig(PingPerformancePartConfig other)
 {
     AggregateGroupsFileIndexUserRowFlagBits = other.AggregateGroupsFileIndexUserRowFlagBits;
     SampleInterval      = other.SampleInterval;
     AggregationInterval = other.AggregationInterval;
     ResponseTimeLimit   = other.ResponseTimeLimit;
     ExtraLength         = other.ExtraLength;
     PingTargetArray     = other.PingTargetArray ?? EmptyArrayFactory <string> .Instance;
 }
示例#3
0
            public PingTracker(string hostNameOrAddress, double[] binBoundariesArray, PingPerformancePartConfig config, INotifyable notifyOnDone)
            {
                HostNameOrAddress = hostNameOrAddress;
                NotifyOnDone      = notifyOnDone;

                // calling GetHostAddresses can throw for many reasons (invalid app.config for example...)
                Func <System.Net.IPAddress []> getHostAddressesDelegate = () => System.Net.Dns.GetHostAddresses(hostNameOrAddress);

                IPAddressArray = getHostAddressesDelegate.TryGet();

                IPAddress = IPAddressArray.SafeAccess(0, System.Net.IPAddress.None);
                h         = new Histogram(binBoundariesArray);

                timeoutCountGPI = new MDRF.Writer.GroupPointInfo()
                {
                    Name = "timeoutCount", ValueCST = ContainerStorageType.UInt64, VC = new ValueContainer(0L)
                };
                failureCountGPI = new MDRF.Writer.GroupPointInfo()
                {
                    Name = "failureCount", ValueCST = ContainerStorageType.UInt64, VC = new ValueContainer(0L)
                };

                hGrp = new MDRFHistogramGroupSource("hPing_{0}".CheckedFormat(HostNameOrAddress),
                                                    h,
                                                    (ulong)config.AggregateGroupsFileIndexUserRowFlagBits,
                                                    extraClientNVS: new NamedValueSet()
                {
                    { "Ping" }, { "Host", HostNameOrAddress }, { "IPAddress", IPAddress.ToString() }
                },
                                                    extraGPISet: new[] { timeoutCountGPI, failureCountGPI });

                extraData = new byte[config.ExtraLength];

                responseTimeLimitInMSec = unchecked ((int)config.ResponseTimeLimit.TotalMilliseconds);
                responseWaitTimeLimit   = (config.ResponseTimeLimit.TotalSeconds + 0.25).FromSeconds();
            }