/// <summary>
        /// Function used to configure cache pressure monitors for EventHubQueueCache.
        /// User can override this function to provide more customization on cache pressure monitors
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="providerOptions"></param>
        /// <param name="cacheLogger"></param>
        protected virtual void AddCachePressureMonitors(IEventHubQueueCache cache, EventHubStreamCachePressureOptions providerOptions,
                                                        ILogger cacheLogger)
        {
            if (providerOptions.AveragingCachePressureMonitorFlowControlThreshold.HasValue)
            {
                var avgMonitor = new AveragingCachePressureMonitor(
                    providerOptions.AveragingCachePressureMonitorFlowControlThreshold.Value, cacheLogger);
                cache.AddCachePressureMonitor(avgMonitor);
            }

            if (providerOptions.SlowConsumingMonitorPressureWindowSize.HasValue ||
                providerOptions.SlowConsumingMonitorFlowControlThreshold.HasValue)
            {
                var slowConsumeMonitor = new SlowConsumingPressureMonitor(cacheLogger);
                if (providerOptions.SlowConsumingMonitorFlowControlThreshold.HasValue)
                {
                    slowConsumeMonitor.FlowControlThreshold = providerOptions.SlowConsumingMonitorFlowControlThreshold.Value;
                }
                if (providerOptions.SlowConsumingMonitorPressureWindowSize.HasValue)
                {
                    slowConsumeMonitor.PressureWindowSize = providerOptions.SlowConsumingMonitorPressureWindowSize.Value;
                }

                cache.AddCachePressureMonitor(slowConsumeMonitor);
            }
        }
Beispiel #2
0
        protected override IEventHubQueueCacheFactory CreateCacheFactory(EventHubStreamCachePressureOptions options)
        {
            var eventHubPath     = this.ehOptions.Path;
            var sharedDimensions = new EventHubMonitorAggregationDimensions(eventHubPath);

            return(new CacheFactoryForTesting(this.Name, this.cacheOptions, this.evictionOptions, this.staticticOptions, base.dataAdapter, this.SerializationManager, this.createdCaches, sharedDimensions, this.serviceProvider.GetRequiredService <ILoggerFactory>()));
        }
Beispiel #3
0
        /// <summary>
        /// Create a IEventHubQueueCacheFactory. It will create a EventHubQueueCacheFactory by default.
        /// User can override this function to return their own implementation of IEventHubQueueCacheFactory,
        /// and other customization of IEventHubQueueCacheFactory if they may.
        /// </summary>
        /// <returns></returns>
        protected virtual IEventHubQueueCacheFactory CreateCacheFactory(EventHubStreamCachePressureOptions eventHubCacheOptions)
        {
            var eventHubPath     = this.ehOptions.Path;
            var sharedDimensions = new EventHubMonitorAggregationDimensions(eventHubPath);

            return(new EventHubQueueCacheFactory(eventHubCacheOptions, cacheEvictionOptions, statisticOptions, this.dataAdapter, sharedDimensions));
        }
 public StreamPerPartitionEventHubStreamAdapterFactory(string name, EventHubOptions ehOptions, EventHubReceiverOptions receiverOptions,
                                                       EventHubStreamCachePressureOptions cacheOptions, StreamCacheEvictionOptions evictionOptions, StreamStatisticOptions statisticOptions,
                                                       IServiceProvider serviceProvider, SerializationManager serializationManager, ITelemetryProducer telemetryProducer, ILoggerFactory loggerFactory)
     : base(name, ehOptions, receiverOptions, cacheOptions, evictionOptions, statisticOptions, serviceProvider, serializationManager, telemetryProducer, loggerFactory)
 {
     this.evictionOptions = evictionOptions;
 }
 public EventHubAdapterFactory(
     string name,
     EventHubOptions ehOptions,
     EventHubReceiverOptions receiverOptions,
     EventHubStreamCachePressureOptions cacheOptions,
     StreamCacheEvictionOptions cacheEvictionOptions,
     StreamStatisticOptions statisticOptions,
     IEventHubDataAdapter dataAdapter,
     IServiceProvider serviceProvider,
     SerializationManager serializationManager,
     ITelemetryProducer telemetryProducer,
     ILoggerFactory loggerFactory)
 {
     this.Name = name;
     this.cacheEvictionOptions = cacheEvictionOptions ?? throw new ArgumentNullException(nameof(cacheEvictionOptions));
     this.statisticOptions     = statisticOptions ?? throw new ArgumentNullException(nameof(statisticOptions));
     this.ehOptions            = ehOptions ?? throw new ArgumentNullException(nameof(ehOptions));
     this.cacheOptions         = cacheOptions ?? throw new ArgumentNullException(nameof(cacheOptions));
     this.dataAdapter          = dataAdapter ?? throw new ArgumentNullException(nameof(dataAdapter));
     this.receiverOptions      = receiverOptions ?? throw new ArgumentNullException(nameof(receiverOptions));
     this.serviceProvider      = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
     this.SerializationManager = serializationManager ?? throw new ArgumentNullException(nameof(serializationManager));
     this.telemetryProducer    = telemetryProducer ?? throw new ArgumentNullException(nameof(telemetryProducer));
     this.loggerFactory        = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
 }
