コード例 #1
0
 private static void OnUserRemovedFromCache(string userToken, FailureThrottling.FailureCounter value, RemoveReason reason)
 {
     Logger.TraceDebug(ExTraceGlobals.FailureThrottlingTracer, "User {0} is removed from failure throttling user cache. Reason: {1}", new object[]
     {
         userToken,
         reason
     });
     FailFastModule.RemotePowershellPerfCounter.FailureThrottlingUserCacheSize.RawValue = (long)FailureThrottling.failureThrottlingUserCache.Count;
 }
コード例 #2
0
 private static FailureThrottling.FailureCounter GetCounter(string userToken)
 {
     Logger.EnterFunction(ExTraceGlobals.FailureThrottlingTracer, "FailureThrottlingUserCache.GetCounter");
     FailureThrottling.FailureCounter failureCounter;
     FailureThrottling.failureThrottlingUserCache.TryGetValue(userToken, out failureCounter);
     if (failureCounter == null || !failureCounter.IsValid)
     {
         Logger.TraceDebug(ExTraceGlobals.FailureThrottlingTracer, "Create counter for User {0}.", new object[]
         {
             userToken
         });
         failureCounter = new FailureThrottling.FailureCounter();
         FailureThrottling.failureThrottlingUserCache.InsertAbsolute(userToken, failureCounter, FailureThrottling.FailureThrottlingTimePeriod, new RemoveItemDelegate <string, FailureThrottling.FailureCounter>(FailureThrottling.OnUserRemovedFromCache));
         FailFastModule.RemotePowershellPerfCounter.FailureThrottlingUserCacheSize.RawValue = (long)FailureThrottling.failureThrottlingUserCache.Count;
     }
     Logger.ExitFunction(ExTraceGlobals.FailureThrottlingTracer, "FailureThrottlingUserCache.GetCounter");
     return(failureCounter);
 }
コード例 #3
0
        internal static bool CountBasedOnStatusCode(string userToken, int statusCode)
        {
            int num;

            if (statusCode != 200)
            {
                if (statusCode != 400 && statusCode != 500)
                {
                    return(false);
                }
                num = 1;
            }
            else
            {
                num = -1;
            }
            FailureThrottling.FailureCounter counter = FailureThrottling.GetCounter(userToken);
            counter.AddDelta(num);
            Logger.TraceDebug(ExTraceGlobals.FailureThrottlingTracer, "User {0} counter changed to be {1}. Current status code is {2}.", new object[]
            {
                userToken,
                counter.Value,
                statusCode
            });
            if (num == 1 && counter.Value > FailureThrottling.failureThrottlingLimit)
            {
                Logger.TraceDebug(ExTraceGlobals.FailureThrottlingTracer, "User {0} is OverBudget. Counter: {1}. FailureThrottlingLimit: {2}", new object[]
                {
                    userToken,
                    counter.Value,
                    FailureThrottling.failureThrottlingLimit
                });
                return(true);
            }
            return(false);
        }