コード例 #1
0
        public AllPostprocessorsControlHandler(
            IManagerInternal postprocessorsManager,
            ICorrelationManager correlationManager
            )
        {
            this.postprocessorsManager = postprocessorsManager;
            this.getOutputs            = Selectors.Create(
                () => postprocessorsManager.LogSourcePostprocessors,
                () => correlationManager.StateSummary,
                (outputs, correlatorSummary) =>
                outputs.GetAutoPostprocessingCapableOutputs()
                .Union(GetCorrelationOutputs(outputs, correlatorSummary))
                .ToArray()
                );
            this.getControlData = Selectors.Create(
                getOutputs,
                outputs => {
                var relevantPostprocessorExists = outputs.Any();

                return(new ControlData(
                           !relevantPostprocessorExists,
                           "*action Run all postprocessors*",
                           ControlData.StatusColor.Neutral
                           ));
            }
                );
        }
コード例 #2
0
        public StateInspectorVisualizerModel(
            IManagerInternal postprocessorsManager,
            ILogSourcesManager logSourcesManager,
            IChangeNotification changeNotification,
            IUserNamesProvider shortNamesManager)
        {
            this.postprocessorsManager = postprocessorsManager;
            this.shortNamesManager     = shortNamesManager;

            int postprocessorsVersion = 0;

            postprocessorsManager.Changed += (sender, args) =>
            {
                postprocessorsVersion++;
                changeNotification.Post();
            };
            var updateGroups = Updaters.Create(
                () => logSourcesManager.VisibleItems,
                () => postprocessorsVersion,
                (visibleSources, _) =>
            {
                UpdateOutputs();
                UpdateOutputGroups();
            }
                );

            this.getGroupsList = Selectors.Create(
                () =>
            {
                updateGroups();
                return(groups);
            },
                dict => (IReadOnlyList <IStateInspectorOutputsGroup>)dict.Values.ToImmutableArray()
                );
        }
コード例 #3
0
 public UnprocessedLogsToastNotification(
     IManagerInternal ppm,
     ILogSourcesManager lsm,
     PostprocessorKind postprocessorKind
     )
 {
     this.ppm = ppm;
     this.postprocessorKind = postprocessorKind;
     ppm.Changed           += (s, e) => Update();
     Update();
 }
コード例 #4
0
 public PresentationObjectsFactory(
     IManagerInternal ppm,
     ILogSourcesManager lsm,
     IChangeNotification changeNotification,
     IAlertPopup alerts,
     ICorrelationManager correlationManager
     )
 {
     this.ppm                = ppm;
     this.lsm                = lsm;
     this.alerts             = alerts;
     this.correlationManager = correlationManager;
 }
コード例 #5
0
 public CorrelatorToastNotification(
     IManagerInternal ppm,
     ILogSourcesManager lsm,
     ICorrelationManager correlationManager
     )
 {
     this.ppm = ppm;
     this.correlationManager = correlationManager;
     // todo: redesign IToastNotificationItem to be reactive
     ppm.Changed += (s, e) => Update();
     lsm.OnLogSourceTimeOffsetChanged += (s, e) => Update();
     Update();
 }
コード例 #6
0
        public TimelineVisualizerModel(
            IManagerInternal postprocessorsManager,
            ILogSourcesManager logSourcesManager,
            IUserNamesProvider shortNames,
            ILogSourceNamesProvider logSourceNamesProvider)
        {
            this.postprocessorsManager  = postprocessorsManager;
            this.shortNames             = shortNames;
            this.logSourceNamesProvider = logSourceNamesProvider;

            postprocessorsManager.Changed += (sender, args) => UpdateOutputs();
            logSourcesManager.OnLogSourceTimeOffsetChanged += (logSource, args) => UpdateAll();
            logSourcesManager.OnLogSourceVisiblityChanged  += (logSource, args) => UpdateOutputs();

            UpdateOutputs();
        }