Beispiel #6
0
 public CacheFactoryForTesting(string name, EventHubStreamCachePressureOptions cacheOptions, StreamCacheEvictionOptions evictionOptions, StreamStatisticOptions statisticOptions,
                               IEventHubDataAdapter dataAdapter, SerializationManager serializationManager, ConcurrentBag <QueueCacheForTesting> caches, EventHubMonitorAggregationDimensions sharedDimensions,
                               ILoggerFactory loggerFactory,
                               Func <EventHubCacheMonitorDimensions, ILoggerFactory, ITelemetryProducer, ICacheMonitor> cacheMonitorFactory             = null,
                               Func <EventHubBlockPoolMonitorDimensions, ILoggerFactory, ITelemetryProducer, IBlockPoolMonitor> blockPoolMonitorFactory = null)
     : base(cacheOptions, evictionOptions, statisticOptions, dataAdapter, serializationManager, sharedDimensions, cacheMonitorFactory, blockPoolMonitorFactory)
 {
     this.name   = name;
     this.caches = caches;
 }
        protected override IEventHubQueueCacheFactory CreateCacheFactory(EventHubStreamCachePressureOptions cacheOptions)
        {
            var loggerFactory    = this.serviceProvider.GetRequiredService <ILoggerFactory>();
            var eventHubPath     = this.ehOptions.Path;
            var sharedDimensions = new EventHubMonitorAggregationDimensions(eventHubPath);
            Func <EventHubCacheMonitorDimensions, ILoggerFactory, ITelemetryProducer, ICacheMonitor>         cacheMonitorFactory     = (dimensions, logger, telemetryProducer) => CacheMonitorForTesting.Instance;
            Func <EventHubBlockPoolMonitorDimensions, ILoggerFactory, ITelemetryProducer, IBlockPoolMonitor> blockPoolMonitorFactory = (dimensions, logger, telemetryProducer) => BlockPoolMonitorForTesting.Instance;

            return(new CacheFactoryForMonitorTesting(this.cachePressureInjectionMonitor, this.cacheOptions, this.evictionOptions, this.staticticOptions, this.serializationManager,
                                                     sharedDimensions, loggerFactory, cacheMonitorFactory, blockPoolMonitorFactory));
        }
 public EHStreamProviderForMonitorTestsAdapterFactory(string name, EventDataGeneratorStreamOptions options, EventHubOptions ehOptions, EventHubReceiverOptions receiverOptions,
                                                      EventHubStreamCachePressureOptions cacheOptions, StreamCacheEvictionOptions streamCacheEvictionOptions, StreamStatisticOptions statisticOptions,
                                                      IServiceProvider serviceProvider, SerializationManager serializationManager, ITelemetryProducer telemetryProducer, ILoggerFactory loggerFactory)
     : base(name, options, ehOptions, receiverOptions, cacheOptions, streamCacheEvictionOptions, statisticOptions, serviceProvider, serializationManager, telemetryProducer, loggerFactory)
 {
     this.serializationManager = serializationManager;
     this.cacheOptions         = cacheOptions;
     this.staticticOptions     = statisticOptions;
     this.ehOptions            = ehOptions;
     this.evictionOptions      = streamCacheEvictionOptions;
 }
Beispiel #9
0
        public EHStreamProviderWithCreatedCacheListAdapterFactory(string name, EventDataGeneratorStreamOptions options, EventHubOptions ehOptions, EventHubReceiverOptions receiverOptions,
                                                                  EventHubStreamCachePressureOptions cacheOptions, StreamCacheEvictionOptions evictionOptions, StreamStatisticOptions statisticOptions,
                                                                  IServiceProvider serviceProvider, SerializationManager serializationManager, ITelemetryProducer telemetryProducer, ILoggerFactory loggerFactory)
            : base(name, options, ehOptions, receiverOptions, cacheOptions, evictionOptions, statisticOptions, serviceProvider, serializationManager, telemetryProducer, loggerFactory)

        {
            this.createdCaches    = new ConcurrentBag <QueueCacheForTesting>();
            this.cacheOptions     = cacheOptions;
            this.staticticOptions = statisticOptions;
            this.ehOptions        = ehOptions;
            this.evictionOptions  = evictionOptions;
        }
