Exemplo n.º 1
0
 public PostprocessorOutputRecord(
     ILogSourcePostprocessor metadata,
     LogSourceRecord logSourceRecord,
     Action scheduleRefresh,
     Action fireChangeNotification,
     LJTraceSource trace,
     IHeartBeatTimer heartbeat,
     ISynchronizationContext modelSyncContext,
     ISynchronizationContext threadPoolSyncContext,
     Telemetry.ITelemetryCollector telemetry,
     IOutputDataDeserializer outputDataDeserializer)
 {
     this.metadata        = metadata;
     this.logSourceRecord = logSourceRecord;
     state = new LoadingState(new PostprocessorOutputRecordState.Context()
     {
         owner                  = this,
         scheduleRefresh        = scheduleRefresh,
         fireChangeNotification = fireChangeNotification,
         tracer                 = trace,
         telemetry              = telemetry,
         heartbeat              = heartbeat,
         modelSyncContext       = modelSyncContext,
         threadPoolSyncContext  = threadPoolSyncContext,
         outputDataDeserializer = outputDataDeserializer
     }, null, null);
 }
Exemplo n.º 2
0
        void Refresh()
        {
            bool somethingChanged = false;

            foreach (LogSourceRecord rec in knownLogSources.Values)
            {
                rec.logSourceIsAlive = false;
            }
            foreach (var src in EnumLogSourcesOfKnownTypes())
            {
                if (!knownLogSources.TryGetValue(src.Key, out LogSourceRecord rec))
                {
                    rec = new LogSourceRecord(src.Key, src.Value);
                    foreach (var postprocessorType in rec.metadata.SupportedPostprocessors)
                    {
                        rec.PostprocessorsOutputs.Add(new PostprocessorOutputRecord(
                                                          postprocessorType, rec, updater.Invoke,
                                                          FireChangedEvent, tracer,
                                                          heartbeat, modelSyncContext, threadPoolSyncContext, telemetry, outputDataDeserializer));
                    }

                    knownLogSources.Add(src.Key, rec);
                    somethingChanged = true;
                }
                rec.logSourceIsAlive = true;

                foreach (var parserOutput in rec.PostprocessorsOutputs)
                {
                    if (parserOutput.SetState(parserOutput.state.Refresh()))
                    {
                        somethingChanged = true;
                    }
                }
            }
            foreach (LogSourceRecord rec in new List <LogSourceRecord>(knownLogSources.Values))
            {
                if (rec.logSource.IsDisposed)
                {
                    rec.logSourceIsAlive = false;
                }
                if (!rec.logSourceIsAlive)
                {
                    if (!rec.cancellation.IsCancellationRequested)
                    {
                        rec.cancellation.Cancel();
                    }
                    knownLogSources.Remove(rec.logSource);
                    rec.PostprocessorsOutputs.ForEach(ppo => ppo.Dispose());
                    somethingChanged = true;
                }
            }
            if (somethingChanged)
            {
                FireChangedEvent();
            }

            if (somethingChanged && settingsAccessor.EnableAutoPostprocessing)
            {
                var outputs = this.GetAutoPostprocessingCapableOutputs()
                              .Where(x => x.PostprocessorMetadata.Kind != PostprocessorKind.Correlator)
                              .Select(output => new KeyValuePair <ILogSourcePostprocessor, ILogSource>(output.PostprocessorMetadata, output.LogSource))
                              .ToArray();
                if (outputs.Length > 0)
                {
                    ((IManager)this).RunPostprocessor(outputs);
                }
            }
        }
Exemplo n.º 3
0
        void Refresh()
        {
            bool somethingChanged = false;

            foreach (LogSourceRecord rec in knownLogSources.Values)
            {
                rec.logSourceIsAlive = false;
            }
            foreach (var src in EnumLogSourcesOfKnownTypes())
            {
                if (!knownLogSources.TryGetValue(src.Key, out LogSourceRecord rec))
                {
                    rec = new LogSourceRecord(src.Key, src.Value, logFileSystem);
                    foreach (var postprocessorType in rec.metadata.SupportedPostprocessors)
                    {
                        rec.PostprocessorsOutputs.Add(new PostprocessorOutputRecord(
                                                          postprocessorType, rec, () => updater.Invoke(),
                                                          FireChangedEvent, tracer,
                                                          heartbeat, modelSyncContext, threadPoolSyncContext, telemetry, outputDataDeserializer));
                    }

                    knownLogSources  = knownLogSources.Add(src.Key, rec);
                    somethingChanged = true;
                }
                rec.logSourceIsAlive = true;

                foreach (var parserOutput in rec.PostprocessorsOutputs)
                {
                    if (parserOutput.SetState(parserOutput.state.Refresh()))
                    {
                        somethingChanged = true;
                    }
                }
            }
            foreach (LogSourceRecord rec in new List <LogSourceRecord>(knownLogSources.Values))
            {
                if (rec.logSource.IsDisposed)
                {
                    rec.logSourceIsAlive = false;
                }
                if (!rec.logSourceIsAlive)
                {
                    if (!rec.cancellation.IsCancellationRequested)
                    {
                        rec.cancellation.Cancel();
                    }
                    knownLogSources = knownLogSources.Remove(rec.logSource);
                    rec.PostprocessorsOutputs.ForEach(ppo => ppo.Dispose());
                    somethingChanged = true;
                }
            }
            if (somethingChanged)
            {
                FireChangedEvent();
            }

            if (somethingChanged && settingsAccessor.EnableAutoPostprocessing)
            {
                IManagerInternal intf = this;
                var outputs           = intf.LogSourcePostprocessors.GetAutoPostprocessingCapableOutputs().ToArray();
                if (outputs.Length > 0)
                {
                    intf.RunPostprocessors(outputs);
                }
            }
        }