コード例 #7
0
        public TimelineVisualizerModel(
            IManagerInternal postprocessorsManager,
            ILogSourcesManager logSourcesManager,
            IUserNamesProvider shortNames,
            ILogSourceNamesProvider logSourceNamesProvider)
        {
            this.postprocessorsManager  = postprocessorsManager;
            this.entitiesComparer       = TimelineEntitiesComparer.Instance;
            this.shortNames             = shortNames;
            this.logSourceNamesProvider = logSourceNamesProvider;

            postprocessorsManager.Changed += (sender, args) => UpdateOutputs(invalidateGroupContents: true);
            logSourcesManager.OnLogSourceTimeOffsetChanged += (logSource, args) => UpdateAll();
            logSourcesManager.OnLogSourceAnnotationChanged += (logSource, args) => UpdateOutputsSequenceDiagramNames(true);
            logSourcesManager.OnLogSourceVisiblityChanged  += (logSource, args) => UpdateOutputs(invalidateGroupContents: false);

            UpdateOutputs(invalidateGroupContents: false);
        }
コード例 #8
0
        public SequenceDiagramVisualizerModel(
            IManagerInternal postprocessorsManager,
            ILogSourcesManager logSourceManager,
            IUserNamesProvider shortNames,
            ILogSourceNamesProvider logSourceNamesProvider,
            IChangeNotification changeNotification)
        {
            this.postprocessorsManager  = postprocessorsManager;
            this.shortNames             = shortNames;
            this.logSourceNamesProvider = logSourceNamesProvider;
            this.changeNotification     = changeNotification;

            postprocessorsManager.Changed += (sender, args) => UpdateOutputs();
            logSourceManager.OnLogSourceTimeOffsetChanged += (s, e) => UpdateCachedContent();
            logSourceManager.OnLogSourceAnnotationChanged += (sender, args) => UpdateCachedContent();
            logSourceManager.OnLogSourceVisiblityChanged  += (sender, args) => UpdateOutputs();


            UpdateOutputs();
        }
コード例 #9
0
        public StateInspectorVisualizerModel(
            IManagerInternal postprocessorsManager,
            ILogSourcesManager logSourcesManager,
            ISynchronizationContext invokeSync,
            IUserNamesProvider shortNamesManager)
        {
            this.postprocessorsManager   = postprocessorsManager;
            this.outputsUpdateInvocation = new AsyncInvokeHelper(invokeSync, UpdateOutputs);
            this.shortNamesManager       = shortNamesManager;

            postprocessorsManager.Changed += (sender, args) =>
            {
                outputsUpdateInvocation.Invoke();
            };
            logSourcesManager.OnLogSourceVisiblityChanged += (sender, args) =>
            {
                outputsUpdateInvocation.Invoke();
            };

            UpdateOutputs();
        }
