コード例 #1
0
        public void ProcessLogs()
        {
            if (!this.LogIsNeeded())
            {
                return;
            }
            MRSSettingsLogCollection config = ConfigBase <MRSConfigSchema> .GetConfig <MRSSettingsLogCollection>("MRSSettingsLogList");

            if (config == null)
            {
                MRSSettingsLog.PublishPeriodicExceptionNotification(string.Format("The value for {0} setting is corrupt. Check and correct setting value", "MRSSettingsLogList"));
                return;
            }
            foreach (MRSSettingsLogCollection.MRSSettingsLogElement mrssettingsLogElement in config.SettingsLogCollection)
            {
                try
                {
                    MRSSettingsData loggingStatsData;
                    if (StringComparer.OrdinalIgnoreCase.Equals(mrssettingsLogElement.SettingName, "IsJobPickupEnabled"))
                    {
                        using (IEnumerator enumerator2 = Enum.GetValues(typeof(RequestWorkloadType)).GetEnumerator())
                        {
                            while (enumerator2.MoveNext())
                            {
                                object obj = enumerator2.Current;
                                RequestWorkloadType requestWorkloadType = (RequestWorkloadType)obj;
                                if (requestWorkloadType != RequestWorkloadType.None)
                                {
                                    SettingsContextBase settingsContextBase = new GenericSettingsContext("RequestWorkloadType", requestWorkloadType.ToString(), null);
                                    using (settingsContextBase.Activate())
                                    {
                                        bool config2 = ConfigBase <MRSConfigSchema> .GetConfig <bool>(mrssettingsLogElement.SettingName);

                                        loggingStatsData = new MRSSettingsData
                                        {
                                            Context      = string.Format("{0}={1}", "RequestWorkloadType", requestWorkloadType.ToString()),
                                            SettingName  = "IsJobPickupEnabled",
                                            SettingValue = Convert.ToInt32(config2).ToString()
                                        };
                                    }
                                    this.Write(loggingStatsData);
                                }
                            }
                            continue;
                        }
                    }
                    if (StringComparer.OrdinalIgnoreCase.Equals(mrssettingsLogElement.SettingName, "IgnoreHealthMonitor"))
                    {
                        List <ResourceKey> list = new List <ResourceKey>
                        {
                            ADResourceKey.Key,
                            ProcessorResourceKey.Local
                        };
                        using (List <ResourceKey> .Enumerator enumerator3 = list.GetEnumerator())
                        {
                            while (enumerator3.MoveNext())
                            {
                                ResourceKey         resourceKey          = enumerator3.Current;
                                SettingsContextBase settingsContextBase2 = new GenericSettingsContext("WlmHealthMonitor", resourceKey.ToString(), null);
                                using (settingsContextBase2.Activate())
                                {
                                    bool config3 = ConfigBase <MRSConfigSchema> .GetConfig <bool>(mrssettingsLogElement.SettingName);

                                    loggingStatsData = new MRSSettingsData
                                    {
                                        Context      = string.Format("{0}={1}", "WlmHealthMonitor", resourceKey.ToString()),
                                        SettingName  = "IgnoreHealthMonitor",
                                        SettingValue = Convert.ToInt32(config3).ToString()
                                    };
                                }
                                this.Write(loggingStatsData);
                            }
                            continue;
                        }
                    }
                    ConfigurationProperty configurationProperty;
                    if (!ConfigBase <MRSConfigSchema> .Schema.TryGetConfigurationProperty(mrssettingsLogElement.SettingName, out configurationProperty))
                    {
                        throw new MRSSettingsLog.BadConfigSettingException(string.Format("Can not find corresponding name of MRS config setting specified by string {0}. Check if the setting name and correct it if needed", mrssettingsLogElement.SettingName));
                    }
                    string settingValue = string.Empty;
                    if (configurationProperty.Type == typeof(bool))
                    {
                        settingValue = ConfigBase <MRSConfigSchema> .GetConfig <bool>(configurationProperty.Name).ToString();
                    }
                    else if (configurationProperty.Type == typeof(int))
                    {
                        settingValue = ConfigBase <MRSConfigSchema> .GetConfig <int>(configurationProperty.Name).ToString();
                    }
                    else if (configurationProperty.Type == typeof(long))
                    {
                        settingValue = ConfigBase <MRSConfigSchema> .GetConfig <long>(configurationProperty.Name).ToString();
                    }
                    else if (configurationProperty.Type == typeof(string))
                    {
                        settingValue = ConfigBase <MRSConfigSchema> .GetConfig <string>(configurationProperty.Name);
                    }
                    else
                    {
                        if (!(configurationProperty.Type == typeof(TimeSpan)))
                        {
                            throw new MRSSettingsLog.BadConfigSettingException(string.Format("Type {0} of a provided setting {1} is not supported by logging functionality. Check and correct list of the settings to be logged", configurationProperty.Type, mrssettingsLogElement.SettingName));
                        }
                        settingValue = ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>(configurationProperty.Name).ToString();
                    }
                    loggingStatsData = new MRSSettingsData
                    {
                        Context      = "Server",
                        SettingName  = configurationProperty.Name,
                        SettingValue = settingValue
                    };
                    this.Write(loggingStatsData);
                }
                catch (MRSSettingsLog.BadConfigSettingException ex)
                {
                    MRSSettingsLog.PublishPeriodicExceptionNotification(ex.Message);
                }
            }
        }
