/// <summary> /// Initialization of EventHub receiver is performed at adapter reciever initialization, but if it fails, /// it will be retried when messages are requested /// </summary> /// <returns></returns> private async Task Initialize() { var watch = Stopwatch.StartNew(); try { checkpointer = await checkpointerFactory(settings.Partition); cache = cacheFactory(settings.Partition, checkpointer, baseLogger); flowController = new AggregatedQueueFlowController(MaxMessagesPerRead) { cache, LoadShedQueueFlowController.CreateAsPercentOfLoadSheddingLimit(getNodeConfig) }; string offset = await checkpointer.Load(); receiver = await this.eventHubReceiverFactory(settings, offset, logger); watch.Stop(); monitor?.TrackInitialization(true, watch.Elapsed, null); } catch (Exception ex) { watch.Stop(); monitor?.TrackInitialization(false, watch.Elapsed, ex); throw; } }
/// <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="providerSettings"></param> /// <param name="cacheLogger"></param> protected virtual void AddCachePressureMonitors(IEventHubQueueCache cache, EventHubStreamProviderSettings providerSettings, Logger cacheLogger) { if (providerSettings.AveragingCachePressureMonitorFlowControlThreshold.HasValue) { var avgMonitor = new AveragingCachePressureMonitor( providerSettings.AveragingCachePressureMonitorFlowControlThreshold.Value, cacheLogger); cache.AddCachePressureMonitor(avgMonitor); } if (providerSettings.SlowConsumingMonitorPressureWindowSize.HasValue || providerSettings.SlowConsumingMonitorFlowControlThreshold.HasValue) { var slowConsumeMonitor = new SlowConsumingPressureMonitor(cacheLogger); if (providerSettings.SlowConsumingMonitorFlowControlThreshold.HasValue) { slowConsumeMonitor.FlowControlThreshold = providerSettings.SlowConsumingMonitorFlowControlThreshold.Value; } if (providerSettings.SlowConsumingMonitorPressureWindowSize.HasValue) { slowConsumeMonitor.PressureWindowSize = providerSettings.SlowConsumingMonitorPressureWindowSize.Value; } cache.AddCachePressureMonitor(slowConsumeMonitor); } }
/// <summary> /// Initialization of EventHub receiver is performed at adapter receiver initialization, but if it fails, /// it will be retried when messages are requested /// </summary> /// <returns></returns> private async Task Initialize() { var watch = Stopwatch.StartNew(); try { this.checkpointer = await this.checkpointerFactory(this.settings.Partition); if (this.cache != null) { this.cache.Dispose(); this.cache = null; } this.cache = this.cacheFactory(this.settings.Partition, this.checkpointer, this.loggerFactory, this.telemetryProducer); this.flowController = new AggregatedQueueFlowController(MaxMessagesPerRead) { this.cache, LoadShedQueueFlowController.CreateAsPercentOfLoadSheddingLimit(this.loadSheddingOptions) }; string offset = await this.checkpointer.Load(); this.receiver = this.eventHubReceiverFactory(this.settings, offset, this.logger, this.telemetryProducer); watch.Stop(); this.monitor?.TrackInitialization(true, watch.Elapsed, null); } catch (Exception ex) { watch.Stop(); this.monitor?.TrackInitialization(false, watch.Elapsed, ex); throw; } }
public Task Shutdown(TimeSpan timeout) { // if receiver was already shutdown, do nothing if (ReceiverShutdown == Interlocked.Exchange(ref recieverState, ReceiverShutdown)) { return(TaskDone.Done); } logger.Info("Stopping reading from EventHub partition {0}-{1}", settings.Hub.Path, settings.Partition); // clear cache and receiver IEventHubQueueCache localCache = Interlocked.Exchange(ref cache, null); EventHubReceiver localReceiver = Interlocked.Exchange(ref receiver, null); // start closing receiver Task closeTask = TaskDone.Done; if (localReceiver != null) { closeTask = localReceiver.CloseAsync(); } // dispose of cache localCache?.Dispose(); // finish return receiver closing task return(closeTask); }
public async Task Initialize(TimeSpan timeout) { checkpointer = await checkpointerFactory(config.Partition); cache = cacheFactory(checkpointer); string offset = await checkpointer.Load(); receiver = await CreateReceiver(config, offset); }
public async Task Initialize(TimeSpan timeout) { checkpointer = await checkpointerFactory(config.Partition); cache = cacheFactory(checkpointer); flowController = new AggregatedQueueFlowController(MaxMessagesPerRead) { cache }; string offset = await checkpointer.Load(); receiver = await CreateReceiver(config, offset); }
/// <summary> /// Initialization of EventHub receiver is performed at adapter reciever initialization, but if it fails, /// it will be retried when messages are requested /// </summary> /// <returns></returns> private async Task Initialize() { checkpointer = await checkpointerFactory(settings.Partition); cache = cacheFactory(settings.Partition, checkpointer, baseLogger); flowController = new AggregatedQueueFlowController(MaxMessagesPerRead) { cache }; string offset = await checkpointer.Load(); receiver = await CreateReceiver(settings, offset, logger); }
public async Task Initialize(TimeSpan timeout) { logger.Info("Initializing EventHub partition {0}-{1}.", config.Hub.Path, config.Partition); checkpointer = await checkpointerFactory(config.Partition); cache = cacheFactory(config.Partition, checkpointer, baseLogger); flowController = new AggregatedQueueFlowController(MaxMessagesPerRead) { cache }; string offset = await checkpointer.Load(); receiver = await CreateReceiver(config, offset, logger); }
public Task Shutdown(TimeSpan timeout) { logger.Info("Stopping reading from EventHub partition {0}-{1}", config.Hub.Path, config.Partition); // clear cache and receiver IEventHubQueueCache localCache = Interlocked.Exchange(ref cache, null); EventHubReceiver localReceiver = Interlocked.Exchange(ref receiver, null); // start closing receiver Task closeTask = TaskDone.Done; if (localReceiver != null) { closeTask = localReceiver.CloseAsync(); } // dispose of cache localCache?.Dispose(); // finish return receiver closing task return(closeTask); }
public Task Shutdown(TimeSpan timeout) { // clear cache and receiver IEventHubQueueCache localCache = Interlocked.Exchange(ref cache, null); EventHubReceiver localReceiver = Interlocked.Exchange(ref receiver, null); // start closing receiver Task closeTask = TaskDone.Done; if (localReceiver != null) { closeTask = localReceiver.CloseAsync(); } // dispose of cache if (localCache != null) { localCache.Dispose(); } // finish return receiver closing task return(closeTask); }
public async Task Shutdown(TimeSpan timeout) { var watch = Stopwatch.StartNew(); try { // if receiver was already shutdown, do nothing if (ReceiverShutdown == Interlocked.Exchange(ref recieverState, ReceiverShutdown)) { return; } logger.Info("Stopping reading from EventHub partition {0}-{1}", settings.Hub.Path, settings.Partition); // clear cache and receiver IEventHubQueueCache localCache = Interlocked.Exchange(ref cache, null); var localReceiver = Interlocked.Exchange(ref receiver, null); // start closing receiver Task closeTask = Task.CompletedTask; if (localReceiver != null) { closeTask = localReceiver.CloseAsync(); } // dispose of cache localCache?.Dispose(); // finish return receiver closing task await closeTask; watch.Stop(); monitor?.TrackShutdown(true, watch.Elapsed, null); } catch (Exception ex) { watch.Stop(); monitor?.TrackShutdown(false, watch.Elapsed, ex); throw; } }
/// <summary> /// Initialization of EventHub receiver is performed at adapter reciever initialization, but if it fails, /// it will be retried when messages are requested /// </summary> /// <returns></returns> private async Task Initialize() { try { checkpointer = await checkpointerFactory(settings.Partition); cache = cacheFactory(settings.Partition, checkpointer, baseLogger); flowController = new AggregatedQueueFlowController(MaxMessagesPerRead) { cache, LoadShedQueueFlowController.CreateAsPercentOfLoadSheddingLimit() }; string offset = await checkpointer.Load(); receiver = await CreateReceiver(settings, offset, logger); monitor.TrackInitialization(true); } catch (Exception) { monitor.TrackInitialization(false); throw; } }
public Cursor(IEventHubQueueCache cache, IStreamIdentity streamIdentity, StreamSequenceToken token) { this.cache = cache; cursor = cache.GetCursor(streamIdentity, token); }
protected override void AddCachePressureMonitors(IEventHubQueueCache cache, EventHubStreamCachePressureOptions providerOptions, ILogger cacheLogger) { cache.AddCachePressureMonitor(this.cachePressureInjectionMonitor); }
public Cursor(IEventHubQueueCache cache, StreamId streamId, StreamSequenceToken token) { this.cache = cache; this.cursor = cache.GetCursor(streamId, token); }
protected override void AddCachePressureMonitors(IEventHubQueueCache cache, EventHubStreamProviderSettings providerSettings, Logger cacheLogger) { cache.AddCachePressureMonitor(this.cachePressureInjectionMonitor); }