コード例 #1
0
 private DelayEnforcementResults(DelayInfo innerDelay, bool enforced, string notEnforcedReason, TimeSpan delayedAmount)
 {
     this.DelayInfo         = innerDelay;
     this.Enforced          = enforced;
     this.NotEnforcedReason = notEnforcedReason;
     this.DelayedAmount     = delayedAmount;
 }
コード例 #2
0
        public DelayInfo GetDelay(ICollection <CostType> consideredCostTypes)
        {
            DelayInfo faultInjectionDelay = this.GetFaultInjectionDelay();

            if (faultInjectionDelay != DelayInfo.NoDelay)
            {
                return(faultInjectionDelay);
            }
            BudgetTypeSetting budgetTypeSetting = BudgetTypeSettings.Get(this.Owner.BudgetType);
            DelayInfo         hardQuotaDelay    = this.GetHardQuotaDelay(consideredCostTypes, budgetTypeSetting);

            if (hardQuotaDelay.Delay == budgetTypeSetting.MaxDelay)
            {
                return(hardQuotaDelay);
            }
            DelayInfo microDelay = this.GetMicroDelay(consideredCostTypes, budgetTypeSetting);

            if (hardQuotaDelay.Delay >= microDelay.Delay)
            {
                ExTraceGlobals.ClientThrottlingTracer.TraceDebug <TimeSpan, TimeSpan>((long)this.GetHashCode(), "[BudgetWrapper.GetDelay] UserQuota delay '{0}' was greater than micro delay '{1}'", hardQuotaDelay.Delay, microDelay.Delay);
                return(hardQuotaDelay);
            }
            ExTraceGlobals.ClientThrottlingTracer.TraceDebug <TimeSpan, TimeSpan>((long)this.GetHashCode(), "[BudgetWrapper.GetDelay] Micro delay '{0}' was greater than user quota delay '{1}'", microDelay.Delay, hardQuotaDelay.Delay);
            return(microDelay);
        }
コード例 #3
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);
        }
コード例 #4
0
 public DelayEnforcementResults(DelayInfo innerDelay, TimeSpan delayedAmount) : this(innerDelay, true, null, delayedAmount)
 {
 }
コード例 #5
0
 public DelayEnforcementResults(DelayInfo innerDelay, string notEnforcedReason) : this(innerDelay, false, notEnforcedReason, TimeSpan.Zero)
 {
 }