Exemple #1
0
 protected override void InternalDispose(bool disposing)
 {
     if (disposing)
     {
         if (this.budget != null)
         {
             if (!this.skipWLMThrottling)
             {
                 TimeSpan timeSpan = MicroDelayScope.maxCallProcessingTime - (ExDateTime.UtcNow - this.startedCallProcessingAt);
                 if (timeSpan < TimeSpan.Zero)
                 {
                     timeSpan = TimeSpan.Zero;
                 }
                 DelayEnforcementResults delayEnforcement = ResourceLoadDelayInfo.EnforceDelay(this.budget, this.workLoadSettings, this.resources, timeSpan, null);
                 this.TraceDelay(delayEnforcement);
             }
             this.budget.Dispose();
             this.budget = null;
         }
         if (this.scope != null)
         {
             this.scope.End();
             this.scope = null;
         }
     }
 }
Exemple #2
0
        private MicroDelayScope(MailboxReplicationProxyService mrsProxy, params ResourceKey[] resources)
        {
            this.startedCallProcessingAt = ExDateTime.UtcNow;
            this.resources         = resources;
            this.budget            = StandardBudget.AcquireUnthrottledBudget("MrsProxyBudget", BudgetType.ResourceTracking);
            this.workLoadSettings  = (mrsProxy.IsHighPriority ? CommonUtils.WorkloadSettingsHighPriority : CommonUtils.WorkloadSettings);
            this.skipWLMThrottling = (!ResourceHealthMonitorManager.Active || !TestIntegration.Instance.MicroDelayEnabled || mrsProxy.SkipWLMThrottling || mrsProxy.IsInFinalization);
            bool flag = false;

            try
            {
                if (!this.skipWLMThrottling)
                {
                    ResourceLoadDelayInfo.CheckResourceHealth(this.budget, this.workLoadSettings, this.resources);
                }
                this.budget.StartConnection("MailboxReplicationService.MicroDelayScope.MicroDelayScope");
                this.budget.StartLocal("MailboxReplicationService.MicroDelayScope.MicroDelayScope", default(TimeSpan));
                if (!ActivityContext.IsStarted)
                {
                    this.scope        = ActivityContext.Start(null);
                    this.scope.Action = "MailboxReplicationProxyService";
                    if (OperationContext.Current != null)
                    {
                        this.scope.UpdateFromMessage(OperationContext.Current);
                    }
                    this.scope.UserId = mrsProxy.ExchangeGuid.ToString();
                    if (mrsProxy.ClientVersion != null)
                    {
                        this.scope.ClientInfo = mrsProxy.ClientVersion.ComputerName;
                    }
                }
                flag = true;
            }
            finally
            {
                if (!flag)
                {
                    this.SuppressDisposeTracker();
                    if (this.budget != null)
                    {
                        this.budget.Dispose();
                        this.budget = null;
                    }
                    if (this.scope != null)
                    {
                        this.scope.End();
                        this.scope = null;
                    }
                }
            }
        }
