Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LoadSheddingValidator"/> class.
 /// </summary>
 /// <param name="loadSheddingOptions">
 /// The load shedding options.
 /// </param>
 /// <param name="hostEnvironmentStatistics">
 /// The host environment statistics.
 /// </param>
 public LoadSheddingValidator(
     IOptions <LoadSheddingOptions> loadSheddingOptions,
     IHostEnvironmentStatistics hostEnvironmentStatistics
     )
 {
     _loadSheddingOptions       = loadSheddingOptions.Value;
     _hostEnvironmentStatistics = hostEnvironmentStatistics;
 }
Exemplo n.º 2
0
 public PlacementTestGrainBase(
     OverloadDetector overloadDetector,
     TestHooksHostEnvironmentStatistics hostEnvironmentStatistics,
     IOptions <LoadSheddingOptions> loadSheddingOptions)
 {
     this.overloadDetector          = overloadDetector;
     this.hostEnvironmentStatistics = hostEnvironmentStatistics;
     this.loadSheddingOptions       = loadSheddingOptions.Value;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="loadSheddingLimit"></param>
 /// <param name="getNodeConfig">The method used to get the current node configuration.</param>
 private LoadShedQueueFlowController(int loadSheddingLimit, LoadSheddingOptions options)
 {
     this.options = options;
     if (loadSheddingLimit < 0 || loadSheddingLimit > 100)
     {
         throw new ArgumentOutOfRangeException(nameof(loadSheddingLimit), "Value must be between 0-100");
     }
     this.loadSheddingLimit = loadSheddingLimit != 0 ? loadSheddingLimit : int.MaxValue;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a flow controller triggered when the CPU reaches a percentage of the cluster load shedding limit.
 /// This is intended to reduce queue read rate prior to causing the silo to shed load.
 /// Note:  Triggered only when load shedding is enabled.
 /// </summary>
 /// <param name="options">The silo satistics options.</param>
 /// <param name="percentOfSiloSheddingLimit">Percentage of load shed limit which triggers a reduction of queue read rate.</param>
 /// <returns></returns>
 public static IQueueFlowController CreateAsPercentOfLoadSheddingLimit(LoadSheddingOptions options, int percentOfSiloSheddingLimit = LoadSheddingOptions.DEFAULT_LOAD_SHEDDING_LIMIT)
 {
     if (percentOfSiloSheddingLimit < 0.0 || percentOfSiloSheddingLimit > 100.0)
     {
         throw new ArgumentOutOfRangeException(nameof(percentOfSiloSheddingLimit), "Percent value must be between 0-100");
     }
     // Start shedding before silo reaches shedding limit.
     return(new LoadShedQueueFlowController((int)(options.LoadSheddingLimit * (percentOfSiloSheddingLimit / 100.0)), options));
 }
Exemplo n.º 5
0
 public TestHooksSystemTarget(
     ISiloHost host,
     ILocalSiloDetails siloDetails,
     ILoggerFactory loggerFactory,
     TestHooksHostEnvironmentStatistics hostEnvironmentStatistics,
     IOptions <LoadSheddingOptions> loadSheddingOptions)
     : base(Constants.TestHooksSystemTargetId, siloDetails.SiloAddress, loggerFactory)
 {
     this.host = host;
     this.hostEnvironmentStatistics = hostEnvironmentStatistics;
     this.loadSheddingOptions       = loadSheddingOptions.Value;
     this.consistentRingProvider    = this.host.Services.GetRequiredService <IConsistentRingProvider>();
 }
Exemplo n.º 6
0
 public TestHooksSystemTarget(
     IServiceProvider serviceProvider,
     ILocalSiloDetails siloDetails,
     ILoggerFactory loggerFactory,
     ISiloStatusOracle siloStatusOracle,
     TestHooksHostEnvironmentStatistics hostEnvironmentStatistics,
     IOptions <LoadSheddingOptions> loadSheddingOptions)
     : base(Constants.TestHooksSystemTargetType, siloDetails.SiloAddress, loggerFactory)
 {
     this.serviceProvider           = serviceProvider;
     this.siloStatusOracle          = siloStatusOracle;
     this.hostEnvironmentStatistics = hostEnvironmentStatistics;
     this.loadSheddingOptions       = loadSheddingOptions.Value;
     this.consistentRingProvider    = this.serviceProvider.GetRequiredService <IConsistentRingProvider>();
 }
Exemplo n.º 7
0
        public EventHubAdapterReceiver(EventHubPartitionSettings settings,
                                       Func <string, IStreamQueueCheckpointer <string>, ILoggerFactory, ITelemetryProducer, IEventHubQueueCache> cacheFactory,
                                       Func <string, Task <IStreamQueueCheckpointer <string> > > checkpointerFactory,
                                       ILoggerFactory loggerFactory,
                                       IQueueAdapterReceiverMonitor monitor,
                                       LoadSheddingOptions loadSheddingOptions,
                                       ITelemetryProducer telemetryProducer,
                                       Func <EventHubPartitionSettings, string, ILogger, ITelemetryProducer, IEventHubReceiver> eventHubReceiverFactory = null)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            if (cacheFactory == null)
            {
                throw new ArgumentNullException(nameof(cacheFactory));
            }
            if (checkpointerFactory == null)
            {
                throw new ArgumentNullException(nameof(checkpointerFactory));
            }
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }
            if (monitor == null)
            {
                throw new ArgumentNullException(nameof(monitor));
            }
            if (loadSheddingOptions == null)
            {
                throw new ArgumentNullException(nameof(loadSheddingOptions));
            }
            if (telemetryProducer == null)
            {
                throw new ArgumentNullException(nameof(telemetryProducer));
            }
            this.settings            = settings;
            this.cacheFactory        = cacheFactory;
            this.checkpointerFactory = checkpointerFactory;
            this.loggerFactory       = loggerFactory;
            this.logger              = this.loggerFactory.CreateLogger($"{this.GetType().FullName}.{settings.Hub.Path}.{settings.Partition}");
            this.monitor             = monitor;
            this.telemetryProducer   = telemetryProducer;
            this.loadSheddingOptions = loadSheddingOptions;

            this.eventHubReceiverFactory = eventHubReceiverFactory == null ? EventHubAdapterReceiver.CreateReceiver : eventHubReceiverFactory;
        }
