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));
 }
 public CacheFactoryForMonitorTesting(CachePressureInjectionMonitor cachePressureInjectionMonitor, EventHubStreamCachePressureOptions cacheOptions, StreamCacheEvictionOptions streamCacheEviction,
                                      StreamStatisticOptions statisticOptions,
                                      SerializationManager serializationManager, EventHubMonitorAggregationDimensions sharedDimensions,
                                      ILoggerFactory loggerFactory,
                                      Func <EventHubCacheMonitorDimensions, ILoggerFactory, ITelemetryProducer, ICacheMonitor> cacheMonitorFactory             = null,
                                      Func <EventHubBlockPoolMonitorDimensions, ILoggerFactory, ITelemetryProducer, IBlockPoolMonitor> blockPoolMonitorFactory = null)
     : base(cacheOptions, streamCacheEviction, statisticOptions, serializationManager, sharedDimensions, cacheMonitorFactory, blockPoolMonitorFactory)
 {
     this.cachePressureInjectionMonitor = cachePressureInjectionMonitor;
 }
        /// <summary>
        /// Default function to be called to create an EventhubQueueCache in IEventHubQueueCacheFactory.CreateCache method. User can
        /// override this method to add more customization.
        /// </summary>
        protected virtual IEventHubQueueCache CreateCache(string partition, StreamStatisticOptions statisticOptions, IStreamQueueCheckpointer <string> checkpointer,
                                                          ILoggerFactory loggerFactory, IObjectPool <FixedSizeBuffer> bufferPool, string blockPoolId, TimePurgePredicate timePurge,
                                                          SerializationManager serializationManager, EventHubMonitorAggregationDimensions sharedDimensions, ITelemetryProducer telemetryProducer)
        {
            var cacheMonitorDimensions = new EventHubCacheMonitorDimensions(sharedDimensions, partition, blockPoolId);
            var cacheMonitor           = this.CacheMonitorFactory(cacheMonitorDimensions, loggerFactory, telemetryProducer);

            return(new EventHubQueueCache(checkpointer, bufferPool, timePurge, loggerFactory.CreateLogger($"{typeof(EventHubQueueCache).FullName}.{sharedDimensions.EventHubPath}.{partition}"), serializationManager,
                                          cacheMonitor, statisticOptions.StatisticMonitorWriteInterval));
        }
 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 #5
0
 public GeneratorAdapterFactory(string providerName, HashRingStreamQueueMapperOptions queueMapperOptions, StreamStatisticOptions statisticOptions, IServiceProvider serviceProvider, SerializationManager serializationManager, ITelemetryProducer telemetryProducer, ILoggerFactory loggerFactory)
 {
     this.Name = providerName;
     this.queueMapperOptions   = queueMapperOptions ?? throw new ArgumentNullException(nameof(queueMapperOptions));
     this.statisticOptions     = statisticOptions ?? throw new ArgumentNullException(nameof(statisticOptions));
     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));
     this.logger = loggerFactory.CreateLogger <GeneratorAdapterFactory>();
 }
Beispiel #6
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 #7
0
 public MemoryAdapterFactory(string providerName, StreamCacheEvictionOptions cacheOptions, StreamStatisticOptions statisticOptions, HashRingStreamQueueMapperOptions queueMapperOptions,
                             IServiceProvider serviceProvider, IGrainFactory grainFactory, ITelemetryProducer telemetryProducer, ILoggerFactory loggerFactory)
 {
     this.Name = providerName;
     this.queueMapperOptions = queueMapperOptions ?? throw new ArgumentNullException(nameof(queueMapperOptions));
     this.cacheOptions       = cacheOptions ?? throw new ArgumentNullException(nameof(cacheOptions));
     this.statisticOptions   = statisticOptions ?? throw new ArgumentException(nameof(statisticOptions));
     this.grainFactory       = grainFactory ?? throw new ArgumentNullException(nameof(grainFactory));
     this.telemetryProducer  = telemetryProducer ?? throw new ArgumentNullException(nameof(telemetryProducer));
     this.loggerFactory      = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
     this.logger             = loggerFactory.CreateLogger <ILogger <MemoryAdapterFactory <TSerializer> > >();
     this.serializer         = MemoryMessageBodySerializerFactory <TSerializer> .GetOrCreateSerializer(serviceProvider);
 }
 /// <summary>
 /// Function used to configure BufferPool for EventHubQueueCache. User can override this function to provide more customization on BufferPool creation
 /// </summary>
 protected virtual IObjectPool <FixedSizeBuffer> CreateBufferPool(StreamStatisticOptions statisticOptions, ILoggerFactory loggerFactory, EventHubMonitorAggregationDimensions sharedDimensions, ITelemetryProducer telemetryProducer, out string blockPoolId)
 {
     if (this.bufferPool == null)
     {
         var bufferSize = 1 << 20;
         this.bufferPoolId = $"BlockPool-{new Guid().ToString()}-BlockSize-{bufferSize}";
         var monitorDimensions = new EventHubBlockPoolMonitorDimensions(sharedDimensions, this.bufferPoolId);
         var objectPoolMonitor = new ObjectPoolMonitorBridge(this.BlockPoolMonitorFactory(monitorDimensions, loggerFactory, telemetryProducer), bufferSize);
         this.bufferPool = new ObjectPool <FixedSizeBuffer>(() => new FixedSizeBuffer(bufferSize),
                                                            objectPoolMonitor, statisticOptions.StatisticMonitorWriteInterval);
     }
     blockPoolId = this.bufferPoolId;
     return(this.bufferPool);
 }
        public KafkaEventBusAdapterFactory(string name, KafkaOptions kafkaOptions, KafkaReceiverOptions receiverOptions, KafkaStreamCachePressureOptions cacheOptions, StreamStatisticOptions statisticOptions,
                                           IServiceProvider serviceProvider, SerializationManager serializationManager, ITelemetryProducer telemetryProducer, ILoggerFactory loggerFactory)
        {
            this.Name                 = name;
            this.statisticOptions     = statisticOptions ?? throw new ArgumentNullException(nameof(statisticOptions));
            this.kafkaOptions         = kafkaOptions ?? throw new ArgumentNullException(nameof(kafkaOptions));
            this.cacheOptions         = cacheOptions ?? throw new ArgumentNullException(nameof(cacheOptions));
            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));

            this.Direction = kafkaOptions.Direction;
        }
