// Token: 0x060075F9 RID: 30201 RVA: 0x00184534 File Offset: 0x00182734 private bool UpdateIsNeeded(CacheableResourceHealthMonitor.LoadInfo loadInfo, ResourceLoad newLoad) { return((loadInfo.Load == ResourceLoad.Unknown && newLoad != ResourceLoad.Unknown) || this.LastUpdateUtc > loadInfo.UpdateUtc || newLoad == ResourceLoad.Critical || newLoad > loadInfo.Load); }
// Token: 0x060075F6 RID: 30198 RVA: 0x00184160 File Offset: 0x00182360 public virtual ResourceLoad GetResourceLoad(WorkloadClassification classification, bool raw = false, object optionalData = null) { if (!this.Settings.Enabled) { return(ResourceLoad.Zero); } int metricValue = this.GetMetricValue(optionalData); if (metricValue < 0) { return(ResourceLoad.Unknown); } ResourceMetricPolicy resourceMetricPolicy = new ResourceMetricPolicy(this.MetricType, classification, this.Settings); ResourceLoad resourceLoad = resourceMetricPolicy.InterpretMetricValue(metricValue); if (!raw) { CacheableResourceHealthMonitor.LoadInfo loadInfo = this.loadInfo[classification]; if (this.UpdateIsNeeded(loadInfo, resourceLoad)) { try { if (Monitor.TryEnter(this.instanceLock) && this.UpdateIsNeeded(loadInfo, resourceLoad)) { switch (resourceLoad.State) { case ResourceLoadState.Unknown: loadInfo.Load = resourceLoad; break; case ResourceLoadState.Underloaded: case ResourceLoadState.Full: if (loadInfo.Load < ResourceLoad.Full) { loadInfo.Load = resourceLoad; } else if (this.LastUpdateUtc > loadInfo.UpdateUtc) { if (loadInfo.Load == ResourceLoad.Full) { loadInfo.Load = resourceLoad; } else if (loadInfo.Load == ResourceLoad.Critical) { loadInfo.Load = new ResourceLoad(resourceMetricPolicy.MaxOverloaded.LoadRatio, new int?(metricValue), null); } else if (resourceLoad.State == ResourceLoadState.Underloaded) { double num = (resourceMetricPolicy.MaxOverloaded - ResourceLoad.Full) / (double)CacheableResourceHealthMonitor.numberOfAdjustmentSteps; if (loadInfo.Load - ResourceLoad.Full > num) { loadInfo.Load -= num; } else { loadInfo.Load = new ResourceLoad(ResourceLoad.Full.LoadRatio, new int?(metricValue), null); } } } break; case ResourceLoadState.Overloaded: if (loadInfo.Load < resourceLoad) { loadInfo.Load = resourceLoad; } else if (this.LastUpdateUtc > loadInfo.UpdateUtc) { double delta = (resourceMetricPolicy.MaxOverloaded - ResourceLoad.Full) / (double)CacheableResourceHealthMonitor.numberOfAdjustmentSteps; if (loadInfo.Load + delta <= resourceMetricPolicy.MaxOverloaded) { loadInfo.Load += delta; } else { loadInfo.Load = new ResourceLoad(ResourceLoad.Critical.LoadRatio, new int?(metricValue), null); } } break; case ResourceLoadState.Critical: loadInfo.Load = resourceLoad; break; } } } finally { if (Monitor.IsEntered(this.instanceLock)) { Monitor.Exit(this.instanceLock); } } } resourceLoad = loadInfo.Load; } object resourceLoadlInfo = this.GetResourceLoadlInfo(resourceLoad); if (resourceLoadlInfo != null) { resourceLoad = new ResourceLoad(resourceLoad.LoadRatio, resourceLoad.Metric, resourceLoadlInfo); } ResourceLoadPerfCounterWrapper.Get(this.resourceKey, classification).Update(metricValue, resourceLoad); lock (this.lastEntries) { SystemWorkloadManagerLogEntry value = null; this.lastEntries.TryGetValue(classification, out value); SystemWorkloadManagerBlackBox.RecordMonitorUpdate(ref value, this.resourceKey, classification, resourceLoad); this.lastEntries[classification] = value; } ExTraceGlobals.ResourceHealthManagerTracer.TraceDebug <ResourceMetricType, ResourceLoad>((long)this.GetHashCode(), "[ResourceLoadMonitor.GetResourceLoad] MetricType={0}, Current Load={1}.", this.MetricType, resourceLoad); return(resourceLoad); }