Ejemplo n.º 1
0
 internal IThrottlingPolicy Lookup()
 {
     if (BudgetKey.LookupPolicyForTest != null)
     {
         return(BudgetKey.LookupPolicyForTest(this));
     }
     return(this.InternalLookup());
 }
Ejemplo n.º 2
0
 public static void IncrementBudgetsAtMaxDelay(BudgetKey key)
 {
     if (!ThrottlingPerfCounterWrapper.PerfCountersInitialized)
     {
         return;
     }
     ThrottlingPerfCounterWrapper.budgetsAtMaximumDelay.TryInsertAbsolute(key, key, ThrottlingPerfCounterWrapper.PerfCounterRefreshWindow);
     ThrottlingPerfCounterWrapper.UpdateBudgetsAtMaxDelay();
 }
        // Token: 0x060073DC RID: 29660 RVA: 0x0017DA84 File Offset: 0x0017BC84
        public static IPowerShellBudget Acquire(BudgetKey budgetKey)
        {
            if (budgetKey == null)
            {
                throw new ArgumentNullException("budgetKey");
            }
            PowerShellBudget.VerifyCorrectBudgetType(budgetKey.BudgetType);
            PowerShellBudget innerBudget = PowerShellBudgetCache.Singleton.Get(budgetKey);

            return(new PowerShellBudgetWrapper(innerBudget));
        }
Ejemplo n.º 4
0
 public static void DecrementBudgetsAtMaxConcurrency(BudgetKey key)
 {
     if (!ThrottlingPerfCounterWrapper.PerfCountersInitialized)
     {
         return;
     }
     lock (ThrottlingPerfCounterWrapper.staticLock)
     {
         ThrottlingPerfCounterWrapper.budgetsAtMaxConcurrency.Remove(key);
         ThrottlingPerfCounterWrapper.userThrottlingPerfCounters.UsersAtMaxConcurrency.RawValue = (long)ThrottlingPerfCounterWrapper.budgetsAtMaxConcurrency.Count;
     }
 }
Ejemplo n.º 5
0
 public static void IncrementBudgetsLockedOut(BudgetKey key, TimeSpan lockoutTime)
 {
     if (!ThrottlingPerfCounterWrapper.PerfCountersInitialized)
     {
         return;
     }
     lock (ThrottlingPerfCounterWrapper.staticLock)
     {
         ThrottlingPerfCounterWrapper.budgetsLockedOut.TryInsertAbsolute(key, key, lockoutTime);
         ThrottlingPerfCounterWrapper.userThrottlingPerfCounters.UsersLockedOut.RawValue = (long)ThrottlingPerfCounterWrapper.budgetsLockedOut.Count;
     }
 }
Ejemplo n.º 6
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();
 }
Ejemplo n.º 7
0
 // Token: 0x060071BB RID: 29115 RVA: 0x001789F0 File Offset: 0x00176BF0
 internal Budget(BudgetKey key, IThrottlingPolicy policy)
 {
     if (key == null)
     {
         throw new ArgumentNullException("key");
     }
     if (policy == null)
     {
         throw new ArgumentNullException("policy");
     }
     this.CreationTime    = TimeProvider.UtcNow;
     this.Owner           = key;
     this.percentileUsage = BudgetUsageTracker.Get(key);
     this.SetPolicy(policy, true);
 }
Ejemplo n.º 8
0
        // Token: 0x06007239 RID: 29241 RVA: 0x0017A3B0 File Offset: 0x001785B0
        public static PercentileUsage Get(BudgetKey key)
        {
            PercentileUsage percentileUsage = null;

            if (!BudgetUsageTracker.budgetUsage.TryGetValue(key, out percentileUsage) || percentileUsage == null)
            {
                lock (BudgetUsageTracker.staticLock)
                {
                    if (!BudgetUsageTracker.budgetUsage.TryGetValue(key, out percentileUsage) || percentileUsage == null)
                    {
                        percentileUsage = new PercentileUsage();
                        BudgetUsageTracker.budgetUsage[key] = percentileUsage;
                    }
                }
            }
            return(percentileUsage);
        }
        protected override PowerShellBudget CreateBudget(BudgetKey key, IThrottlingPolicy policy)
        {
            BudgetType budgetType = key.BudgetType;

            if (budgetType == BudgetType.PowerShell)
            {
                return(new PowerShellBudget(key, policy));
            }
            switch (budgetType)
            {
            case BudgetType.WSMan:
                return(new WSManBudget(key, policy));

            case BudgetType.WSManTenant:
                return(new WSManTenantBudget(key, policy));

            default:
                throw new ArgumentException("PowerShellBudgetCache can only be used to create Power-ish budgets.  Passed budget key: " + key);
            }
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
        // Token: 0x06007469 RID: 29801 RVA: 0x0017FE60 File Offset: 0x0017E060
        public static IStandardBudget Acquire(BudgetKey budgetKey)
        {
            StandardBudget innerBudget = StandardBudgetCache.Singleton.Get(budgetKey);

            return(new StandardBudgetWrapper(innerBudget));
        }
Ejemplo n.º 12
0
 // Token: 0x060071F0 RID: 29168 RVA: 0x00179CA8 File Offset: 0x00177EA8
 protected override bool HandleShouldRemove(BudgetKey key, T value)
 {
     return(value.CanExpire);
 }
Ejemplo n.º 13
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();
 }
