private async Task OnSchedulerConfigurationChanged(CollectorConfigChangeResult collectorConfigChangeResult)
        {
            _schedulerCollectorConfigurationService.GetCollectorConfiguration(true);

            foreach (var collector in collectorConfigChangeResult.RemovedCollectors)
            {
                await _scheduler.DeleteJob(new JobKey(collector.Id, "CollectorGroup"));

                _logger.LogInformation($"Removed collector {collector.Id} from the scheduler due to changed configuration.");
            }

            foreach (var collector in collectorConfigChangeResult.ChangedCollectors)
            {
                await _scheduler.DeleteJob(new JobKey(collector.Id, "CollectorGroup"));

                var job     = CreateCollectorJobDetail(collector, collector.Id);
                var trigger = CreateCollectorTrigger(collector, collector.Id);
                await _scheduler.ScheduleJob(job, trigger);

                _logger.LogInformation($"Updated collector {collector.Id} within the scheduler due to changed configuration.");
            }

            foreach (var collector in collectorConfigChangeResult.AddedCollectors)
            {
                var job     = CreateCollectorJobDetail(collector, collector.Id);
                var trigger = CreateCollectorTrigger(collector, collector.Id);
                await _scheduler.ScheduleJob(job, trigger);

                _logger.LogInformation($"Added collector {collector.Id} to the scheduler due to changed configuration.");
            }
        }
示例#2
0
        private static void AnalyzeCollectorChanges(CollectorConfigChangeResult configurationChangeResult,
                                                    List <Collector> loadedConfigCollectors, List <Collector> compareConfigurationCollectors)
        {
            var removedCollectors = compareConfigurationCollectors.Where(w =>
                                                                         loadedConfigCollectors.All(x => !x.Id.EqualsIgnoreCase(w.Id)));

            configurationChangeResult.RemovedCollectors.AddRange(removedCollectors);

            foreach (var collector in loadedConfigCollectors)
            {
                if (string.IsNullOrWhiteSpace(collector.Id))
                {
                    continue;
                }

                var compareCollector = compareConfigurationCollectors.FirstOrDefault(f =>
                                                                                     f.Id.EqualsIgnoreCase(collector.Id));
                if (compareCollector == null)
                {
                    configurationChangeResult.AddedCollectors.Add(collector);
                }
                else if (!compareCollector.IsEqualByJsonCompare(collector))
                {
                    configurationChangeResult.ChangedCollectors.Add(collector);
                }
            }
        }
示例#3
0
        public static CollectorConfigChangeResult AnalyzeConfigurationChanges(CollectorConfig newCollectorConfig,
                                                                              CollectorConfig currentCollectorConfig)
        {
            var configurationChangeResult = new CollectorConfigChangeResult();

            AnalyzeNotificationChanges(configurationChangeResult, newCollectorConfig.Notifications,
                                       currentCollectorConfig.Notifications);

            AnalyzeCollectorChanges(configurationChangeResult, newCollectorConfig.Collectors,
                                    currentCollectorConfig.Collectors);

            return(configurationChangeResult);
        }