Exemplo n.º 1
0
        private ResourceLoad GetCurrentLoad()
        {
            ResourceLoad result;

            if (this.IsDisabled)
            {
                result = ResourceLoad.Zero;
            }
            else if (TestIntegration.Instance.AssumeWLMUnhealthyForReservations)
            {
                result = new ResourceLoad(12321.0, new int?(12321), null);
            }
            else
            {
                IResourceLoadMonitor resourceLoadMonitor = ResourceHealthMonitorManager.Singleton.Get(this.WlmResourceKey);
                if (resourceLoadMonitor == null)
                {
                    result = new ResourceLoad(24642.0, new int?(24642), null);
                }
                else
                {
                    result = resourceLoadMonitor.GetResourceLoad(this.Owner.WorkloadClassification, false, null);
                }
            }
            this.ResourceHealthPerfCounter.RawValue = (long)result.State;
            return(result);
        }
Exemplo n.º 2
0
 protected internal void CheckExpired()
 {
     while (this.wrappedMonitor.Expired)
     {
         lock (this.instanceLock)
         {
             if (this.wrappedMonitor.Expired)
             {
                 IResourceLoadMonitor resourceLoadMonitor = ResourceHealthMonitorManager.Singleton.Get(this.wrappedMonitor.Key);
                 this.wrappedMonitor = (resourceLoadMonitor as ResourceHealthMonitorWrapper).wrappedMonitor;
             }
         }
         if (this.wrappedMonitor.Expired)
         {
             ExTraceGlobals.ClientThrottlingTracer.TraceDebug <ResourceKey>((long)this.GetHashCode(), "[ResourceHealthMonitorWrapper.CheckExpired] Retrieved expired monitor from cache '{0}'.  Will try again.", this.wrappedMonitor.Key);
             Thread.Yield();
         }
     }
 }
Exemplo n.º 3
0
        protected void SetMetrics(ADMetrics newMetrics, string forestFqdn)
        {
            ADMetrics oldMetrics;

            if (newMetrics == null)
            {
                this.metricValuesDictionary[forestFqdn] = -1;
            }
            else if (newMetrics.AllServerMetrics.Count == 1)
            {
                this.metricValuesDictionary[forestFqdn] = 0;
            }
            else if (this.metricsDictionary.TryGetValue(forestFqdn, out oldMetrics))
            {
                this.SetInjectionRates(oldMetrics, newMetrics);
                this.metricValuesDictionary[forestFqdn] = this.CalculateMetricValue(newMetrics);
                if (DirectoryThrottlingLog.LoggingEnabled)
                {
                    int countOfDCsToLog = DirectoryThrottlingLog.CountOfDCsToLog;
                    Dictionary <string, ADServerMetrics> topNDomainControllers = newMetrics.GetTopNDomainControllers(countOfDCsToLog);
                    IResourceLoadMonitor resourceLoadMonitor = ResourceHealthMonitorManager.Singleton.Get(ADResourceKey.Key);
                    ResourceLoad         resourceLoad        = resourceLoadMonitor.GetResourceLoad(WorkloadClassification.Discretionary, false, forestFqdn);
                    DirectoryThrottlingLog.Instance.Log(forestFqdn, resourceLoad.State, this.metricValuesDictionary[forestFqdn], topNDomainControllers);
                }
                ExTraceGlobals.ResourceHealthManagerTracer.TraceDebug <string, int>((long)this.GetHashCode(), "[ADResourceHealthMonitor::SetMetrics] Current Metrics for forest {0} is={1}.", forestFqdn, this.metricValuesDictionary[forestFqdn]);
            }
            else
            {
                this.metricValuesDictionary[forestFqdn] = -1;
            }
            if (newMetrics != null)
            {
                this.metricsDictionary[forestFqdn] = newMetrics;
                this.LastUpdateUtc = (DateTime)newMetrics.UpdateTime;
            }
        }