public static void IncrementBudgetsMicroDelayed(BudgetKey key) { if (!ThrottlingPerfCounterWrapper.PerfCountersInitialized) { return; } ThrottlingPerfCounterWrapper.budgetsMicroDelayed.TryInsertAbsolute(key, key, ThrottlingPerfCounterWrapper.PerfCounterRefreshWindow); ThrottlingPerfCounterWrapper.UpdateBudgetsMicroDelayed(); }
public static void DecrementBudgetCount() { if (!ThrottlingPerfCounterWrapper.PerfCountersInitialized) { return; } ThrottlingPerfCounterWrapper.userThrottlingPerfCounters.TotalUniqueBudgets.Decrement(); ThrottlingPerfCounterWrapper.UpdateBudgetsAtMaxDelay(); ThrottlingPerfCounterWrapper.UpdateBudgetsLockedOut(); ThrottlingPerfCounterWrapper.UpdateBudgetsMicroDelayed(); ThrottlingPerfCounterWrapper.UpdateOverBudget(); }
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>(); }