Пример #1
0
 public static void DecrementExchangeExecutingCmdlets()
 {
     if (ThrottlingPerfCounterWrapper.PerfCountersInitialized)
     {
         ThrottlingPerfCounterWrapper.DecrementPerfCounter(ThrottlingPerfCounterWrapper.throttlingPerfCounters.ExchangeExecutingCmdlets);
     }
 }
 // Token: 0x06007294 RID: 29332 RVA: 0x0017B570 File Offset: 0x00179770
 public static bool SleepIfNecessary(uint cpuStartPercent, out int sleepTime, out float cpuPercent)
 {
     sleepTime  = -1;
     cpuPercent = -1f;
     if (cpuStartPercent >= 100U || CPUBasedSleeper.ProcessCPUCounter == null)
     {
         return(false);
     }
     cpuPercent = CPUBasedSleeper.ProcessCPUCounter.GetValue();
     if (cpuPercent >= cpuStartPercent)
     {
         int num = (int)(100U - cpuStartPercent);
         if (num > 0)
         {
             float num2 = 500f / (float)num;
             sleepTime = (int)((cpuPercent - cpuStartPercent) * num2);
         }
         if (sleepTime > 0)
         {
             Thread.Sleep(sleepTime);
         }
         else
         {
             sleepTime = -1;
         }
     }
     ThrottlingPerfCounterWrapper.UpdateAverageThreadSleepTime((long)Math.Max(sleepTime, 0));
     return(sleepTime >= 0);
 }
Пример #3
0
 public static void DecrementActivePowerShellRunspaces()
 {
     if (ThrottlingPerfCounterWrapper.PerfCountersInitialized)
     {
         ThrottlingPerfCounterWrapper.DecrementPerfCounter(ThrottlingPerfCounterWrapper.throttlingPerfCounters.ActivePowerShellRunspaces);
     }
 }
Пример #4
0
 private static void UpdateBudgetsMicroDelayed()
 {
     if (!ThrottlingPerfCounterWrapper.PerfCountersInitialized)
     {
         return;
     }
     ThrottlingPerfCounterWrapper.SetNumberAndPercentCounters(ThrottlingPerfCounterWrapper.budgetsMicroDelayed, ThrottlingPerfCounterWrapper.userThrottlingPerfCounters.NumberOfUsersMicroDelayed, ThrottlingPerfCounterWrapper.userThrottlingPerfCounters.PercentageUsersMicroDelayed);
 }
Пример #5
0
 private static void UpdateBudgetsAtMaxDelay()
 {
     if (!ThrottlingPerfCounterWrapper.PerfCountersInitialized)
     {
         return;
     }
     ThrottlingPerfCounterWrapper.SetNumberAndPercentCounters(ThrottlingPerfCounterWrapper.budgetsAtMaximumDelay, ThrottlingPerfCounterWrapper.userThrottlingPerfCounters.NumberOfUsersAtMaximumDelay, ThrottlingPerfCounterWrapper.userThrottlingPerfCounters.PercentageUsersAtMaximumDelay);
 }
Пример #6
0
 public static void IncrementBudgetsAtMaxDelay(BudgetKey key)
 {
     if (!ThrottlingPerfCounterWrapper.PerfCountersInitialized)
     {
         return;
     }
     ThrottlingPerfCounterWrapper.budgetsAtMaximumDelay.TryInsertAbsolute(key, key, ThrottlingPerfCounterWrapper.PerfCounterRefreshWindow);
     ThrottlingPerfCounterWrapper.UpdateBudgetsAtMaxDelay();
 }
Пример #7
0
 public static void DecrementBudgetCount()
 {
     if (!ThrottlingPerfCounterWrapper.PerfCountersInitialized)
     {
         return;
     }
     ThrottlingPerfCounterWrapper.userThrottlingPerfCounters.TotalUniqueBudgets.Decrement();
     ThrottlingPerfCounterWrapper.UpdateBudgetsAtMaxDelay();
     ThrottlingPerfCounterWrapper.UpdateBudgetsLockedOut();
     ThrottlingPerfCounterWrapper.UpdateBudgetsMicroDelayed();
     ThrottlingPerfCounterWrapper.UpdateOverBudget();
 }
