Exemplo n.º 1
0
        // Token: 0x060002F7 RID: 759 RVA: 0x0000F8AC File Offset: 0x0000DAAC
        BackOffValue IAirSyncUser.GetBudgetBackOffValue()
        {
            BackOffValue backOffValue = null;

            if (((IAirSyncUser)this).Budget != null)
            {
                ITokenBucket budgetTokenBucket = ((IAirSyncUser)this).GetBudgetTokenBucket();
                if (budgetTokenBucket == null)
                {
                    AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, null, "[AirSyncUser.GetBudgetBackOffDuration] Budget does not contain a token bucket.  Likely unthrottled.");
                    return(BackOffValue.NoBackOffValue);
                }
                float balance = budgetTokenBucket.GetBalance();
                AirSyncDiagnostics.TraceInfo <float, int>(ExTraceGlobals.RequestsTracer, null, "[AirSyncUser.GetBudgetBackOffDuration]. Balance :{0}, RechargeRate:{1}", balance, budgetTokenBucket.RechargeRate);
                backOffValue = new BackOffValue
                {
                    BackOffReason = "Budget"
                };
                if ((double)balance < GlobalSettings.BudgetBackOffMinThreshold.TotalMilliseconds)
                {
                    backOffValue.BackOffDuration = Math.Ceiling((GlobalSettings.BudgetBackOffMinThreshold.TotalMilliseconds - (double)balance) * 60.0 * 60.0 / (double)budgetTokenBucket.RechargeRate);
                    backOffValue.BackOffType     = ((balance > (float)(ulong.MaxValue * (ulong)((IAirSyncUser)this).Budget.ThrottlingPolicy.EasMaxBurst.Value)) ? BackOffType.Medium : BackOffType.High);
                }
                else
                {
                    backOffValue.BackOffDuration = Math.Ceiling((GlobalSettings.BudgetBackOffMinThreshold.TotalMilliseconds - (double)balance) / 1000.0);
                }
            }
            AirSyncDiagnostics.TraceInfo <double, BackOffType>(ExTraceGlobals.RequestsTracer, null, "[AirSyncUser.GetBudgetBackOffDuration]. BudgetBackOff Duration:{0} sec. BackOffType:{1}", backOffValue.BackOffDuration, backOffValue.BackOffType);
            return(backOffValue ?? BackOffValue.NoBackOffValue);
        }
Exemplo n.º 2
0
        // Token: 0x06000562 RID: 1378 RVA: 0x0001F9A8 File Offset: 0x0001DBA8
        private BackOffValue GetAutoBlockBackOffTimeForSyncCommands()
        {
            int behaviorTypeIncidenceLimit = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.SyncCommands).BehaviorTypeIncidenceLimit;
            EnhancedTimeSpan behaviorTypeIncidenceDuration = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.SyncCommands).BehaviorTypeIncidenceDuration;

            if (behaviorTypeIncidenceDuration.TotalSeconds == 0.0)
            {
                return(BackOffValue.NoBackOffValue);
            }
            if (this.syncTimes == null || this.syncTimes.Count == 0 || this.syncTimes.Count <= behaviorTypeIncidenceLimit / 2)
            {
                AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "GetAutoblockBackOffTime: Skip calculating backOff time.");
                return(new BackOffValue
                {
                    BackOffDuration = -1.0 * behaviorTypeIncidenceDuration.TotalSeconds,
                    BackOffType = BackOffType.Low,
                    BackOffReason = AutoblockThresholdType.SyncCommands.ToString()
                });
            }
            TimeSpan     currentDuration = ExDateTime.UtcNow.Subtract(this.syncTimes[0]);
            BackOffValue backOffValue    = this.CalculateAutoBlockBackOffTime(behaviorTypeIncidenceLimit, behaviorTypeIncidenceDuration, this.syncTimes.Count, currentDuration, AutoblockThresholdType.SyncCommands.ToString());

            AirSyncDiagnostics.TraceInfo <int, double>(ExTraceGlobals.RequestsTracer, this, "GetAutoblockBackOffTime: SyncCommandLimit:{0}, backOffDuration:{1}", behaviorTypeIncidenceLimit, backOffValue.BackOffDuration);
            return(backOffValue);
        }
Exemplo n.º 3
0
        // Token: 0x06000561 RID: 1377 RVA: 0x0001F93C File Offset: 0x0001DB3C
        public BackOffValue GetAutoBlockBackOffTime()
        {
            BackOffValue autoBlockBackOffTimeForSyncCommands      = this.GetAutoBlockBackOffTimeForSyncCommands();
            BackOffValue autoBlockBackOffTimeForCommandsFrequency = this.GetAutoBlockBackOffTimeForCommandsFrequency();

            if (autoBlockBackOffTimeForSyncCommands.CompareTo(autoBlockBackOffTimeForCommandsFrequency) > 0)
            {
                AirSyncDiagnostics.TraceInfo <double, BackOffType, string>(ExTraceGlobals.RequestsTracer, this, "GetAutoblockBackOffTime: BackOffTime-{0} sec, BackOffType-{1}, BackOffReason:{2}", autoBlockBackOffTimeForSyncCommands.BackOffDuration, autoBlockBackOffTimeForSyncCommands.BackOffType, autoBlockBackOffTimeForSyncCommands.BackOffReason);
                return(autoBlockBackOffTimeForSyncCommands);
            }
            AirSyncDiagnostics.TraceInfo <double, BackOffType, string>(ExTraceGlobals.RequestsTracer, this, "GetAutoblockBackOffTime: BackOffTime-{0} sec, BackOffType-{1}, BackOffReason:{2}", autoBlockBackOffTimeForCommandsFrequency.BackOffDuration, autoBlockBackOffTimeForCommandsFrequency.BackOffType, autoBlockBackOffTimeForCommandsFrequency.BackOffReason);
            return(autoBlockBackOffTimeForCommandsFrequency);
        }
