/// <summary>
        /// Disposes off this instance.
        /// </summary>
        /// <param name="disposing">Indication whether called from finalizer or Dispose().</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposedValue)
            {
                if (disposing)
                {
                    this.timer?.Dispose();

                    foreach (var item in this.dataHandlers)
                    {
                        item?.Dispose();
                    }

                    this.dataHandlers.Clear();

                    this.DisposeDatabaseContext();

                    this.hamnetDbPoller?.Dispose();
                    this.hamnetDbPoller = null;
                }

                // TODO: nicht verwaltete Ressourcen (nicht verwaltete Objekte) freigeben und Finalizer weiter unten überschreiben.
                // TODO: große Felder auf Null setzen.

                this.disposedValue = true;
            }
        }
Пример #2
0
 /// <summary>
 /// Construct for the given configuration.
 /// </summary>
 /// <param name="configuration">The configuration to construct for.</param>
 /// <param name="hamnetDbPoller">The HamnetDB poller to use for lookups.</param>
 public InfluxDatabaseDataHandler(IConfiguration configuration, HamnetDbPoller hamnetDbPoller)
 {
     this.configuration       = configuration ?? throw new ArgumentNullException(nameof(configuration), "configuration is null");
     this.influxConfiguration = configuration.GetSection(Program.InfluxSectionKey);
     this.CreateInfluxClient();
     this.hamnetDbPoller = hamnetDbPoller ?? throw new ArgumentNullException(nameof(hamnetDbPoller), "hamnetDbPoller is null");
 }
        /// <summary>
        /// Constructs taking the logger.
        /// </summary>
        /// <param name="logger">The logger to use.</param>
        /// <param name="configuration">The service configuration.</param>
        /// <param name="hamnetDbAccess">The singleton instance of the HamnetDB access handler.</param>
        /// <param name="retryFeasibleHandler">The handler to check whether retry is feasible.</param>
        public BgpAquisitionService(ILogger <BgpAquisitionService> logger, IConfiguration configuration, IHamnetDbAccess hamnetDbAccess, IFailureRetryFilteringDataHandler retryFeasibleHandler)
        {
            this.logger               = logger ?? throw new ArgumentNullException(nameof(logger), "The logger has not been provided by DI engine");
            this.configuration        = configuration ?? throw new ArgumentNullException(nameof(configuration), "The configuration has not been provided by DI engine");
            this.retryFeasibleHandler = retryFeasibleHandler ?? throw new ArgumentNullException(nameof(retryFeasibleHandler), "The retry feasible handler singleton has not been provided by DI engine");

            this.hamnetDbPoller = new HamnetDbPoller(this.configuration, hamnetDbAccess ?? throw new ArgumentNullException(nameof(hamnetDbAccess), "The HamnetDB accessor singleton has not been provided by DI engine"));

            this.dataHandlers.Add(this.retryFeasibleHandler);
            this.dataHandlers.Add(new ResultDatabaseDataHandler(configuration, this.retryFeasibleHandler));
            this.dataHandlers.Add(new InfluxDatabaseDataHandler(configuration, this.hamnetDbPoller));
            this.dataHandlers = this.dataHandlers.OrderBy(h => h.Name).ToList();
        }
        /// <summary>
        /// Constructs taking the logger.
        /// </summary>
        /// <param name="logger">The logger to use.</param>
        /// <param name="configuration">The service configuration.</param>
        /// <param name="hamnetDbAccess">The singleton instance of the HamnetDB access handler.</param>
        /// <param name="retryFeasibleHandler">The handler to check whether retry is feasible.</param>
        public RssiAquisitionService(ILogger<RssiAquisitionService> logger, IConfiguration configuration, IHamnetDbAccess hamnetDbAccess, IFailureRetryFilteringDataHandler retryFeasibleHandler)
        {
            this.logger = logger ?? throw new ArgumentNullException(nameof(logger), "The logger has not been provided by DI engine");
            this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration), "The configuration has not been provided by DI engine");
            this.retryFeasibleHandler = retryFeasibleHandler ?? throw new ArgumentNullException(nameof(retryFeasibleHandler), "The retry feasible handler singleton has not been provided by DI engine");

            this.dataHandlers.Add(this.retryFeasibleHandler);
            this.dataHandlers.Add(new ResultDatabaseDataHandler(configuration, this.retryFeasibleHandler));

            this.hamnetDbPoller = new HamnetDbPoller(this.configuration, hamnetDbAccess ?? throw new ArgumentNullException(nameof(hamnetDbAccess), "The HamnetDB accessor singleton has not been provided by DI engine"));

            IConfigurationSection influxSection = configuration.GetSection(Program.InfluxSectionKey);
            if ((influxSection != null) && influxSection.GetChildren().Any())
            {
                this.dataHandlers.Add(new InfluxDatabaseDataHandler(configuration, this.hamnetDbPoller));
            }
            else
            {
                this.logger.LogInformation($"Influx database disabled: No or empty '{Program.InfluxSectionKey}' section in configuration");
            }

            this.dataHandlers = this.dataHandlers.OrderBy(h => h.Name).ToList();
        }