コード例 #1
0
        public static ReservationBase CreateReservation(Guid mailboxGuid, TenantPartitionHint partitionHint, Guid resourceId, ReservationFlags flags, string clientName)
        {
            ReservationBase result;

            using (DisposeGuard disposeGuard = default(DisposeGuard))
            {
                SettingsContextBase settingsContextBase = new MailboxSettingsContext(mailboxGuid, null);
                if (partitionHint != null)
                {
                    settingsContextBase = new OrganizationSettingsContext(OrganizationId.FromExternalDirectoryOrganizationId(partitionHint.GetExternalDirectoryOrganizationId()), settingsContextBase);
                }
                ReservationBase reservationBase;
                if (resourceId == MRSResource.Id.ObjectGuid)
                {
                    reservationBase = new MRSReservation();
                }
                else
                {
                    if (flags.HasFlag(ReservationFlags.Read))
                    {
                        reservationBase = new ReadReservation();
                    }
                    else
                    {
                        reservationBase = new WriteReservation();
                    }
                    settingsContextBase = new DatabaseSettingsContext(resourceId, settingsContextBase);
                }
                disposeGuard.Add <ReservationBase>(reservationBase);
                settingsContextBase           = new GenericSettingsContext("WorkloadType", reservationBase.WorkloadType.ToString(), settingsContextBase);
                reservationBase.MailboxGuid   = mailboxGuid;
                reservationBase.PartitionHint = partitionHint;
                reservationBase.ResourceId    = resourceId;
                reservationBase.Flags         = flags;
                reservationBase.ClientName    = clientName;
                using (settingsContextBase.Activate())
                {
                    reservationBase.ReserveResources();
                }
                disposeGuard.Success();
                result = reservationBase;
            }
            return(result);
        }
コード例 #2
0
        private static void WriteInternal(Guid requestGuid, Exception failure, bool isFatal, RequestState requestState, SyncStage syncStage, string folderName, string operationType, Guid failureGuid, int failureLevel)
        {
            FailureData objectToLog = default(FailureData);

            objectToLog.FailureGuid   = failureGuid;
            objectToLog.RequestGuid   = requestGuid;
            objectToLog.Failure       = failure;
            objectToLog.FailureLevel  = failureLevel;
            objectToLog.IsFatal       = isFatal;
            objectToLog.RequestState  = requestState;
            objectToLog.SyncStage     = syncStage;
            objectToLog.FolderName    = folderName;
            objectToLog.OperationType = operationType;
            if (objectToLog.OperationType == null && objectToLog.Failure != null)
            {
                string dataContext = ExecutionContext.GetDataContext(failure);
                objectToLog.OperationType = FailureLog.GetDataContextToPersist(dataContext);
            }
            GenericSettingsContext genericSettingsContext = new GenericSettingsContext("FailureType", CommonUtils.GetFailureType(failure), null);

            using (genericSettingsContext.Activate())
            {
                if (ConfigBase <MRSConfigSchema> .GetConfig <bool>("SendGenericWatson"))
                {
                    string watsonHash;
                    CommonUtils.SendGenericWatson(failure, CommonUtils.FullFailureMessageWithCallStack(failure, 5), out watsonHash);
                    objectToLog.WatsonHash = watsonHash;
                }
                else
                {
                    objectToLog.WatsonHash = CommonUtils.ComputeCallStackHash(failure, 5);
                }
            }
            FailureLog.instance.LogObject(objectToLog);
            if (failure.InnerException != null)
            {
                FailureLog.WriteInternal(requestGuid, failure.InnerException, isFatal, requestState, syncStage, folderName, operationType, failureGuid, failureLevel + 1);
            }
        }
コード例 #3
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);
                }
            }
        }
コード例 #4
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);
        }