Пример #8
0
 // Token: 0x06007473 RID: 29811 RVA: 0x001800CC File Offset: 0x0017E2CC
 protected override void UpdateCachedPolicyValues(bool resetBudgetValues)
 {
     base.UpdateCachedPolicyValues(resetBudgetValues);
     lock (base.SyncRoot)
     {
         this.maxConcurrency = (int)(base.ThrottlingPolicy.MaxConcurrency.IsUnlimited ? 2147483647U : base.ThrottlingPolicy.MaxConcurrency.Value);
         if (resetBudgetValues)
         {
             this.connections = 0;
             ThrottlingPerfCounterWrapper.DecrementBudgetsAtMaxConcurrency(base.Owner);
         }
     }
 }
Пример #9
0
 public static void IncrementOverBudget(BudgetKey key, TimeSpan backoffTime)
 {
     if (!ThrottlingPerfCounterWrapper.PerfCountersInitialized)
     {
         return;
     }
     if (backoffTime == TimeSpan.Zero || backoffTime == TimeSpan.MaxValue)
     {
         backoffTime = ThrottlingPerfCounterWrapper.PerfCounterRefreshWindow;
     }
     ThrottlingPerfCounterWrapper.budgetsOverBudget.TryInsertAbsolute(key, key, backoffTime);
     ThrottlingPerfCounterWrapper.userThrottlingPerfCounters.UniqueBudgetsOverBudget.RawValue = (long)ThrottlingPerfCounterWrapper.budgetsOverBudget.Count;
     ThrottlingPerfCounterWrapper.LogEventsIfNecessary();
 }
Пример #10
0
 // Token: 0x06007471 RID: 29809 RVA: 0x00180084 File Offset: 0x0017E284
 protected override void AccountForCostHandle(CostHandle costHandle)
 {
     if (costHandle.CostType != CostType.Connection)
     {
         base.AccountForCostHandle(costHandle);
         return;
     }
     if (this.connections <= 0)
     {
         throw new InvalidOperationException("[StandardBudget.AccountForCostHandle] End for Connections was called, but there are no outstanding Connections.");
     }
     this.connections--;
     ThrottlingPerfCounterWrapper.DecrementBudgetsAtMaxConcurrency(base.Owner);
 }
 // Token: 0x060073E1 RID: 29665 RVA: 0x0017DCC8 File Offset: 0x0017BEC8
 public CostHandle StartActiveRunspace(Action <CostHandle> onRelease)
 {
     ExTraceGlobals.ClientThrottlingTracer.TraceDebug <BudgetKey>((long)this.GetHashCode(), "[PowerShellBudget.StartActiveRunspace] Start called for user {0}", base.Owner);
     this.Update();
     if (this.IsMaxRunspacesPerTimePeriodEnabled())
     {
         Interlocked.Decrement(ref this.runspacesRemaining);
     }
     Interlocked.Increment(ref this.activeRunspaces);
     if (this.TrackActiveRunspacePerfCounter)
     {
         ThrottlingPerfCounterWrapper.IncrementActivePowerShellRunspaces();
     }
     return(new CostHandle(this, CostType.ActiveRunspace, onRelease, "PowerShellBudget.StartActiveRunspace", default(TimeSpan)));
 }