コード例 #10
0
        public void BeforeEach()
        {
            logSources         = Substitute.For <ILogSourcesManager>();
            telemetry          = Substitute.For <Telemetry.ITelemetryCollector>();
            mockedSyncContext  = new ManualSynchronizationContext();
            heartbeat          = Substitute.For <IHeartBeatTimer>();
            progressAggregator = Substitute.For <Progress.IProgressAggregator>();
            settingsAccessor   = Substitute.For <Settings.IGlobalSettingsAccessor>();
            logSource1         = Substitute.For <ILogSource>();
            logProviderFac1    = Substitute.For <ILogProviderFactory>();
            logSource1.Provider.Factory.Returns(logProviderFac1);
            logSource1.Provider.ConnectionParams.Returns(new ConnectionParams($"{ConnectionParamsKeys.PathConnectionParam}=/log.txt"));
            logSource1.Provider.Stats.Returns(new LogProviderStats()
            {
                ContentsEtag = null
            });
            logSourcePP1 = Substitute.For <ILogSourcePostprocessor>();
            logSourcePP1.Kind.Returns(PostprocessorKind.SequenceDiagram);
            pp1outputXmlSection = Substitute.For <Persistence.ISaxXMLStorageSection>();
            logSource1.LogSourceSpecificStorageEntry.OpenSaxXMLSection("postproc-sequencediagram.xml", Persistence.StorageSectionOpenFlag.ReadOnly).Returns(pp1outputXmlSection);
            pp1outputXmlSection.Reader.Returns(Substitute.For <XmlReader>());
            pp1PostprocessorOutput = Substitute.For <IPostprocessorOutputETag>();
            outputDataDeserializer = Substitute.For <IOutputDataDeserializer>();
            outputDataDeserializer.Deserialize(PostprocessorKind.SequenceDiagram, Arg.Any <LogSourcePostprocessorDeserializationParams>()).Returns(pp1PostprocessorOutput);
            pp1RunSummary = Substitute.For <IPostprocessorRunSummary>();
            logSourcePP1.Run(null).ReturnsForAnyArgs(Task.FromResult(pp1RunSummary));
            pp1RunSummary.GetLogSpecificSummary(null).ReturnsForAnyArgs((IPostprocessorRunSummary)null);
            logPartTokenFactories           = Substitute.For <ILogPartTokenFactories>();
            sameNodeDetectionTokenFactories = Substitute.For <ISameNodeDetectionTokenFactories>();
            changeNotification = Substitute.For <IChangeNotification>();
            fileSystem         = Substitute.For <IFileSystem>();

            manager = new LogJoint.Postprocessing.PostprocessorsManager(
                logSources, telemetry, mockedSyncContext, mockedSyncContext, heartbeat, progressAggregator, settingsAccessor, outputDataDeserializer, new TraceSourceFactory(),
                logPartTokenFactories, sameNodeDetectionTokenFactories, changeNotification, fileSystem);

            manager.Register(new LogSourceMetadata(logProviderFac1, logSourcePP1));
        }
コード例 #11
0
        public CorrelationManager(
            IManagerInternal postprocessingManager,
            Func <Solver.ISolver> solverFactory,
            ISynchronizationContext modelThreadSync,
            ILogSourcesManager logSourcesManager,
            IChangeNotification changeNotification,
            Telemetry.ITelemetryCollector telemetryCollector
            )
        {
            this.postprocessingManager = postprocessingManager;
            this.solverFactory         = solverFactory;
            this.modelThreadSync       = modelThreadSync;
            this.logSourcesManager     = logSourcesManager;
            this.changeNotification    = changeNotification;
            this.telemetryCollector    = telemetryCollector;

            logSourcesManager.OnLogSourceTimeOffsetChanged += (s, e) =>
            {
                ++logSourceTimeOffsetRevision;
                changeNotification.Post();
            };

            this.getOutputs = Selectors.Create(
                () => postprocessingManager.LogSourcePostprocessors,
                outputs => ImmutableArray.CreateRange(
                    outputs.Where(output => output.Postprocessor.Kind == PostprocessorKind.Correlator)
                    )
                );
            this.getStateSummary = Selectors.Create(
                getOutputs,
                () => logConnectionIdToLastRunResult,
                () => lastRunSummary,
                () => logSourceTimeOffsetRevision,
                GetCorrelatorStateSummary
                );
        }
コード例 #12
0
 public LogSourcePostprocessorControlHandler(
     IManagerInternal postprocessorsManager,
     PostprocessorKind postprocessorKind,
     Func <IPostprocessorVisualizerPresenter> visualizerPresenter,
     IShellOpen shellOpen,
     ITempFilesManager tempFiles
     )
 {
     this.postprocessorsManager = postprocessorsManager;
     this.postprocessorKind     = postprocessorKind;
     this.visualizerPresenter   = visualizerPresenter;
     this.shellOpen             = shellOpen;
     this.tempFiles             = tempFiles;
     this.getOutputs            = Selectors.Create(
         () => postprocessorsManager.LogSourcePostprocessors,
         outputs => ImmutableList.CreateRange(
             outputs.Where(output => output.Postprocessor.Kind == postprocessorKind)
             )
         );
     this.getControlData = Selectors.Create(
         getOutputs,
         outputs => GetCurrentData(outputs, postprocessorKind)
         );
 }