Exemple #3
0
        private LocalizedString GenerateDelayInfoLogString(IBudget budget, DelayEnforcementResults info)
        {
            LocalizedString result = LocalizedString.Empty;

            if (!string.Equals(info.NotEnforcedReason, "No Delay Necessary", StringComparison.OrdinalIgnoreCase))
            {
                CmdletLogger.SafeAppendGenericInfo(this.context.UniqueId, "DelayInfo.Type", info.DelayInfo.GetType().Name);
                if (info.NotEnforcedReason != null)
                {
                    CmdletLogger.SafeAppendGenericInfo(this.context.UniqueId, "NotEnforcedReason", info.NotEnforcedReason);
                }
                if (string.Equals(info.NotEnforcedReason, "Max Delayed Threads Exceeded", StringComparison.OrdinalIgnoreCase))
                {
                    BudgetTypeSetting budgetTypeSetting = BudgetTypeSettings.Get(budget.Owner.BudgetType);
                    if (info.DelayInfo is UserQuotaDelayInfo)
                    {
                        UserQuotaDelayInfo userQuotaDelayInfo = info.DelayInfo as UserQuotaDelayInfo;
                        result = Strings.UserQuotaDelayNotEnforcedMaxThreadsExceeded((int)info.DelayInfo.Delay.TotalMilliseconds, info.DelayInfo.Required, userQuotaDelayInfo.OverBudgetException.PolicyPart, budgetTypeSetting.MaxDelayedThreads);
                    }
                    else if (info.DelayInfo is ResourceLoadDelayInfo)
                    {
                        ResourceLoadDelayInfo resourceLoadDelayInfo = info.DelayInfo as ResourceLoadDelayInfo;
                        result = Strings.ResourceLoadDelayNotEnforcedMaxThreadsExceeded((int)info.DelayInfo.Delay.TotalMilliseconds, info.DelayInfo.Required, resourceLoadDelayInfo.ResourceKey.ToString(), resourceLoadDelayInfo.ResourceLoad.ToString(), budgetTypeSetting.MaxDelayedThreads);
                    }
                    else
                    {
                        result = Strings.MicroDelayNotEnforcedMaxThreadsExceeded((int)info.DelayInfo.Delay.TotalMilliseconds, info.DelayInfo.Required, budgetTypeSetting.MaxDelayedThreads);
                    }
                }
                else
                {
                    CmdletLogger.SafeSetLogger(this.context.UniqueId, RpsCmdletMetadata.ThrottlingDelay, info.DelayedAmount.TotalMilliseconds);
                    if (info.DelayInfo is UserQuotaDelayInfo)
                    {
                        UserQuotaDelayInfo userQuotaDelayInfo2 = info.DelayInfo as UserQuotaDelayInfo;
                        result = Strings.UserQuotaDelayInfo((int)info.DelayedAmount.TotalMilliseconds, info.Enforced, (int)info.DelayInfo.Delay.TotalMilliseconds, info.DelayInfo.Required, userQuotaDelayInfo2.OverBudgetException.PolicyPart, info.NotEnforcedReason);
                    }
                    else if (info.DelayInfo is ResourceLoadDelayInfo)
                    {
                        ResourceLoadDelayInfo resourceLoadDelayInfo2 = info.DelayInfo as ResourceLoadDelayInfo;
                        result = Strings.ResourceLoadDelayInfo((int)info.DelayedAmount.TotalMilliseconds, info.Enforced, (int)info.DelayInfo.Delay.TotalMilliseconds, info.DelayInfo.Required, resourceLoadDelayInfo2.ResourceKey.ToString(), resourceLoadDelayInfo2.ResourceLoad.ToString(), info.NotEnforcedReason);
                    }
                    else
                    {
                        result = Strings.MicroDelayInfo((int)info.DelayedAmount.TotalMilliseconds, info.Enforced, (int)info.DelayInfo.Delay.TotalMilliseconds, info.DelayInfo.Required, info.NotEnforcedReason);
                    }
                }
            }
            return(result);
        }
Exemple #4
0
 static MRSService()
 {
     ServerThrottlingResource.InitializeServerThrottlingObjects(true);
     ResourceLoadDelayInfo.Initialize();
     ADSession.DisableAdminTopologyMode();
     MRSService.NextFullScanTime  = DateTime.MinValue;
     MRSService.scheduledLogsList = new List <ILogProcessable>();
     MRSService.jobPoller         = new PeriodicJobExecuter("PickHeavyJobs", new PeriodicJobExecuter.JobPollerCallback(MRSService.PickHeavyJobs), 0.1);
     MRSService.lightJobPoller    = new PeriodicJobExecuter("PickLightJobs", new PeriodicJobExecuter.JobPollerCallback(MRSService.PickLightJobs), 0.1);
     MRSService.logDumper         = new PeriodicJobExecuter("DumpLogFiles", new PeriodicJobExecuter.JobPollerCallback(MRSService.DumpLogFiles), 0.0);
     MRSService.issueCache        = new MRSIssueCache();
     MailboxReplicationServicePerformanceCounters.LastScanTime.RawValue = CommonUtils.TimestampToPerfcounterLong(DateTime.UtcNow);
     MRSService.serviceStartTime = DateTime.UtcNow;
 }
