public ActivityExecutionRateLimitingService(IUtilizationMonitoringService utilizationMonitoringService, IUtilizationDataProvider utilizationDataProvider, IPusherNotifier pusherNotifier, ITimer timer) { var renewInterval = Math.Max(GetSetting("UtilizationSateRenewInterval", utilizationMonitoringService.AggregationUnitDuration / 2), MinimalRenewInterval); _overheatingThreshold = GetSetting("ActivityExecutionOverheatingThreshold", DefaultOverheatingThreshold); _userBanTime = TimeSpan.FromSeconds(GetSetting("OverheatedUserBanTime", DefaultUserBanTime)); _reportValidInterval = TimeSpan.FromSeconds(Math.Ceiling(utilizationMonitoringService.AggregationUnitDuration * 1.5f)); _utilizationDataProvider = utilizationDataProvider; _pusherNotifier = pusherNotifier; _utilizationRenewTimer = timer; timer.Configure(OnUtilizationStateRenewTick, this, renewInterval * 1000, renewInterval * 1000); }
public UtilizationMonitoringService(IUtilizationDataProvider utilizationDataProvider, ITimer timer) { var aggregationUnitStr = CloudConfigurationManager.GetSetting("UtilizationReportAggregationUnit"); if (string.IsNullOrWhiteSpace(aggregationUnitStr) || !int.TryParse(aggregationUnitStr, out _reportAggregationUnit)) { _reportAggregationUnit = DefaultReportAggregationUnit; } _reportAggregationUnit = Math.Max(MinimalReportAggregationUnitDuration, _reportAggregationUnit); _utilizationDataProvider = utilizationDataProvider; _reportTimer = timer; timer.Configure(OnReportTimerTick, this, _reportAggregationUnit * 1000, _reportAggregationUnit * 1000); }