Example #1
0
        public void SettingWithAvgConsumingMonitorSetUp_Write_Into_ProviderConfiguration_PopulateBack()
        {
            var expectedSetting = new EventHubStreamProviderSettings(StreamProviderName);

            expectedSetting.AveragingCachePressureMonitorFlowControlThreshold = 1 / 10;
            AssertSettingEqual_After_WriteInto_ProviderConfiguration_AndPopulateBack(expectedSetting);
        }
            protected override IEventHubQueueCacheFactory CreateCacheFactory(EventHubStreamProviderSettings providerSettings)
            {
                var eventHubPath     = this.hubSettings.Path;
                var sharedDimensions = new EventHubMonitorAggregationDimensions(eventHubPath);

                return(new CacheFactoryForTesting(providerSettings, this.SerializationManager, this.createdCaches, sharedDimensions, this.serviceProvider.GetRequiredService <ILoggerFactory>()));
            }
Example #3
0
        public void SettingWithSlowConsumingMonitorSetUp_Write_Into_ProviderConfiguration_PopulateBack()
        {
            var expectedSetting = new EventHubStreamProviderSettings(StreamProviderName);

            expectedSetting.SlowConsumingMonitorPressureWindowSize   = TimeSpan.FromMinutes(2);
            expectedSetting.SlowConsumingMonitorFlowControlThreshold = 1 / 3;
            AssertSettingEqual_After_WriteInto_ProviderConfiguration_AndPopulateBack(expectedSetting);
        }
 public CacheFactoryForTesting(EventHubStreamProviderSettings providerSettings,
                               SerializationManager serializationManager, List <IEventHubQueueCache> caches, EventHubMonitorAggregationDimensions sharedDimensions,
                               Func <EventHubCacheMonitorDimensions, Logger, ICacheMonitor> cacheMonitorFactory             = null,
                               Func <EventHubBlockPoolMonitorDimensions, Logger, IBlockPoolMonitor> blockPoolMonitorFactory = null)
     : base(providerSettings, serializationManager, sharedDimensions, cacheMonitorFactory, blockPoolMonitorFactory)
 {
     this.caches = caches;
 }
 public CacheFactoryForTesting(EventHubStreamProviderSettings providerSettings,
                               SerializationManager serializationManager, ConcurrentBag <QueueCacheForTesting> caches, EventHubMonitorAggregationDimensions sharedDimensions,
                               ILoggerFactory loggerFactory,
                               Func <EventHubCacheMonitorDimensions, ILoggerFactory, ITelemetryProducer, ICacheMonitor> cacheMonitorFactory             = null,
                               Func <EventHubBlockPoolMonitorDimensions, ILoggerFactory, ITelemetryProducer, IBlockPoolMonitor> blockPoolMonitorFactory = null)
     : base(providerSettings, serializationManager, sharedDimensions, loggerFactory, cacheMonitorFactory, blockPoolMonitorFactory)
 {
     this.caches = caches;
 }
            protected override IEventHubQueueCacheFactory CreateCacheFactory(EventHubStreamProviderSettings providerSettings)
            {
                var globalConfig     = this.serviceProvider.GetRequiredService <GlobalConfiguration>();
                var nodeConfig       = this.serviceProvider.GetRequiredService <NodeConfiguration>();
                var eventHubPath     = hubSettings.Path;
                var sharedDimensions = new EventHubMonitorAggregationDimensions(globalConfig, nodeConfig, eventHubPath);

                return(new CacheFactoryForTesting(providerSettings, SerializationManager, this.createdCaches, sharedDimensions));
            }
            private static Dictionary <string, string> BuildProviderSettings(EventHubStreamProviderSettings providerSettings)
            {
                var settings = new Dictionary <string, string>();

                // get initial settings from configs
                providerSettings.WriteProperties(settings);
                EventHubConfig.Value.WriteProperties(settings);
                CheckpointerSettings.WriteProperties(settings);
                return(settings);
            }
            protected override IEventHubQueueCacheFactory CreateCacheFactory(EventHubStreamProviderSettings providerSettings)
            {
                var loggerFactory    = this.serviceProvider.GetRequiredService <ILoggerFactory>();
                var eventHubPath     = this.hubSettings.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, providerSettings, this.SerializationManager,
                                                         sharedDimensions, loggerFactory, cacheMonitorFactory, blockPoolMonitorFactory));
            }