Пример #12
0
 public static void Initialize(BudgetType budgetType, int?massOverBudgetPercent, bool allowReinitialize)
 {
     if (ThrottlingPerfCounterWrapper.PerfCountersInitialized && !allowReinitialize)
     {
         throw new InvalidOperationException(string.Format("ThrottlingPerformanceCounters were already initialized with budget type of '{0}'.", ThrottlingPerfCounterWrapper.budgetType));
     }
     if (massOverBudgetPercent != null && (massOverBudgetPercent.Value < 0 || massOverBudgetPercent.Value > 100))
     {
         throw new ArgumentOutOfRangeException("massOverBudgetPercent", massOverBudgetPercent.Value, "massOverBudgetPercent must be between 0 and 100 inclusive");
     }
     ThrottlingPerfCounterWrapper.budgetType = budgetType;
     ThrottlingPerfCounterWrapper.massiveNumberOfUsersOverBudgetPercent = ((massOverBudgetPercent != null) ? massOverBudgetPercent.Value : DefaultThrottlingAlertValues.MassUserOverBudgetPercent(budgetType));
     try
     {
         string instanceName = ThrottlingPerfCounterWrapper.GetInstanceName(budgetType.ToString());
         ThrottlingPerfCounterWrapper.throttlingPerfCounters     = MSExchangeThrottling.GetInstance(instanceName);
         ThrottlingPerfCounterWrapper.userThrottlingPerfCounters = MSExchangeUserThrottling.GetInstance(instanceName);
         ThrottlingPerfCounterWrapper.PerfCountersInitialized    = true;
     }
     catch (Exception ex)
     {
         ThrottlingPerfCounterWrapper.PerfCountersInitialized = false;
         Globals.LogEvent(DirectoryEventLogConstants.Tuple_InitializePerformanceCountersFailed, string.Empty, new object[]
         {
             ex.ToString()
         });
         ExTraceGlobals.ClientThrottlingTracer.TraceError <string, string>(0L, "[ThrottlingPerfCounterWrapper.Initialize] Perf counter initialization failed with exception type: {0}, Messsage: {1}", ex.GetType().FullName, ex.Message);
     }
     ThrottlingPerfCounterWrapper.budgetsMicroDelayed = new ExactTimeoutCache <BudgetKey, BudgetKey>(delegate(BudgetKey key, BudgetKey value, RemoveReason reason)
     {
         ThrottlingPerfCounterWrapper.UpdateBudgetsMicroDelayed();
     }, null, null, 1000000, false, CacheFullBehavior.ExpireExisting);
     ThrottlingPerfCounterWrapper.budgetsAtMaximumDelay = new ExactTimeoutCache <BudgetKey, BudgetKey>(delegate(BudgetKey key, BudgetKey value, RemoveReason reason)
     {
         ThrottlingPerfCounterWrapper.UpdateBudgetsAtMaxDelay();
     }, null, null, 1000000, false, CacheFullBehavior.ExpireExisting);
     ThrottlingPerfCounterWrapper.budgetsLockedOut = new ExactTimeoutCache <BudgetKey, BudgetKey>(delegate(BudgetKey key, BudgetKey value, RemoveReason reason)
     {
         ThrottlingPerfCounterWrapper.UpdateBudgetsLockedOut();
     }, null, null, 1000000, false, CacheFullBehavior.ExpireExisting);
     ThrottlingPerfCounterWrapper.budgetsOverBudget = new ExactTimeoutCache <BudgetKey, BudgetKey>(delegate(BudgetKey key, BudgetKey value, RemoveReason reason)
     {
         ThrottlingPerfCounterWrapper.UpdateOverBudget();
     }, null, null, 1000000, false, CacheFullBehavior.ExpireExisting);
     ThrottlingPerfCounterWrapper.budgetsAtMaxConcurrency = new HashSet <BudgetKey>();
 }