コード例 #13
0
        public Factory(
            IViewsFactory postprocessingViewsFactory,
            IManagerInternal postprocessorsManager,
            ILogSourcesManager logSourcesManager,
            ISynchronizationContext synchronizationContext,
            IChangeNotification changeNotification,
            IBookmarks bookmarks,
            IModelThreads threads,
            Persistence.IStorageManager storageManager,
            ILogSourceNamesProvider logSourceNamesProvider,
            IUserNamesProvider shortNames,
            SourcesManager.IPresenter sourcesManagerPresenter,
            LoadedMessages.IPresenter loadedMessagesPresenter,
            IClipboardAccess clipboardAccess,
            IPresentersFacade presentersFacade,
            IAlertPopup alerts,
            IColorTheme colorTheme,
            Drawing.IMatrixFactory matrixFactory,
            ICorrelationManager correlationManager
            )
        {
            stateInspectorVisualizer = new Lazy <StateInspectorVisualizer.IPresenterInternal>(() =>
            {
                var view  = postprocessingViewsFactory.CreateStateInspectorView();
                var model = new LogJoint.Postprocessing.StateInspector.StateInspectorVisualizerModel(
                    postprocessorsManager,
                    logSourcesManager,
                    synchronizationContext,
                    shortNames
                    );
                return(new StateInspectorVisualizer.StateInspectorPresenter(
                           view,
                           model,
                           shortNames,
                           logSourcesManager,
                           loadedMessagesPresenter,
                           bookmarks,
                           threads,
                           presentersFacade,
                           clipboardAccess,
                           sourcesManagerPresenter,
                           colorTheme
                           ));
            });

            timelineVisualizer = new Lazy <TimelineVisualizer.IPresenter>(() =>
            {
                var view  = postprocessingViewsFactory.CreateTimelineView();
                var model = new LogJoint.Postprocessing.Timeline.TimelineVisualizerModel(
                    postprocessorsManager,
                    logSourcesManager,
                    shortNames,
                    logSourceNamesProvider
                    );
                return(new TimelineVisualizer.TimelineVisualizerPresenter(
                           model,
                           view,
                           stateInspectorVisualizer.Value,
                           new Common.PresentationObjectsFactory(postprocessorsManager, logSourcesManager, changeNotification, alerts, correlationManager),
                           loadedMessagesPresenter,
                           bookmarks,
                           storageManager,
                           presentersFacade,
                           shortNames,
                           changeNotification,
                           colorTheme
                           ));
            });

            sequenceDiagramVisualizer = new Lazy <SequenceDiagramVisualizer.IPresenter>(() =>
            {
                var view  = postprocessingViewsFactory.CreateSequenceDiagramView();
                var model = new LogJoint.Postprocessing.SequenceDiagram.SequenceDiagramVisualizerModel(
                    postprocessorsManager,
                    logSourcesManager,
                    shortNames,
                    logSourceNamesProvider,
                    changeNotification
                    );
                return(new SequenceDiagramVisualizer.SequenceDiagramVisualizerPresenter(
                           model,
                           view,
                           stateInspectorVisualizer.Value,
                           new Common.PresentationObjectsFactory(postprocessorsManager, logSourcesManager, changeNotification, alerts, correlationManager),
                           loadedMessagesPresenter,
                           bookmarks,
                           storageManager,
                           presentersFacade,
                           shortNames,
                           changeNotification,
                           colorTheme,
                           matrixFactory
                           ));
            });

            timeSeriesVisualizer = new Lazy <TimeSeriesVisualizer.IPresenter>(() =>
            {
                var view  = postprocessingViewsFactory.CreateTimeSeriesView();
                var model = new LogJoint.Postprocessing.TimeSeries.TimelineVisualizerModel(
                    postprocessorsManager,
                    logSourcesManager,
                    shortNames,
                    logSourceNamesProvider
                    );
                return(new TimeSeriesVisualizer.TimeSeriesVisualizerPresenter(
                           model,
                           view,
                           new Common.PresentationObjectsFactory(postprocessorsManager, logSourcesManager, changeNotification, alerts, correlationManager),
                           loadedMessagesPresenter.LogViewerPresenter,
                           bookmarks,
                           presentersFacade,
                           changeNotification
                           ));
            });
        }