Beispiel #10
0
 public CacheFactoryForMonitorTesting(
     CachePressureInjectionMonitor cachePressureInjectionMonitor,
     EventHubStreamCachePressureOptions cacheOptions,
     StreamCacheEvictionOptions streamCacheEviction,
     StreamStatisticOptions statisticOptions,
     IEventHubDataAdapter dataAdater,
     EventHubMonitorAggregationDimensions sharedDimensions,
     ILoggerFactory loggerFactory,
     Func <EventHubCacheMonitorDimensions, ILoggerFactory, ITelemetryProducer, ICacheMonitor> cacheMonitorFactory             = null,
     Func <EventHubBlockPoolMonitorDimensions, ILoggerFactory, ITelemetryProducer, IBlockPoolMonitor> blockPoolMonitorFactory = null)
     : base(cacheOptions, streamCacheEviction, statisticOptions, dataAdater, sharedDimensions, cacheMonitorFactory, blockPoolMonitorFactory)
 {
     this.cachePressureInjectionMonitor = cachePressureInjectionMonitor;
 }
Beispiel #11
0
 public TestEventHubStreamAdapterFactory(
     string name,
     EventHubOptions ehOptions,
     EventHubReceiverOptions receiverOptions,
     EventHubStreamCachePressureOptions cacheOptions,
     StreamCacheEvictionOptions evictionOptions,
     StreamStatisticOptions statisticOptions,
     IEventHubDataAdapter dataAdapter,
     IServiceProvider serviceProvider,
     ITelemetryProducer telemetryProducer,
     ILoggerFactory loggerFactory)
     : base(name, ehOptions, receiverOptions, cacheOptions, evictionOptions, statisticOptions, dataAdapter, serviceProvider, telemetryProducer, loggerFactory)
 {
     StreamFailureHandlerFactory = qid => TestAzureTableStorageStreamFailureHandler.Create(this.serviceProvider.GetRequiredService <Serializer <StreamSequenceToken> >());
 }
 public EventDataGeneratorAdapterFactory(
     string name,
     EventDataGeneratorStreamOptions options,
     EventHubOptions ehOptions,
     EventHubReceiverOptions receiverOptions,
     EventHubStreamCachePressureOptions cacheOptions,
     StreamCacheEvictionOptions evictionOptions,
     StreamStatisticOptions statisticOptions,
     IEventHubDataAdapter dataAdapter,
     IServiceProvider serviceProvider,
     ITelemetryProducer telemetryProducer,
     ILoggerFactory loggerFactory)
     : base(name, ehOptions, receiverOptions, cacheOptions, evictionOptions, statisticOptions, dataAdapter, serviceProvider, telemetryProducer, loggerFactory)
 {
     this.ehGeneratorOptions = options;
 }
 /// <summary>
 /// Constructor for EventHubQueueCacheFactory
 /// </summary>
 /// <param name="cacheOptions"></param>
 /// <param name="evictionOptions"></param>
 /// <param name="statisticOptions"></param>
 /// <param name="serializationManager"></param>
 /// <param name="sharedDimensions">shared dimensions between cache monitor and block pool monitor</param>
 /// <param name="cacheMonitorFactory"></param>
 /// <param name="blockPoolMonitorFactory"></param>
 public EventHubQueueCacheFactory(
     EventHubStreamCachePressureOptions cacheOptions,
     StreamCacheEvictionOptions evictionOptions,
     StreamStatisticOptions statisticOptions,
     SerializationManager serializationManager, EventHubMonitorAggregationDimensions sharedDimensions,
     Func <EventHubCacheMonitorDimensions, ILoggerFactory, ITelemetryProducer, ICacheMonitor> cacheMonitorFactory             = null,
     Func <EventHubBlockPoolMonitorDimensions, ILoggerFactory, ITelemetryProducer, IBlockPoolMonitor> blockPoolMonitorFactory = null)
 {
     this.cacheOptions            = cacheOptions;
     this.statisticOptions        = statisticOptions;
     this.serializationManager    = serializationManager;
     this.timePurge               = new TimePurgePredicate(evictionOptions.DataMinTimeInCache, evictionOptions.DataMaxAgeInCache);
     this.sharedDimensions        = sharedDimensions;
     this.CacheMonitorFactory     = cacheMonitorFactory ?? ((dimensions, logger, telemetryProducer) => new DefaultEventHubCacheMonitor(dimensions, telemetryProducer));
     this.BlockPoolMonitorFactory = blockPoolMonitorFactory ?? ((dimensions, logger, telemetryProducer) => new DefaultEventHubBlockPoolMonitor(dimensions, telemetryProducer));
 }
 protected override void AddCachePressureMonitors(IEventHubQueueCache cache, EventHubStreamCachePressureOptions providerOptions,
                                                  ILogger cacheLogger)
 {
     cache.AddCachePressureMonitor(this.cachePressureInjectionMonitor);
 }
 protected override IEventHubQueueCacheFactory CreateCacheFactory(EventHubStreamCachePressureOptions options)
 {
     return(new CustomCacheFactory(this.Name, evictionOptions, SerializationManager));
 }