Пример #13
0
        private static void SetNumberAndPercentCounters(ExactTimeoutCache <BudgetKey, BudgetKey> cache, ExPerformanceCounter numberCounter, ExPerformanceCounter percentCounter)
        {
            if (!ThrottlingPerfCounterWrapper.PerfCountersInitialized)
            {
                return;
            }
            int budgetCount = ThrottlingPerfCounterWrapper.GetBudgetCount();
            int count       = cache.Count;

            numberCounter.RawValue = (long)count;
            int num = (budgetCount == 0) ? 0 : (100 * count / budgetCount);

            if (num > 100)
            {
                num = 100;
            }
            percentCounter.RawValue = (long)num;
        }
 // Token: 0x060073E0 RID: 29664 RVA: 0x0017DC20 File Offset: 0x0017BE20
 public CostHandle StartCmdlet(string cmdLetName, Action <CostHandle> onRelease)
 {
     ExTraceGlobals.ClientThrottlingTracer.TraceDebug <BudgetKey, string>((long)this.GetHashCode(), "[PowerShellBudget.StartCmdlet] Start called for user {0}, cmdlet: {1}", base.Owner, cmdLetName);
     this.Update();
     if (this.IsCmdletPerTimePeriodEnabled())
     {
         Interlocked.Decrement(ref this.cmdletsRemaining);
     }
     if (this.IsExchangeCmdletPerTimePeriodEnabled())
     {
         Interlocked.Decrement(ref this.exchangeCmdletsRemaining);
     }
     if (this.IsDestructiveCmdletPerTimePeriodEnabled() && !string.IsNullOrEmpty(cmdLetName) && PowerShellBudget.DestructiveCmdlets.Contains(cmdLetName.ToLower()))
     {
         Interlocked.Decrement(ref this.destructiveCmdletsRemaining);
     }
     ThrottlingPerfCounterWrapper.IncrementExchangeExecutingCmdlets();
     return(new CostHandle(this, CostType.CMDLET, onRelease, string.Format("PowerShellBudgetCache.StartCmdlet.{0}", cmdLetName), default(TimeSpan)));
 }
Пример #15
0
        // Token: 0x0600746F RID: 29807 RVA: 0x0017FEEC File Offset: 0x0017E0EC
        public CostHandle StartConnection(Action <CostHandle> onRelease, string callerInfo)
        {
            CostHandle result;

            lock (base.SyncRoot)
            {
                int num = this.connections + 1;
                ExTraceGlobals.FaultInjectionTracer.TraceTest <int>(3701878077U, ref num);
                bool flag2 = false;
                ExTraceGlobals.FaultInjectionTracer.TraceTest <bool>(2630233405U, ref flag2);
                if (num > this.maxConcurrency || flag2)
                {
                    ThrottlingPerfCounterWrapper.IncrementBudgetsAtMaxConcurrency(base.Owner);
                    throw base.CreateOverBudgetException("MaxConcurrency", flag2 ? "FaultInjection" : this.maxConcurrency.ToString(), 0);
                }
                this.connections++;
                result = new CostHandle(this, CostType.Connection, onRelease, callerInfo, default(TimeSpan));
            }
            return(result);
        }
Пример #16
0
        private DelayInfo GetMicroDelay(ICollection <CostType> consideredCostTypes, BudgetTypeSetting budgetTypeSetting)
        {
            if (this.microDelayWorthyWork == TimeSpan.Zero || !consideredCostTypes.Contains(CostType.CAS))
            {
                return(DelayInfo.NoDelay);
            }
            float balance = this.innerBudget.CasTokenBucket.GetBalance();

            if (balance < 0f)
            {
                SingleComponentThrottlingPolicy throttlingPolicy = this.innerBudget.ThrottlingPolicy;
                int      num       = (int)this.microDelayWorthyWork.TotalMilliseconds;
                int      num2      = num * (int)(3600000U / throttlingPolicy.RechargeRate.Value);
                float    num3      = -balance / throttlingPolicy.RechargeRate.Value;
                TimeSpan timeSpan  = TimeSpan.FromMilliseconds((double)((float)num2 * num3));
                TimeSpan timeSpan2 = (BudgetWrapper <T> .MinimumMicroDelay > timeSpan) ? BudgetWrapper <T> .MinimumMicroDelay : timeSpan;
                TimeSpan timeSpan3 = timeSpan2;
                TimeSpan timeSpan4 = (budgetTypeSetting.MaxMicroDelayMultiplier == int.MaxValue) ? TimeSpan.MaxValue : TimeSpan.FromMilliseconds((double)(num * budgetTypeSetting.MaxMicroDelayMultiplier));
                if (timeSpan3 > timeSpan4)
                {
                    ExTraceGlobals.ClientThrottlingTracer.TraceDebug((long)this.GetHashCode(), "[BudgetWrapper.GetDelay] Budget '{0}' calculated an overBudgetFactor of '{1}', but used registry cap of '{2}' instead.  Budget Snapshot: '{3}'", new object[]
                    {
                        this.Owner,
                        num3,
                        budgetTypeSetting.MaxMicroDelayMultiplier,
                        this
                    });
                    timeSpan3 = timeSpan4;
                }
                if (timeSpan3 > budgetTypeSetting.MaxDelay)
                {
                    ExTraceGlobals.ClientThrottlingTracer.TraceDebug <BudgetKey, TimeSpan, TimeSpan>((long)this.GetHashCode(), "[BudgetWrapper.GetDelay] Budget '{0}' calculated a cappedDelay of '{1}' which was higher than registry MaxDelay of '{2}'.  Using MaxDelay instead.", this.Owner, timeSpan3, budgetTypeSetting.MaxDelay);
                    ThrottlingPerfCounterWrapper.IncrementBudgetsAtMaxDelay(this.Owner);
                    timeSpan3 = budgetTypeSetting.MaxDelay;
                }
                ThrottlingPerfCounterWrapper.IncrementBudgetsMicroDelayed(this.Owner);
                DelayInfo.TraceMicroDelays(this, TimeSpan.FromMilliseconds((double)num), timeSpan3);
                return(new DelayInfo(timeSpan3, false));
            }
            return(DelayInfo.NoDelay);
        }