Exemplo n.º 4
0
        // Token: 0x060003A3 RID: 931 RVA: 0x0001572C File Offset: 0x0001392C
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }
            BackOffValue backOffValue = obj as BackOffValue;

            if (backOffValue != null)
            {
                return(this.BackOffDuration.CompareTo(backOffValue.BackOffDuration));
            }
            throw new ArgumentException("Object is not a valid BackOffValue");
        }
Exemplo n.º 5
0
        // Token: 0x060003A5 RID: 933 RVA: 0x00015790 File Offset: 0x00013990
        public static BackOffValue GetEffectiveBackOffValue(BackOffValue budgetBackOff, BackOffValue abBackOff)
        {
            BackOffValue backOffValue = new BackOffValue();

            backOffValue.BackOffDuration = Math.Ceiling(Math.Max(budgetBackOff.BackOffDuration, abBackOff.BackOffDuration));
            backOffValue.BackOffType     = ((budgetBackOff.BackOffType >= abBackOff.BackOffType) ? budgetBackOff.BackOffType : abBackOff.BackOffType);
            backOffValue.BackOffReason   = ((budgetBackOff.BackOffType >= abBackOff.BackOffType) ? budgetBackOff.BackOffReason : abBackOff.BackOffReason);
            if (backOffValue.BackOffDuration > GlobalSettings.MaxBackOffDuration.TotalSeconds)
            {
                AirSyncDiagnostics.TraceDebug <double, TimeSpan>(ExTraceGlobals.RequestsTracer, null, "Calculated backoff time exceed max allowed backoff time, using predefined MaxBackOffDuration. CalculatedbackOff:{0} sec, MaxValue as per Settings:{1}", backOffValue.BackOffDuration, GlobalSettings.MaxBackOffDuration);
                backOffValue.BackOffDuration = GlobalSettings.MaxBackOffDuration.TotalSeconds;
            }
            if (Command.CurrentCommand != null)
            {
                Command.CurrentCommand.ProtocolLogger.SetValue(ProtocolLoggerData.SuggestedBackOffValue, string.Format("BBkOff:{0}, ABBkOff:{1}, EffBkOff:{2}", budgetBackOff.ToString(), abBackOff.ToString(), backOffValue.ToString()));
            }
            return(backOffValue);
        }
Exemplo n.º 6
0
        // Token: 0x06000563 RID: 1379 RVA: 0x0001FAA8 File Offset: 0x0001DCA8
        private BackOffValue GetAutoBlockBackOffTimeForCommandsFrequency()
        {
            EnhancedTimeSpan behaviorTypeIncidenceDuration = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.CommandFrequency).BehaviorTypeIncidenceDuration;

            if (behaviorTypeIncidenceDuration.TotalSeconds == 0.0)
            {
                return(BackOffValue.NoBackOffValue);
            }
            BackOffValue backOffValue;

            if ((this.recentCommandTimes != null && this.recentCommandTimes.Count >= 0) || (this.syncTimes != null && this.syncTimes.Count >= 0))
            {
                int        behaviorTypeIncidenceLimit = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.CommandFrequency).BehaviorTypeIncidenceLimit;
                ExDateTime exDateTime  = ExDateTime.MaxValue;
                ExDateTime exDateTime2 = ExDateTime.MaxValue;
                int        num         = 0;
                if (this.syncTimes != null && this.syncKeys.Count > 0)
                {
                    num       += this.syncTimes.Count;
                    exDateTime = this.syncTimes[0];
                }
                if (this.recentCommandTimes != null && this.recentCommandTimes.Count > 0)
                {
                    num        += this.recentCommandTimes.Count;
                    exDateTime2 = this.recentCommandTimes[0];
                }
                TimeSpan currentDuration = (exDateTime < exDateTime2) ? ExDateTime.UtcNow.Subtract(exDateTime) : ExDateTime.UtcNow.Subtract(exDateTime2);
                backOffValue = this.CalculateAutoBlockBackOffTime(behaviorTypeIncidenceLimit, behaviorTypeIncidenceDuration, num, currentDuration, AutoblockThresholdType.CommandFrequency.ToString());
                AirSyncDiagnostics.TraceInfo <int, double>(ExTraceGlobals.RequestsTracer, this, "GetAutoblockBackOffTime: SyncCommandLimit:{0}, backOffDuration:{1}", behaviorTypeIncidenceLimit, backOffValue.BackOffDuration);
            }
            else
            {
                AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "GetAutoblockBackOffTime: Skip calculating backOff time.");
                backOffValue = new BackOffValue
                {
                    BackOffType     = BackOffType.Low,
                    BackOffReason   = AutoblockThresholdType.CommandFrequency.ToString(),
                    BackOffDuration = -1.0 * behaviorTypeIncidenceDuration.TotalSeconds
                };
            }
            return(backOffValue);
        }