public CustomCacheFactory(string name, StreamCacheEvictionOptions options, SerializationManager serializationManager)
 {
     this.name    = name;
     this.options = options;
     this.serializationManager = serializationManager;
     timePurgePredicate        = new TimePurgePredicate(options.DataMinTimeInCache, options.DataMaxAgeInCache);
 }
 public TestEventHubStreamAdapterFactory(string name, EventHubOptions ehOptions, EventHubReceiverOptions receiverOptions, EventHubStreamCachePressureOptions cacheOptions,
                                         StreamCacheEvictionOptions evictionOptions, StreamStatisticOptions statisticOptions, IEventHubDataAdapter dataAdapter,
                                         IServiceProvider serviceProvider, SerializationManager serializationManager, ITelemetryProducer telemetryProducer, ILoggerFactory loggerFactory)
     : base(name, ehOptions, receiverOptions, cacheOptions, evictionOptions, statisticOptions, dataAdapter, serviceProvider, serializationManager, telemetryProducer, loggerFactory)
 {
     StreamFailureHandlerFactory = qid => TestAzureTableStorageStreamFailureHandler.Create(this.serviceProvider.GetRequiredService <SerializationManager>());
 }
 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 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 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 #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);
 }
Beispiel #8
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;
 }
 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));
        }
            protected override IEventHubQueueCache CreateCache(
                string partition,
                IEventHubDataAdapter dataAdatper,
                StreamStatisticOptions options,
                StreamCacheEvictionOptions evictionOptions,
                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 cacheLogger            = loggerFactory.CreateLogger($"{typeof(EventHubQueueCache).FullName}.{this.name}.{partition}");
                var evictionStrategy       = new ChronologicalEvictionStrategy(cacheLogger, timePurge, cacheMonitor, options.StatisticMonitorWriteInterval);
                //set defaultMaxAddCount to 10 so TryCalculateCachePressureContribution will start to calculate real contribution shortly
                var cache = new QueueCacheForTesting(DefaultMaxAddCount, bufferPool, dataAdatper, evictionStrategy, checkpointer,
                                                     cacheLogger, cacheMonitor, options.StatisticMonitorWriteInterval);

                this.caches.Add(cache);
                return(cache);
            }
Beispiel #13
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;
 }