Exemple #5
0
 // Token: 0x06001D63 RID: 7523 RVA: 0x000755B4 File Offset: 0x000737B4
 private void CompleteRequest(SpeechRecognitionProcessor.SpeechProcessorAsyncCompletedArgs args)
 {
     if (this.IsSpeechRequestNotCompleted())
     {
         ExTraceGlobals.SpeechRecognitionTracer.TraceDebug <int, string>((long)this.GetHashCode(), "SpeechRecognitionProcessor - Status code='{0}', Status message='{1}'", args.HttpStatus.StatusCode, args.HttpStatus.StatusDescription);
         this.CollectAndLogStatisticsInformation(SpeechLoggerProcessType.RequestCompleted, -1);
         this.asyncResult.StatusCode                  = args.HttpStatus.StatusCode;
         this.asyncResult.StatusDescription           = args.HttpStatus.StatusDescription;
         this.asyncResult.ResponseText                = args.ResponseText;
         this.asyncResult.ThrottlingDelay             = -1.0;
         this.asyncResult.ThrottlingNotEnforcedReason = string.Empty;
         if (this.budget != null)
         {
             try
             {
                 this.budget.EndLocal();
                 DelayEnforcementResults delayEnforcementResults = ResourceLoadDelayInfo.EnforceDelay(this.budget, new WorkloadSettings(WorkloadType.OwaVoice, false), null, TimeSpan.MaxValue, null);
                 if (delayEnforcementResults != null && delayEnforcementResults.DelayInfo != null)
                 {
                     ExTraceGlobals.SpeechRecognitionTracer.TraceDebug((long)this.GetHashCode(), "SpeechRecognitionProcessor - Request id={0}, Delayed amount={1}s, Capped delay={2}s, Delay Required={3}, NotEnforcedReason={4}", new object[]
                     {
                         this.RequestId,
                         delayEnforcementResults.DelayedAmount.TotalSeconds,
                         delayEnforcementResults.DelayInfo.Delay.TotalSeconds,
                         delayEnforcementResults.DelayInfo.Required,
                         delayEnforcementResults.NotEnforcedReason
                     });
                     this.asyncResult.ThrottlingDelay             = delayEnforcementResults.DelayedAmount.TotalSeconds;
                     this.asyncResult.ThrottlingNotEnforcedReason = delayEnforcementResults.NotEnforcedReason;
                 }
                 this.budget.EndConnection();
             }
             finally
             {
                 this.budget.Dispose();
                 this.budget = null;
             }
         }
         this.asyncResult.IsCompleted = true;
         return;
     }
     ExTraceGlobals.SpeechRecognitionTracer.TraceDebug((long)this.GetHashCode(), "SpeechRecognitionProcessor.CompleteRequest: speech request already completed, ignoring this request.");
 }
        public bool TryGetDatabaseHealth(Guid databaseGuid, out int health, out List <KeyValuePair <string, double> > monitorHealthValues)
        {
            health = -1;
            monitorHealthValues = null;
            if (databaseGuid != Guid.Empty)
            {
                ResourceLoadDelayInfo.Initialize();
                ResourceKey[] array = new ResourceKey[]
                {
                    new MdbResourceHealthMonitorKey(databaseGuid),
                    new MdbReplicationResourceHealthMonitorKey(databaseGuid)
                };
                ResourceLoad[] resourceLoadList = null;
                ResourceKey    resourceKey;
                ResourceLoad   resourceLoad;
                ResourceLoadDelayInfo.GetWorstResourceAndAllHealthValues(WorkloadType.Transport, array, out resourceLoadList, out resourceKey, out resourceLoad);
                if (resourceKey != null)
                {
                    switch (resourceLoad.State)
                    {
                    case ResourceLoadState.Underloaded:
                    case ResourceLoadState.Full:
                        health = 100;
                        break;

                    case ResourceLoadState.Overloaded:
                        health = (int)(100.0 / resourceLoad.LoadRatio);
                        break;

                    case ResourceLoadState.Critical:
                        health = 0;
                        break;
                    }
                    monitorHealthValues = this.GetMDBHealthMonitors(array, resourceLoadList);
                    return(true);
                }
            }
            else
            {
                DeliveryThrottling.Diag.TraceDebug <string>(0L, "Database Guid is empty for {0}.", StoreDriverDelivery.MailboxServerFqdn);
            }
            return(false);
        }