Ejemplo n.º 14
0
 // Token: 0x060071F3 RID: 29171 RVA: 0x00179D54 File Offset: 0x00177F54
 protected override void AfterCacheHit(BudgetKey key, T value)
 {
     Interlocked.Increment(ref this.cacheHits);
     value.AfterCacheHit();
     base.AfterCacheHit(key, value);
 }
 // Token: 0x060073DF RID: 29663 RVA: 0x0017DB20 File Offset: 0x0017BD20
 internal PowerShellBudget(BudgetKey owner, IThrottlingPolicy policy) : base(owner, policy)
 {
 }
Ejemplo n.º 16
0
 // Token: 0x060071F4 RID: 29172
 protected abstract T CreateBudget(BudgetKey key, IThrottlingPolicy policy);
Ejemplo n.º 17
0
 internal WSManBudget(BudgetKey owner, IThrottlingPolicy policy) : base(owner, policy)
 {
 }
 // Token: 0x06007466 RID: 29798 RVA: 0x0017FE43 File Offset: 0x0017E043
 protected override StandardBudget CreateBudget(BudgetKey key, IThrottlingPolicy policy)
 {
     return(new StandardBudget(key, policy));
 }
Ejemplo n.º 19
0
 // Token: 0x0600746E RID: 29806 RVA: 0x0017FEDF File Offset: 0x0017E0DF
 internal StandardBudget(BudgetKey owner, IThrottlingPolicy policy) : base(owner, policy)
 {
 }
Ejemplo n.º 20
0
        public static ITokenBucket Create(ITokenBucket tokenBucket, Unlimited <uint> maxBalance, Unlimited <uint> rechargeRate, Unlimited <uint> minBalance, BudgetKey budgetKey)
        {
            if (rechargeRate == 0U)
            {
                return(new FullyThrottledTokenBucket(tokenBucket));
            }
            if (rechargeRate == 2147483647U || rechargeRate.IsUnlimited)
            {
                return(new UnthrottledTokenBucket(tokenBucket));
            }
            TokenBucket tokenBucket2 = tokenBucket as TokenBucket;

            if (tokenBucket2 != null && tokenBucket2.BudgetKey == budgetKey)
            {
                tokenBucket2.UpdateSettings(maxBalance, rechargeRate, minBalance);
                return(tokenBucket);
            }
            return(new TokenBucket(tokenBucket, maxBalance, rechargeRate, minBalance, budgetKey));
        }
Ejemplo n.º 21
0
 private TokenBucket(ITokenBucket oldBucket, Unlimited <uint> maxBalance, Unlimited <uint> rechargeRate, Unlimited <uint> minBalance, BudgetKey budgetKey)
 {
     this.BudgetKey     = budgetKey;
     this.LastUpdateUtc = TimeProvider.UtcNow;
     this.UpdateSettings(maxBalance, rechargeRate, minBalance);
     this.balance = (maxBalance.IsUnlimited ? 2147483647U : maxBalance.Value);
     if (oldBucket != null)
     {
         this.PendingCharges = oldBucket.PendingCharges;
     }
 }
Ejemplo n.º 22
0
 public static ITokenBucket Create(Unlimited <uint> maxBalance, Unlimited <uint> rechargeRate, Unlimited <uint> minBalance, BudgetKey budgetKey)
 {
     return(TokenBucket.Create(null, maxBalance, rechargeRate, minBalance, budgetKey));
 }