コード例 #14
0
        public Presenter(
            IView view,
            IManagerInternal postprocessorsManager,
            ICorrelationManager correlationManager,
            IFactory presentersFactory,
            ITempFilesManager tempFiles,
            IShellOpen shellOpen,
            NewLogSourceDialog.IPresenter newLogSourceDialog,
            IChangeNotification changeNotification,
            MainForm.IPresenter mainFormPresenter
            )
        {
            this.view = view;
            this.postprocessorsManager = postprocessorsManager;
            this.correlationManager    = correlationManager;
            this.presentersFactory     = presentersFactory;
            this.tempFiles             = tempFiles;
            this.shellOpen             = shellOpen;
            this.changeNotification    = changeNotification.CreateChainedChangeNotification(false);


            InitAndAddProstprocessorHandler(ViewControlId.StateInspector, PostprocessorKind.StateInspector);
            InitAndAddProstprocessorHandler(ViewControlId.Timeline, PostprocessorKind.Timeline);
            InitAndAddProstprocessorHandler(ViewControlId.Sequence, PostprocessorKind.SequenceDiagram);
            InitAndAddProstprocessorHandler(ViewControlId.Correlate, PostprocessorKind.Correlator);
            InitAndAddProstprocessorHandler(ViewControlId.TimeSeries, PostprocessorKind.TimeSeries);
            viewControlHandlers.Add(ViewControlId.LogsCollectionControl1, new GenericLogsOpenerControlHandler(newLogSourceDialog));
            viewControlHandlers.Add(ViewControlId.AllPostprocessors, new AllPostprocessorsControlHandler(postprocessorsManager, correlationManager));

            this.getControlsData = Selectors.Create(
                () => (
                    viewControlHandlers[ViewControlId.StateInspector].GetCurrentData(),
                    viewControlHandlers[ViewControlId.Timeline].GetCurrentData(),
                    viewControlHandlers[ViewControlId.Sequence].GetCurrentData(),
                    viewControlHandlers[ViewControlId.Correlate].GetCurrentData(),
                    viewControlHandlers[ViewControlId.TimeSeries].GetCurrentData(),
                    viewControlHandlers[ViewControlId.LogsCollectionControl1].GetCurrentData(),
                    viewControlHandlers[ViewControlId.AllPostprocessors].GetCurrentData()
                    ), _ => {
                return(ImmutableDictionary.CreateRange(
                           viewControlHandlers.Select(h => new KeyValuePair <ViewControlId, ControlData>(h.Key, h.Value.GetCurrentData()))
                           ));
            }
                );

            this.getActionStates = Selectors.Create(
                getControlsData,
                ctrlData => ImmutableDictionary.CreateRange(
                    ctrlData.Select(h => {
                Action makeAction(string id) =>
                h.Value.Content.Contains($"*{id}")
                                                        ? () => viewControlHandlers[h.Key].ExecuteAction(id, ClickFlags.None)
                                                        : (Action)null;
                return(new KeyValuePair <ViewControlId, ActionState>(
                           h.Key,
                           new ActionState
                {
                    Enabled = !h.Value.Disabled,
                    Run = makeAction(Constants.RunActionId),
                    Show = makeAction(Constants.ShowVisualizerActionId)
                }
                           ));
            })
                    )
                );

            this.view.SetViewModel(this);

            if (IsBrowser.Value)
            {
                this.changeNotification.Active = true;
            }
            else
            {
                mainFormPresenter.TabChanging += (sender, e) =>
                {
                    this.changeNotification.Active = e.TabID == MainForm.TabIDs.Postprocessing;
                };
            }
        }
コード例 #15
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  = 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);
                }
            }
        }