Exemple #7
0
        private TimeSpan GetResourceMonitorDelay()
        {
            DelayInfo delay = ResourceLoadDelayInfo.GetDelay(this.budget, PublicFolderSynchronizer.WorkloadSettings, this.resourcesToAccess, true);

            if (delay != null)
            {
                PublicFolderSynchronizer.Tracer.TraceDebug <TimeSpan>((long)this.GetHashCode(), "Resource load provided delay info: {0}", delay.Delay);
                if (delay.Delay > this.maximumAllowedDelay)
                {
                    string text = string.Format("Delay suggested by ResourceMonitor of {0} ms has exceeded the maximum allowed delay of {1} ms", delay.Delay.TotalMilliseconds, this.maximumAllowedDelay.TotalMilliseconds);
                    if (this.syncContext.IsHierarchyReady)
                    {
                        throw new StorageTransientException(new LocalizedString(text));
                    }
                    PublicFolderSynchronizerLogger.LogOnServer(text, LogEventType.Warning, new Guid?(this.syncContext.CorrelationId));
                    return(this.maximumAllowedDelay);
                }
            }
            if (delay == null)
            {
                return(TimeSpan.Zero);
            }
            return(delay.Delay);
        }
 public DelayInfo GetDelay()
 {
     return(ResourceLoadDelayInfo.GetDelay(this.ibudget, TeamMailboxSyncResourceMonitorFactory.TeamMailboxSyncResourceMonitor.workloadSettings, this.resourcesToAccess, true));
 }
 public void CheckResourceHealth()
 {
     ResourceLoadDelayInfo.CheckResourceHealth(this.ibudget, TeamMailboxSyncResourceMonitorFactory.TeamMailboxSyncResourceMonitor.workloadSettings, this.resourcesToAccess);
 }
 // Token: 0x060016A7 RID: 5799 RVA: 0x000559C0 File Offset: 0x00053BC0
 public DelayEnforcementResults EnforceDelay(IThrottlingModuleInfo tmInfo, CostType[] costTypes, TimeSpan cmdletMaxPreferredDelay)
 {
     return(ResourceLoadDelayInfo.EnforceDelay(tmInfo.PSBudget, tmInfo.GetWorkloadSettings(), costTypes, tmInfo.ResourceKeys, cmdletMaxPreferredDelay, new Func <DelayInfo, bool>(tmInfo.OnBeforeDelay)));
 }
 // Token: 0x060016A6 RID: 5798 RVA: 0x000559A7 File Offset: 0x00053BA7
 public void CheckResourceHealth(IThrottlingModuleInfo tmInfo)
 {
     ResourceLoadDelayInfo.CheckResourceHealth(tmInfo.PSBudget, tmInfo.GetWorkloadSettings(), tmInfo.ResourceKeys);
 }
 // Token: 0x060016A5 RID: 5797 RVA: 0x000559A0 File Offset: 0x00053BA0
 public void Initialize()
 {
     ResourceLoadDelayInfo.Initialize();
 }