コード例 #2
0
        XElement IDiagnosable.GetDiagnosticInfo(DiagnosableParameters parameters)
        {
            XElement xelement = new XElement(MRSService.DiagnosticsComponentName);
            MRSDiagnosticArgument arguments;

            try
            {
                arguments = new MRSDiagnosticArgument(parameters.Argument);
            }
            catch (DiagnosticArgumentException ex)
            {
                xelement.Add(new XElement("Error", "Encountered exception: " + ex.Message));
                return(xelement);
            }
            xelement.Add(new object[]
            {
                new XElement("ServiceStartTime", MRSService.serviceStartTime),
                new XElement("LastScanDuration", MRSService.lastFullScanDuration),
                new XElement("LastScanTime", MRSService.lastFullScanTime.ToString()),
                new XElement("DurationSinceLastScan", (long)(DateTime.UtcNow - MRSService.lastFullScanTime).TotalMilliseconds),
                new XElement("NextFullScanTime", MRSService.NextFullScanTime.ToString()),
                new XElement("NextLightJobsFullScanTime", MRSService.nextLightJobsFullScanTime.ToString())
            });
            if (arguments.ArgumentCount == 0)
            {
                xelement.Add(new XElement("Help", "Supported arguments: " + arguments.GetSupportedArguments()));
            }
            if (arguments.HasArgument("binaryversions"))
            {
                string assemblyNamePattern = arguments.GetArgument <string>("binaryversions");
                xelement.Add(arguments.RunDiagnosticOperation(() => CommonUtils.GetBinaryVersions(assemblyNamePattern)));
            }
            if (arguments.HasArgument("job"))
            {
                xelement.Add(arguments.RunDiagnosticOperation(() => MailboxSyncerJobs.GetJobsDiagnosticInfo(arguments)));
            }
            if (arguments.HasArgument("reservations"))
            {
                xelement.Add(arguments.RunDiagnosticOperation(() => ReservationManager.GetReservationsDiagnosticInfo(arguments)));
            }
            if (arguments.HasArgument("resources"))
            {
                xelement.Add(arguments.RunDiagnosticOperation(() => ReservationManager.GetResourcesDiagnosticInfo(arguments)));
            }
            if (arguments.HasArgument("queues"))
            {
                xelement.Add(arguments.RunDiagnosticOperation(() => MRSQueue.GetDiagnosticInfo(arguments)));
            }
            if (arguments.HasArgument("workloads"))
            {
                XElement xelement2 = new XElement("Workloads");
                foreach (object obj in Enum.GetValues(typeof(RequestWorkloadType)))
                {
                    RequestWorkloadType requestWorkloadType = (RequestWorkloadType)obj;
                    if (requestWorkloadType != RequestWorkloadType.None)
                    {
                        GenericSettingsContext genericSettingsContext = new GenericSettingsContext("RequestWorkloadType", requestWorkloadType.ToString(), null);
                        using (genericSettingsContext.Activate())
                        {
                            bool config = ConfigBase <MRSConfigSchema> .GetConfig <bool>("IsJobPickupEnabled");

                            xelement2.Add(new XElement("Workload", new object[]
                            {
                                new XAttribute("Name", requestWorkloadType.ToString()),
                                new XAttribute("IsJobPickupEnabled", config)
                            }));
                        }
                    }
                }
                xelement.Add(xelement2);
            }
            return(xelement);
        }