Beispiel #10
0
            protected override IEventHubQueueCache CreateCache(string partition, StreamStatisticOptions options, IStreamQueueCheckpointer <string> checkpointer,
                                                               ILoggerFactory loggerFactory, IObjectPool <FixedSizeBuffer> bufferPool, string blockPoolId, TimePurgePredicate timePurge,
                                                               SerializationManager serializationManager, EventHubMonitorAggregationDimensions sharedDimensions, ITelemetryProducer telemetryProducer)
            {
                var cacheMonitorDimensions = new EventHubCacheMonitorDimensions(sharedDimensions, partition, blockPoolId);
                var cacheMonitor           = this.CacheMonitorFactory(cacheMonitorDimensions, loggerFactory, telemetryProducer);
                var cacheLogger            = loggerFactory.CreateLogger($"{typeof(EventHubQueueCache).FullName}.{this.name}.{partition}");
                //set defaultMaxAddCount to 10 so TryCalculateCachePressureContribution will start to calculate real contribution shortly
                var cache = new QueueCacheForTesting(DefaultMaxAddCount, checkpointer, new EventHubDataAdapter(serializationManager, bufferPool),
                                                     EventHubDataComparer.Instance, cacheLogger, new EventHubCacheEvictionStrategy(cacheLogger, timePurge, cacheMonitor, options.StatisticMonitorWriteInterval),
                                                     cacheMonitor, options.StatisticMonitorWriteInterval);

                this.caches.Add(cache);
                return(cache);
            }
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));
 }
        /// <summary>
        /// Default function to be called to create an EventhubQueueCache in IEventHubQueueCacheFactory.CreateCache method. User can
        /// override this method to add more customization.
        /// </summary>
        protected virtual IEventHubQueueCache CreateCache(
            string partition,
            IEventHubDataAdapter dataAdatper,
            StreamStatisticOptions statisticOptions,
            StreamCacheEvictionOptions streamCacheEvictionOptions,
            IStreamQueueCheckpointer <string> checkpointer,
            ILoggerFactory loggerFactory,
            IObjectPool <FixedSizeBuffer> bufferPool,
            string blockPoolId,
            TimePurgePredicate timePurge,
            EventHubMonitorAggregationDimensions sharedDimensions,
            ITelemetryProducer telemetryProducer)
        {
            var cacheMonitorDimensions = new EventHubCacheMonitorDimensions(sharedDimensions, partition, blockPoolId);
            var cacheMonitor           = this.CacheMonitorFactory(cacheMonitorDimensions, loggerFactory, telemetryProducer);
            var logger           = loggerFactory.CreateLogger($"{typeof(EventHubQueueCache).FullName}.{sharedDimensions.EventHubPath}.{partition}");
            var evictionStrategy = new ChronologicalEvictionStrategy(logger, timePurge, cacheMonitor, statisticOptions.StatisticMonitorWriteInterval);

            return(new EventHubQueueCache(partition, EventHubAdapterReceiver.MaxMessagesPerRead, bufferPool, dataAdatper, evictionStrategy, checkpointer, logger,
                                          cacheMonitor, statisticOptions.StatisticMonitorWriteInterval, streamCacheEvictionOptions.MetadataMinTimeInCache));
        }
Beispiel #15
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;
 }
 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;
 }