Пример #17
0
        private static void LogEventsIfNecessary()
        {
            int num  = 0;
            int num2 = 0;
            int num3 = 0;

            lock (ThrottlingPerfCounterWrapper.staticLock)
            {
                int budgetCount = ThrottlingPerfCounterWrapper.GetBudgetCount();
                num3 = ((budgetCount > 0) ? (100 * ThrottlingPerfCounterWrapper.budgetsOverBudget.Count / budgetCount) : 0);
            }
            if (num3 > ThrottlingPerfCounterWrapper.massiveNumberOfUsersOverBudgetPercent && ThrottlingPerfCounterWrapper.budgetsOverBudget.Count > ThrottlingPerfCounterWrapper.minUniqueBudgetsForMassiveOverBudgetAlert)
            {
                bool flag2 = false;
                lock (ThrottlingPerfCounterWrapper.staticLock)
                {
                    if (ThrottlingPerfCounterWrapper.budgetsOverBudget.Count > ThrottlingPerfCounterWrapper.minUniqueBudgetsForMassiveOverBudgetAlert)
                    {
                        flag2 = true;
                        num   = ThrottlingPerfCounterWrapper.GetBudgetCount();
                        num2  = ThrottlingPerfCounterWrapper.budgetsOverBudget.Count;
                    }
                }
                if (flag2)
                {
                    if (ThrottlingPerfCounterWrapper.OnLogMassiveNumberOfUsersOverBudgetDelegate != null)
                    {
                        ThrottlingPerfCounterWrapper.OnLogMassiveNumberOfUsersOverBudgetDelegate(num, num3);
                    }
                    Globals.LogEvent(DirectoryEventLogConstants.Tuple_ExcessiveMassUserThrottling, ThrottlingPerfCounterWrapper.budgetType.ToString(), new object[]
                    {
                        num2,
                        ThrottlingPerfCounterWrapper.budgetType,
                        num,
                        num3
                    });
                }
            }
        }
        // Token: 0x060073E4 RID: 29668 RVA: 0x0017DDDC File Offset: 0x0017BFDC
        protected override void AccountForCostHandle(CostHandle costHandle)
        {
            ExTraceGlobals.ClientThrottlingTracer.TraceDebug <BudgetKey, CostType, BudgetType>((long)this.GetHashCode(), "[PowerShellBudget.AccountForCostHandle] End called for user {0}, cost type {1}, budget type {2}", base.Owner, costHandle.CostType, base.Owner.BudgetType);
            base.AccountForCostHandle(costHandle);
            switch (costHandle.CostType)
            {
            case CostType.CMDLET:
                ThrottlingPerfCounterWrapper.DecrementExchangeExecutingCmdlets();
                return;

            case CostType.ActiveRunspace:
                Interlocked.Decrement(ref this.activeRunspaces);
                if (this.TrackActiveRunspacePerfCounter)
                {
                    ThrottlingPerfCounterWrapper.DecrementActivePowerShellRunspaces();
                }
                return;

            default:
                return;
            }
        }