Example #9
0
 private void AssertEqual(EventHubStreamProviderSettings expectedSettings, EventHubStreamProviderSettings actualSettings)
 {
     Assert.Equal(expectedSettings.StreamProviderName, actualSettings.StreamProviderName);
     Assert.Equal(expectedSettings.SlowConsumingMonitorFlowControlThreshold, actualSettings.SlowConsumingMonitorFlowControlThreshold);
     Assert.Equal(expectedSettings.SlowConsumingMonitorPressureWindowSize, actualSettings.SlowConsumingMonitorPressureWindowSize);
     Assert.Equal(expectedSettings.AveragingCachePressureMonitorFlowControlThreshold, actualSettings.AveragingCachePressureMonitorFlowControlThreshold);
     Assert.Equal(expectedSettings.EventHubSettingsType, actualSettings.EventHubSettingsType);
     Assert.Equal(expectedSettings.CheckpointerSettingsType, actualSettings.CheckpointerSettingsType);
     Assert.Equal(expectedSettings.CacheSizeMb, actualSettings.CacheSizeMb);
     Assert.Equal(expectedSettings.DataMinTimeInCache, actualSettings.DataMinTimeInCache);
     Assert.Equal(expectedSettings.DataMaxAgeInCache, actualSettings.DataMaxAgeInCache);
 }
Example #10
0
        private void AssertSettingEqual_After_WriteInto_ProviderConfiguration_AndPopulateBack(EventHubStreamProviderSettings expectedSetting)
        {
            var properties = new Dictionary <string, string>();

            expectedSetting.WriteProperties(properties);
            var config = new ProviderConfiguration(properties, typeof(EventHubStreamProvider).FullName, StreamProviderName);

            var actualSettings = new EventHubStreamProviderSettings(StreamProviderName);

            actualSettings.PopulateFromProviderConfig(config);
            AssertEqual(expectedSetting, actualSettings);
        }
            protected override IEventHubQueueCacheFactory CreateCacheFactory(EventHubStreamProviderSettings providerSettings)
            {
                var globalConfig     = this.serviceProvider.GetRequiredService <GlobalConfiguration>();
                var nodeConfig       = this.serviceProvider.GetRequiredService <NodeConfiguration>();
                var eventHubPath     = hubSettings.Path;
                var sharedDimensions = new EventHubMonitorAggregationDimensions(globalConfig, nodeConfig, eventHubPath);
                Func <EventHubCacheMonitorDimensions, Logger, ICacheMonitor>         cacheMonitorFactory     = (dimensions, logger) => CacheMonitorForTesting.Instance;
                Func <EventHubBlockPoolMonitorDimensions, Logger, IBlockPoolMonitor> blockPoolMonitorFactory = (dimensions, logger) => BlockPoolMonitorForTesting.Instance;

                return(new CacheFactoryForMonitorTesting(this.cachePressureInjectionMonitor, providerSettings, SerializationManager,
                                                         sharedDimensions, cacheMonitorFactory, blockPoolMonitorFactory));
            }
                protected override IEventHubQueueCache CreateCache(string partition, EventHubStreamProviderSettings providerSettings, IStreamQueueCheckpointer <string> checkpointer,
                                                                   Logger cacheLogger, IObjectPool <FixedSizeBuffer> bufferPool, string blockPoolId, TimePurgePredicate timePurge,
                                                                   SerializationManager serializationManager, EventHubMonitorAggregationDimensions sharedDimensions)
                {
                    var cacheMonitorDimensions = new EventHubCacheMonitorDimensions(sharedDimensions, partition, blockPoolId);
                    var cacheMonitor           = this.CacheMonitorFactory(cacheMonitorDimensions, cacheLogger);
                    //set defaultMaxAddCount to 10 so TryCalculateCachePressureContribution will start to calculate real contribution shortly
                    var cache = new EventHubQueueCache(defaultMaxAddCount, checkpointer, new EventHubDataAdapter(serializationManager, bufferPool),
                                                       EventHubDataComparer.Instance, cacheLogger, new EventHubCacheEvictionStrategy(cacheLogger, cacheMonitor, providerSettings.StatisticMonitorWriteInterval, timePurge),
                                                       cacheMonitor, providerSettings.StatisticMonitorWriteInterval);

                    this.caches.Add(cache);
                    return(cache);
                }