Exemple #13
0
        // Token: 0x0600029E RID: 670 RVA: 0x0000FAF8 File Offset: 0x0000DCF8
        private int InternalThrottleStoreCall(List <ResourceKey> archiveResourceDependencies)
        {
            WorkloadSettings settings = new WorkloadSettings(WorkloadType.ELCAssistant, true);

            ResourceKey[] array = (archiveResourceDependencies != null) ? archiveResourceDependencies.ToArray() : null;
            ResourceUnhealthyException ex;

            if (ResourceLoadDelayInfo.TryCheckResourceHealth(this.budget, settings, this.primaryResourceDependencies, out ex))
            {
                ELCHealthMonitor.Tracer.TraceDebug <ResourceKey>((long)this.GetHashCode(), "ELCHealthMonitor: Unhealthy database resource {0}", ex.ResourceKey);
                ELCPerfmon.HealthMonitorUnhealthy.Increment();
                throw ex;
            }
            if (array != null && array.Length > 0 && ResourceLoadDelayInfo.TryCheckResourceHealth(this.budget, settings, array, out ex))
            {
                ELCHealthMonitor.Tracer.TraceDebug <ResourceKey>((long)this.GetHashCode(), "ELCHealthMonitor: Unhealthy archive database resource {0}", ex.ResourceKey);
                ELCPerfmon.HealthMonitorUnhealthy.Increment();
                throw ex;
            }
            int backoff = 0;

            ResourceLoadDelayInfo.EnforceDelay(this.budget, settings, this.primaryResourceDependencies, TimeSpan.MaxValue, delegate(DelayInfo delayInfo)
            {
                ELCHealthMonitor.Tracer.TraceDebug((long)this.GetHashCode(), "ELCHealthMonitor: Backoff for database {0} ({1}) with resource {2} doing a wait of {3} ms", new object[]
                {
                    this.databaseName,
                    this.databaseGuid,
                    ResourceLoadDelayInfo.GetInstance(delayInfo),
                    delayInfo.Delay.TotalMilliseconds
                });
                backoff = (int)delayInfo.Delay.TotalMilliseconds;
                ELCPerfmon.HealthMonitorDelayRate.Increment();
                return(true);
            });
            ELCHealthMonitor.averageDelay.Update((float)backoff);
            ELCPerfmon.HealthMonitorAverageDelay.RawValue = (long)ELCHealthMonitor.averageDelay.Value;
            if (array != null && array.Length > 0)
            {
                backoff = 0;
                ResourceLoadDelayInfo.EnforceDelay(this.budget, settings, array, TimeSpan.MaxValue, delegate(DelayInfo delayInfo)
                {
                    ELCHealthMonitor.Tracer.TraceDebug <string, double>((long)this.GetHashCode(), "ELCHealthMonitor: Backoff for archive resource {0} doing a wait of {1} ms", ResourceLoadDelayInfo.GetInstance(delayInfo), delayInfo.Delay.TotalMilliseconds);
                    backoff = (int)delayInfo.Delay.TotalMilliseconds;
                    ELCPerfmon.HealthMonitorDelayRate.Increment();
                    return(true);
                });
                ELCHealthMonitor.averageDelay.Update((float)backoff);
                ELCPerfmon.HealthMonitorAverageDelay.RawValue = (long)ELCHealthMonitor.averageDelay.Value;
            }
            if (ResourceLoadDelayInfo.TryCheckResourceHealth(this.budget, settings, this.primaryResourceDependencies, out ex))
            {
                ELCHealthMonitor.Tracer.TraceDebug <ResourceKey>((long)this.GetHashCode(), "ELCHealthMonitor: Unhealthy database resource {0} after the delay", ex.ResourceKey);
                ELCPerfmon.HealthMonitorUnhealthy.Increment();
                throw ex;
            }
            if (array != null && array.Length > 0 && ResourceLoadDelayInfo.TryCheckResourceHealth(this.budget, settings, array, out ex))
            {
                ELCHealthMonitor.Tracer.TraceDebug <ResourceKey>((long)this.GetHashCode(), "ELCHealthMonitor: Unhealthy archive database resource {0} after the delay", ex.ResourceKey);
                ELCPerfmon.HealthMonitorUnhealthy.Increment();
                throw ex;
            }
            return(backoff);
        }