Beispiel #1
0
 /// <summary>
 /// EventHub queue cache.
 /// </summary>
 /// <param name="partition">Partition this instance is caching.</param>
 /// <param name="defaultMaxAddCount">Default max number of items that can be added to the cache between purge calls.</param>
 /// <param name="bufferPool">raw data block pool.</param>
 /// <param name="dataAdapter">Adapts EventData to cached.</param>
 /// <param name="evictionStrategy">Eviction strategy manage purge related events</param>
 /// <param name="checkpointer">Logic used to store queue position.</param>
 /// <param name="logger"></param>
 /// <param name="cacheMonitor"></param>
 /// <param name="cacheMonitorWriteInterval"></param>
 /// <param name="metadataMinTimeInCache"></param>
 public EventHubQueueCache(
     string partition,
     int defaultMaxAddCount,
     IObjectPool <FixedSizeBuffer> bufferPool,
     IEventHubDataAdapter dataAdapter,
     IEvictionStrategy evictionStrategy,
     IStreamQueueCheckpointer <string> checkpointer,
     ILogger logger,
     ICacheMonitor cacheMonitor,
     TimeSpan?cacheMonitorWriteInterval,
     TimeSpan?metadataMinTimeInCache)
 {
     this.Partition          = partition;
     this.defaultMaxAddCount = defaultMaxAddCount;
     this.bufferPool         = bufferPool;
     this.dataAdapter        = dataAdapter;
     this.checkpointer       = checkpointer;
     this.cache                            = new PooledQueueCache(dataAdapter, logger, cacheMonitor, cacheMonitorWriteInterval, metadataMinTimeInCache);
     this.cacheMonitor                     = cacheMonitor;
     this.evictionStrategy                 = evictionStrategy;
     this.evictionStrategy.OnPurged        = this.OnPurge;
     this.evictionStrategy.PurgeObservable = this.cache;
     this.cachePressureMonitor             = new AggregatedCachePressureMonitor(logger, cacheMonitor);
     this.logger                           = logger;
 }
 /// <summary>
 /// Construct EventHub queue cache.
 /// </summary>
 /// <param name="defaultMaxAddCount">Default max number of items that can be added to the cache between purge calls.</param>
 /// <param name="checkpointer">Logic used to store queue position.</param>
 /// <param name="cacheDataAdapter">Performs data transforms appropriate for the various types of queue data.</param>
 /// <param name="comparer">Compares cached data</param>
 /// <param name="logger"></param>
 protected EventHubQueueCache(int defaultMaxAddCount, IStreamQueueCheckpointer <string> checkpointer, ICacheDataAdapter <EventData, TCachedMessage> cacheDataAdapter, ICacheDataComparer <TCachedMessage> comparer, Logger logger)
 {
     this.defaultMaxAddCount = defaultMaxAddCount;
     Checkpointer            = checkpointer;
     cache = new PooledQueueCache <EventData, TCachedMessage>(cacheDataAdapter, comparer, logger);
     cacheDataAdapter.PurgeAction = cache.Purge;
     cache.OnPurged            = OnPurge;
     this.cachePressureMonitor = new AggregatedCachePressureMonitor(logger);
 }
 /// <summary>
 /// Construct EventHub queue cache.
 /// </summary>
 /// <param name="defaultMaxAddCount">Default max number of items that can be added to the cache between purge calls.</param>
 /// <param name="checkpointer">Logic used to store queue position.</param>
 /// <param name="cacheDataAdapter">Performs data transforms appropriate for the various types of queue data.</param>
 /// <param name="comparer">Compares cached data</param>
 /// <param name="logger"></param>
 /// <param name="evictionStrategy">Eviction stretagy manage purge related events</param>
 protected EventHubQueueCache(int defaultMaxAddCount, IStreamQueueCheckpointer <string> checkpointer, ICacheDataAdapter <EventData, TCachedMessage> cacheDataAdapter,
                              ICacheDataComparer <TCachedMessage> comparer, Logger logger, IEvictionStrategy <TCachedMessage> evictionStrategy)
 {
     this.defaultMaxAddCount = defaultMaxAddCount;
     Checkpointer            = checkpointer;
     cache = new PooledQueueCache <EventData, TCachedMessage>(cacheDataAdapter, comparer, logger);
     this.evictionStrategy                 = evictionStrategy;
     this.evictionStrategy.OnPurged        = this.OnPurge;
     this.evictionStrategy.PurgeObservable = cache;
     cacheDataAdapter.OnBlockAllocated     = this.evictionStrategy.OnBlockAllocated;
     this.cachePressureMonitor             = new AggregatedCachePressureMonitor(logger);
 }
Beispiel #4
0
 /// <summary>
 /// Construct EventHub queue cache.
 /// </summary>
 /// <param name="defaultMaxAddCount">Default max number of items that can be added to the cache between purge calls.</param>
 /// <param name="checkpointer">Logic used to store queue position.</param>
 /// <param name="cacheDataAdapter">Performs data transforms appropriate for the various types of queue data.</param>
 /// <param name="comparer">Compares cached data</param>
 /// <param name="logger"></param>
 /// <param name="evictionStrategy">Eviction stretagy manage purge related events</param>
 /// <param name="cacheMonitor"></param>
 /// <param name="cacheMonitorWriteInterval"></param>
 protected EventHubQueueCache(int defaultMaxAddCount, IStreamQueueCheckpointer <string> checkpointer, ICacheDataAdapter <EventData, TCachedMessage> cacheDataAdapter,
                              ICacheDataComparer <TCachedMessage> comparer, Logger logger, IEvictionStrategy <TCachedMessage> evictionStrategy,
                              ICacheMonitor cacheMonitor, TimeSpan?cacheMonitorWriteInterval)
 {
     this.defaultMaxAddCount = defaultMaxAddCount;
     Checkpointer            = checkpointer;
     cache                          = new PooledQueueCache <EventData, TCachedMessage>(cacheDataAdapter, comparer, logger, cacheMonitor, cacheMonitorWriteInterval);
     this.cacheMonitor              = cacheMonitor;
     this.evictionStrategy          = evictionStrategy;
     this.evictionStrategy.OnPurged = this.OnPurge;
     this.cachePressureMonitor      = new AggregatedCachePressureMonitor(logger, cacheMonitor);
     EvictionStrategyCommonUtils.WireUpEvictionStrategy <EventData, TCachedMessage>(this.cache, cacheDataAdapter, this.evictionStrategy);
 }