Пример #19
0
        private void LockBucket()
        {
            lock (this.instanceLock)
            {
                this.locked   = true;
                this.lockedAt = TimeProvider.UtcNow;
            }
            DateTime value = this.LockedUntilUtcNonUpdating.Value;

            ThrottlingPerfCounterWrapper.IncrementBudgetsLockedOut(this.BudgetKey, value - TimeProvider.UtcNow);
            if (Globals.ProcessInstanceType != InstanceType.NotInitialized)
            {
                Globals.LogEvent(DirectoryEventLogConstants.Tuple_UserLockedOutThrottling, string.Empty, new object[]
                {
                    this.BudgetKey,
                    value,
                    this.GetTraceInt(this.MaximumBalance),
                    this.GetTraceInt(this.RechargeRate),
                    this.GetTraceInt(this.MinimumBalance)
                });
            }
            ExTraceGlobals.ClientThrottlingTracer.TraceDebug <DateTime, int>((long)this.GetHashCode(), "[TokenBucket.LockBucket] Bucket locked until {0}.  Current Pending charges: {1}", value, this.PendingCharges);
        }
Пример #20
0
        // Token: 0x060071F1 RID: 29169 RVA: 0x00179CB8 File Offset: 0x00177EB8
        protected override T CreateOnCacheMiss(BudgetKey key, ref bool shouldAdd)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            IThrottlingPolicy throttlingPolicy = null;
            LookupBudgetKey   lookupBudgetKey  = key as LookupBudgetKey;

            if (lookupBudgetKey != null)
            {
                throttlingPolicy = lookupBudgetKey.Lookup();
            }
            if (throttlingPolicy == null)
            {
                ExTraceGlobals.ClientThrottlingTracer.TraceDebug <string>((long)this.GetHashCode(), "[BudgetCache.CreateOnCacheMiss] Using global policy for account: {0}", key.ToString());
                throttlingPolicy = ThrottlingPolicyCache.Singleton.GetGlobalThrottlingPolicy();
            }
            T result = this.CreateBudget(key, throttlingPolicy);

            ThrottlingPerfCounterWrapper.IncrementBudgetCount();
            Interlocked.Increment(ref this.cacheMisses);
            return(result);
        }
Пример #21
0
 public static void Initialize(BudgetType budgetType, int?massOverBudgetPercent)
 {
     ThrottlingPerfCounterWrapper.Initialize(budgetType, massOverBudgetPercent, false);
 }
 protected ThrottlingPolicyCache()
 {
     this.globalThrottlingPolicyCache    = new ThrottlingPolicyCache.GlobalThrottlingPolicyCache(ThrottlingPolicyCache.cacheExpirationInterval);
     this.organizationThrottlingPolicies = new AutoRefreshCache <OrganizationId, CachableThrottlingPolicyItem, object>(10000L, ThrottlingPolicyCache.cacheExpirationInterval, ThrottlingPolicyCache.cacheCleanupInterval, ThrottlingPolicyCache.cachePurgeInterval, ThrottlingPolicyCache.cacheRefreshInterval, new DefaultCacheTracer <OrganizationId>(ThrottlingPolicyCache.Tracer, "OrganizationThrottlingPolicies"), ThrottlingPerfCounterWrapper.GetOrganizationThrottlingPolicyCacheCounters(10000L), new AutoRefreshCache <OrganizationId, CachableThrottlingPolicyItem, object> .CreateEntryDelegate(ThrottlingPolicyCache.ResolveOrganizationThrottlingPolicy));
     this.throttlingPolicies             = new AutoRefreshCache <OrgAndObjectId, CachableThrottlingPolicyItem, object>(10000L, ThrottlingPolicyCache.cacheExpirationInterval, ThrottlingPolicyCache.cacheCleanupInterval, ThrottlingPolicyCache.cachePurgeInterval, ThrottlingPolicyCache.cacheRefreshInterval, new DefaultCacheTracer <OrgAndObjectId>(ThrottlingPolicyCache.Tracer, "ThrottlingPolicies"), ThrottlingPerfCounterWrapper.GetThrottlingPolicyCacheCounters(10000L), new AutoRefreshCache <OrgAndObjectId, CachableThrottlingPolicyItem, object> .CreateEntryDelegate(ThrottlingPolicyCache.ResolveThrottlingPolicy));
 }