Example #13
0
        public override ClientConfiguration Build()
        {
            var rvalue = _builder.Build();

            var settings = new Dictionary <string, string>();

            EventHubStreamProviderSettings providerSettings = new EventHubStreamProviderSettings(_providerName);

            providerSettings.WriteProperties(settings);

            EventHubCheckpointerSettings checkpoint = new EventHubCheckpointerSettings(_checkpointConnectionString, _checkpointTableName, _checkpointNamespace, _checkpointInterval);

            checkpoint.WriteProperties(settings);

            EventHubSettings eventHub = new EventHubSettings(_hubConnectionString, _consumerGroup, _path);

            eventHub.WriteProperties(settings);

            rvalue.RegisterStreamProvider <EventHubStreamProvider>(_providerName, settings);

            return(rvalue);
        }
Example #14
0
 public CacheFactoryForTesting(EventHubStreamProviderSettings providerSettings,
                               SerializationManager serializationManager, List <IEventHubQueueCache> caches)
     : base(providerSettings, serializationManager)
 {
     _caches = caches;
 }
Example #15
0
 protected override IEventHubQueueCacheFactory CreateCacheFactory(EventHubStreamProviderSettings providerSettings)
 {
     return(new CacheFactoryForTesting(providerSettings, SerializationManager, createdCaches));
 }
Example #16
0
        public void DefaultSetting_Write_Into_ProviderConfiguration_PopulateBack()
        {
            var expectedSetting = new EventHubStreamProviderSettings(StreamProviderName);

            AssertSettingEqual_After_WriteInto_ProviderConfiguration_AndPopulateBack(expectedSetting);
        }
 protected override void AddCachePressureMonitors(IEventHubQueueCache cache, EventHubStreamProviderSettings providerSettings,
                                                  Logger cacheLogger)
 {
     cache.AddCachePressureMonitor(this.cachePressureInjectionMonitor);
 }
 public CacheFactoryForMonitorTesting(CachePressureInjectionMonitor cachePressureInjectionMonitor, EventHubStreamProviderSettings providerSettings,
                                      SerializationManager serializationManager, EventHubMonitorAggregationDimensions sharedDimensions,
                                      Func <EventHubCacheMonitorDimensions, Logger, ICacheMonitor> cacheMonitorFactory             = null,
                                      Func <EventHubBlockPoolMonitorDimensions, Logger, IBlockPoolMonitor> blockPoolMonitorFactory = null)
     : base(providerSettings, serializationManager, sharedDimensions, cacheMonitorFactory, blockPoolMonitorFactory)
 {
     this.cachePressureInjectionMonitor = cachePressureInjectionMonitor;
 }
 public CacheFactory(EventHubStreamProviderSettings adapterSettings, SerializationManager serializationManager)
 {
     this.adapterSettings      = adapterSettings;
     this.serializationManager = serializationManager;
     timePurgePredicate        = new TimePurgePredicate(adapterSettings.DataMinTimeInCache, adapterSettings.DataMaxAgeInCache);
 }