Exemplo n.º 8
0
 internal SiloPerformanceMetrics(
     IHostEnvironmentStatistics hostEnvironmentStatistics,
     IAppEnvironmentStatistics appEnvironmentStatistics,
     ILoggerFactory loggerFactory,
     IOptions <LoadSheddingOptions> loadSheddingOptions)
 {
     this.loggerFactory             = loggerFactory;
     this.hostEnvironmentStatistics = hostEnvironmentStatistics;
     this.appEnvironmentStatistics  = appEnvironmentStatistics;
     reportFrequency          = TimeSpan.Zero;
     overloadLatched          = false;
     overloadValue            = false;
     this.logger              = loggerFactory.CreateLogger <SiloPerformanceMetrics>();
     this.loadSheddingOptions = loadSheddingOptions.Value;
     StringValueStatistic.FindOrCreate(StatisticNames.RUNTIME_IS_OVERLOADED, () => IsOverloaded.ToString());
 }
Exemplo n.º 9
0
 /// <summary>
 /// Creates a flow controller triggered when the CPU reaches the specified limit.
 /// Note:  Triggered only when load shedding is enabled.
 /// </summary>
 /// <param name="loadSheddingLimit">Percentage of CPU which triggers queue read rate reduction</param>
 /// <param name="options">The silo satistics options.</param>
 /// <returns></returns>
 public static IQueueFlowController CreateAsPercentageOfCPU(int loadSheddingLimit, LoadSheddingOptions options)
 {
     if (loadSheddingLimit < 0 || loadSheddingLimit > 100)
     {
         throw new ArgumentOutOfRangeException(nameof(loadSheddingLimit), "Value must be between 0-100");
     }
     return(new LoadShedQueueFlowController(loadSheddingLimit, options));
 }