Пример #23
0
 public static void Initialize(BudgetType budgetType)
 {
     ThrottlingPerfCounterWrapper.Initialize(budgetType, null, false);
 }
Пример #24
0
 // Token: 0x060071F2 RID: 29170 RVA: 0x00179D37 File Offset: 0x00177F37
 protected override void HandleRemove(BudgetKey key, T value, RemoveReason reason)
 {
     ThrottlingPerfCounterWrapper.DecrementBudgetCount();
     base.HandleRemove(key, value, reason);
     value.Expire();
 }
Пример #25
0
        // Token: 0x0600723C RID: 29244 RVA: 0x0017A49C File Offset: 0x0017869C
        public static void Update(bool isOneHour)
        {
            if (!ThrottlingPerfCounterWrapper.PerfCountersInitialized)
            {
                return;
            }
            int[] array        = null;
            int   averageUsage = 0;

            int[] array2        = null;
            int   averageUsage2 = 0;

            PercentileUsage[] array3 = null;
            if (BudgetUsageTracker.budgetUsage.Count > 0)
            {
                List <BudgetKey> list = null;
                lock (BudgetUsageTracker.staticLock)
                {
                    if (BudgetUsageTracker.budgetUsage.Count > 0)
                    {
                        array3 = new PercentileUsage[BudgetUsageTracker.budgetUsage.Count];
                        int num = 0;
                        foreach (KeyValuePair <BudgetKey, PercentileUsage> keyValuePair in BudgetUsageTracker.budgetUsage)
                        {
                            array3[num++] = new PercentileUsage(keyValuePair.Value);
                            if (keyValuePair.Value.FiveMinuteUsage == 0 && keyValuePair.Value.OneHourUsage == 0 && TimeProvider.UtcNow - keyValuePair.Value.CreationTime > BudgetUsageTracker.PeriodicLoggingInterval)
                            {
                                if (list == null)
                                {
                                    list = new List <BudgetKey>();
                                }
                                list.Add(keyValuePair.Key);
                            }
                            keyValuePair.Value.Clear(isOneHour);
                        }
                        if (list != null)
                        {
                            foreach (BudgetKey key in list)
                            {
                                PercentileUsage percentileUsage;
                                if (BudgetUsageTracker.budgetUsage.TryGetValue(key, out percentileUsage))
                                {
                                    percentileUsage.Expired = true;
                                    BudgetUsageTracker.budgetUsage.Remove(key);
                                }
                            }
                        }
                    }
                }
            }
            if (array3 != null)
            {
                BudgetUsageTracker.GetPercentileUsage(array3, false, out array, out averageUsage);
                ThrottlingPerfCounterWrapper.SetFiveMinuteBudgetUsage(array[0], array[1], array[2], averageUsage);
                if (isOneHour)
                {
                    BudgetUsageTracker.GetPercentileUsage(array3, true, out array2, out averageUsage2);
                    ThrottlingPerfCounterWrapper.SetOneHourBudgetUsage(array2[0], array2[1], array2[2], averageUsage2);
                    return;
                }
            }
            else
            {
                if (isOneHour)
                {
                    ThrottlingPerfCounterWrapper.SetOneHourBudgetUsage(0, 0, 0, 0);
                    return;
                }
                ThrottlingPerfCounterWrapper.SetFiveMinuteBudgetUsage(0, 0, 0, 0);
            }
        }
Пример #26
0
 internal override void Clear()
 {
     base.Clear();
     ThrottlingPerfCounterWrapper.ClearCaches();
 }