Пример #1
0
        public void LoadsSampleScript()
        {
            ITimeSeriesTypesAccess tsTypes = new TimeSeriesTypesLoader();

            var tempTimeSeriesConfig = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N") + ".cs");

            try
            {
                using (var tempTimeSeriesConfigStream = new FileStream(tempTimeSeriesConfig, FileMode.Create))
                    Utils.GetResourceStream("TestParserConfig").CopyTo(tempTimeSeriesConfigStream);
                Environment.SetEnvironmentVariable("TSTEST", tempTimeSeriesConfig);
                tsTypes.CustomConfigEnvVar = "TSTEST";

                Assert.IsTrue(string.IsNullOrEmpty(tsTypes.CustomConfigLoadingError));
                Assert.AreEqual(1, tsTypes.GetMetadataTypes().Count(t => t.Name == "FooBar"));
            }
            finally
            {
                File.Delete(tempTimeSeriesConfig);
            }
        }
Пример #2
0
        public static ModelObjects Create(
            ModelConfig config,
            ISynchronizationContext modelSynchronizationContext,
            Func <Persistence.IStorageManager, Preprocessing.ICredentialsCache> createPreprocessingCredentialsCache,
            Func <IShutdownSource, Persistence.IWebContentCache, ITraceSourceFactory, WebViewTools.IWebViewTools> createWebBrowserDownloader,
            Drawing.IMatrixFactory matrixFactory,
            RegularExpressions.IRegexFactory regexFactory
            )
        {
            ITraceSourceFactory traceSourceFactory = new TraceSourceFactory(config.TraceListeners);
            IShutdownSource     shutdown           = new Shutdown();
            var tracer = traceSourceFactory.CreateTraceSource("App", "model");

            Telemetry.UnhandledExceptionsReporter.SetupLogging(tracer, shutdown);
            ILogProviderFactoryRegistry  logProviderFactoryRegistry  = new LogProviderFactoryRegistry();
            IFormatDefinitionsRepository formatDefinitionsRepository = new DirectoryFormatsRepository(null);

            MultiInstance.IInstancesCounter instancesCounter = config.DisableLogjointInstancesCounting ?
                                                               (MultiInstance.IInstancesCounter) new MultiInstance.DummyInstancesCounter() :
                                                               (MultiInstance.IInstancesCounter) new MultiInstance.InstancesCounter(shutdown);
            ITempFilesManager tempFilesManager = new TempFilesManager(traceSourceFactory, instancesCounter);

            Persistence.Implementation.IStorageManagerImplementation userDataStorage = new Persistence.Implementation.StorageManagerImplementation();
            Persistence.IStorageManager storageManager = new Persistence.PersistentUserDataManager(traceSourceFactory, userDataStorage, shutdown);
            var persistentUserDataFileSystem           = Persistence.Implementation.DesktopFileSystemAccess.CreatePersistentUserDataFileSystem(config.AppDataDirectory);

            Settings.IGlobalSettingsAccessor globalSettingsAccessor = new Settings.GlobalSettingsAccessor(storageManager);
            userDataStorage.Init(
                new Persistence.Implementation.RealTimingAndThreading(),
                persistentUserDataFileSystem,
                new Persistence.PersistentUserDataManager.ConfigAccess(globalSettingsAccessor)
                );
            Telemetry.ITelemetryUploader telemetryUploader = new Telemetry.AzureTelemetryUploader(
                traceSourceFactory,
                config.TelemetryUrl,
                config.IssuesUrl
                );
            var telemetryCollectorImpl = new Telemetry.TelemetryCollector(
                storageManager,
                telemetryUploader,
                modelSynchronizationContext,
                instancesCounter,
                shutdown,
                new MemBufferTraceAccess(),
                traceSourceFactory
                );

            Telemetry.ITelemetryCollector telemetryCollector        = telemetryCollectorImpl;
            FieldsProcessor.IFactory      fieldsProcessorFactory    = new FieldsProcessor.FieldsProcessorImpl.Factory(storageManager, telemetryCollector);
            UserDefinedFormatsManager     userDefinedFormatsManager = new UserDefinedFormatsManager(
                formatDefinitionsRepository, logProviderFactoryRegistry, tempFilesManager, traceSourceFactory, regexFactory, fieldsProcessorFactory);

            RegisterUserDefinedFormats(userDefinedFormatsManager);
            RegisterPredefinedFormatFactories(logProviderFactoryRegistry, tempFilesManager, userDefinedFormatsManager, regexFactory, traceSourceFactory);
            ISynchronizationContext threadPoolSynchronizationContext = new ThreadPoolSynchronizationContext();
            IChangeNotification     changeNotification = new ChangeNotification(modelSynchronizationContext);
            IFiltersFactory         filtersFactory     = new FiltersFactory(changeNotification, regexFactory);
            IBookmarksFactory       bookmarksFactory   = new BookmarksFactory(changeNotification);
            var bookmarks = bookmarksFactory.CreateBookmarks();

            Persistence.IFirstStartDetector firstStartDetector = persistentUserDataFileSystem;
            Persistence.Implementation.IStorageManagerImplementation contentCacheStorage = new Persistence.Implementation.StorageManagerImplementation();
            contentCacheStorage.Init(
                new Persistence.Implementation.RealTimingAndThreading(),
                Persistence.Implementation.DesktopFileSystemAccess.CreateCacheFileSystemAccess(config.AppDataDirectory),
                new Persistence.ContentCacheManager.ConfigAccess(globalSettingsAccessor)
                );
            Persistence.IContentCache           contentCache          = new Persistence.ContentCacheManager(traceSourceFactory, contentCacheStorage);
            Persistence.IWebContentCacheConfig  webContentCacheConfig = config.WebContentCacheConfig;
            Preprocessing.ILogsDownloaderConfig logsDownloaderConfig  = config.LogsDownloaderConfig;
            Persistence.IWebContentCache        webContentCache       = new Persistence.WebContentCache(
                contentCache,
                webContentCacheConfig
                );
            IHeartBeatTimer heartBeatTimer = new HeartBeatTimer();

            Progress.IProgressAggregatorFactory progressAggregatorFactory = new Progress.ProgressAggregator.Factory(heartBeatTimer, modelSynchronizationContext);
            Progress.IProgressAggregator        progressAggregator        = progressAggregatorFactory.CreateProgressAggregator();

            var threadColorsLease = new ColorLease(1);
            IModelThreadsInternal modelThreads = new ModelThreads(threadColorsLease);


            MRU.IRecentlyUsedEntities recentlyUsedLogs = new MRU.RecentlyUsedEntities(
                storageManager,
                logProviderFactoryRegistry,
                telemetryCollector
                );

            ILogSourcesManager logSourcesManager = new LogSourcesManager(
                heartBeatTimer,
                modelSynchronizationContext,
                modelThreads,
                tempFilesManager,
                storageManager,
                bookmarks,
                globalSettingsAccessor,
                recentlyUsedLogs,
                shutdown,
                traceSourceFactory,
                changeNotification,
                regexFactory
                );

            telemetryCollectorImpl.SetLogSourcesManager(logSourcesManager);

            Telemetry.UnhandledExceptionsReporter.Setup(telemetryCollector, shutdown);

            IFormatAutodetect formatAutodetect = new FormatAutodetect(
                recentlyUsedLogs,
                logProviderFactoryRegistry,
                traceSourceFactory
                );

            Workspaces.Backend.IBackendAccess workspacesBackendAccess = new Workspaces.Backend.AzureWorkspacesBackend(
                traceSourceFactory,
                config.WorkspacesUrl
                );

            Workspaces.IWorkspacesManager workspacesManager = new Workspaces.WorkspacesManager(
                logSourcesManager,
                logProviderFactoryRegistry,
                storageManager,
                workspacesBackendAccess,
                tempFilesManager,
                recentlyUsedLogs,
                shutdown,
                traceSourceFactory
                );

            AppLaunch.ILaunchUrlParser launchUrlParser = new AppLaunch.LaunchUrlParser();

            Preprocessing.IExtensionsRegistry preprocessingManagerExtensionsRegistry =
                new Preprocessing.PreprocessingManagerExtentionsRegistry(logsDownloaderConfig);

            Preprocessing.ICredentialsCache preprocessingCredentialsCache = createPreprocessingCredentialsCache(
                storageManager
                );

            WebViewTools.IWebViewTools webBrowserDownloader = createWebBrowserDownloader(shutdown, webContentCache, traceSourceFactory);

            Preprocessing.IStepsFactory preprocessingStepsFactory = new Preprocessing.PreprocessingStepsFactory(
                workspacesManager,
                launchUrlParser,
                modelSynchronizationContext,
                preprocessingManagerExtensionsRegistry,
                progressAggregator,
                webContentCache,
                preprocessingCredentialsCache,
                logProviderFactoryRegistry,
                webBrowserDownloader,
                logsDownloaderConfig,
                regexFactory
                );

            Preprocessing.IManager logSourcesPreprocessings = new Preprocessing.LogSourcesPreprocessingManager(
                modelSynchronizationContext,
                formatAutodetect,
                preprocessingManagerExtensionsRegistry,
                new Preprocessing.BuiltinStepsExtension(preprocessingStepsFactory),
                telemetryCollector,
                tempFilesManager,
                logSourcesManager,
                shutdown,
                traceSourceFactory,
                changeNotification
                );

            ISearchManager searchManager = new SearchManager(
                logSourcesManager,
                progressAggregatorFactory,
                modelSynchronizationContext,
                globalSettingsAccessor,
                telemetryCollector,
                heartBeatTimer,
                changeNotification,
                traceSourceFactory
                );

            IUserDefinedSearches userDefinedSearches = new UserDefinedSearchesManager(storageManager, filtersFactory, modelSynchronizationContext);

            ISearchHistory searchHistory = new SearchHistory(storageManager.GlobalSettingsEntry, userDefinedSearches);

            IBookmarksController bookmarksController = new BookmarkController(
                bookmarks,
                modelThreads,
                heartBeatTimer
                );

            IFiltersManager filtersManager = new FiltersManager(
                filtersFactory,
                globalSettingsAccessor,
                logSourcesManager,
                shutdown
                );

            Postprocessing.IUserNamesProvider analyticsShortNames = new Postprocessing.CodenameUserNamesProvider(
                logSourcesManager
                );

            Postprocessing.TimeSeries.ITimeSeriesTypesAccess timeSeriesTypesAccess = new Postprocessing.TimeSeries.TimeSeriesTypesLoader();

            Postprocessing.ILogPartTokenFactories logPartTokenFactories = new Postprocessing.LogPartTokenFactories();

            Postprocessing.Correlation.ISameNodeDetectionTokenFactories sameNodeDetectionTokenFactories = new Postprocessing.Correlation.SameNodeDetectionTokenFactories();

            Postprocessing.IManagerInternal postprocessorsManager = new Postprocessing.PostprocessorsManager(
                logSourcesManager,
                telemetryCollector,
                modelSynchronizationContext,
                threadPoolSynchronizationContext,
                heartBeatTimer,
                progressAggregator,
                globalSettingsAccessor,
                new Postprocessing.OutputDataDeserializer(timeSeriesTypesAccess, logPartTokenFactories, sameNodeDetectionTokenFactories),
                traceSourceFactory,
                logPartTokenFactories,
                sameNodeDetectionTokenFactories,
                changeNotification
                );

            Postprocessing.Correlation.ICorrelationManager correlationManager = new Postprocessing.Correlation.CorrelationManager(
                postprocessorsManager,
                () => new LogJoint.Postprocessing.Correlation.EmbeddedSolver.EmbeddedSolver(),
                modelSynchronizationContext,
                logSourcesManager,
                changeNotification,
                telemetryCollector
                );


            Postprocessing.IModel postprocessingModel = new Postprocessing.Model(
                postprocessorsManager,
                timeSeriesTypesAccess,
                new Postprocessing.StateInspector.Model(tempFilesManager, logPartTokenFactories),
                new Postprocessing.Timeline.Model(tempFilesManager, logPartTokenFactories),
                new Postprocessing.SequenceDiagram.Model(tempFilesManager, logPartTokenFactories),
                new Postprocessing.TimeSeries.Model(timeSeriesTypesAccess),
                new Postprocessing.Correlation.Model(tempFilesManager, logPartTokenFactories, sameNodeDetectionTokenFactories)
                );

            AutoUpdate.IFactory autoUpdateFactory = new AutoUpdate.Factory(
                tempFilesManager,
                traceSourceFactory,
                instancesCounter,
                shutdown,
                modelSynchronizationContext,
                firstStartDetector,
                telemetryCollector,
                storageManager,
                changeNotification,
                config.AutoUpdateUrl,
                config.PluginsUrl
                );

            AppLaunch.ICommandLineHandler commandLineHandler = new AppLaunch.CommandLineHandler(
                logSourcesPreprocessings,
                preprocessingStepsFactory);

            Postprocessing.IAggregatingLogSourceNamesProvider logSourceNamesProvider = new Postprocessing.AggregatingLogSourceNamesProvider();

            Postprocessing.InternalTracePostprocessors.Register(
                postprocessorsManager,
                userDefinedFormatsManager,
                timeSeriesTypesAccess,
                postprocessingModel
                );

            Extensibility.IPluginsManagerInternal pluginsManager = new Extensibility.PluginsManager(
                traceSourceFactory,
                telemetryCollector,
                shutdown,
                userDefinedFormatsManager,
                autoUpdateFactory.CreatePluginsIndexUpdateDownloader(),
                new Extensibility.PluginsIndex.Factory(telemetryCollector),
                changeNotification,
                autoUpdateFactory.CreateAppUpdateDownloader()
                );

            AutoUpdate.IAutoUpdater autoUpdater = autoUpdateFactory.CreateAutoUpdater(pluginsManager);

            Model expensibilityModel = new Model(
                modelSynchronizationContext,
                changeNotification,
                webContentCache,
                contentCache,
                storageManager,
                bookmarks,
                logSourcesManager,
                modelThreads,
                tempFilesManager,
                new Preprocessing.Model(
                    logSourcesPreprocessings,
                    preprocessingStepsFactory,
                    preprocessingManagerExtensionsRegistry
                    ),
                progressAggregator,
                logProviderFactoryRegistry,
                userDefinedFormatsManager,
                recentlyUsedLogs,
                progressAggregatorFactory,
                shutdown,
                webBrowserDownloader,
                postprocessingModel,
                pluginsManager,
                traceSourceFactory
                );

            tracer.Info("model creation completed");

            return(new ModelObjects
            {
                GlobalSettingsAccessor = globalSettingsAccessor,
                InstancesCounter = instancesCounter,
                Shutdown = shutdown,
                TelemetryCollector = telemetryCollector,
                FirstStartDetector = firstStartDetector,
                LaunchUrlParser = launchUrlParser,
                ChangeNotification = changeNotification,
                BookmarksFactory = bookmarksFactory,
                LogSourcesManager = logSourcesManager,
                ModelThreads = modelThreads,
                FiltersManager = filtersManager,
                Bookmarks = bookmarks,
                SearchManager = searchManager,
                FiltersFactory = filtersFactory,
                LogSourcesPreprocessings = logSourcesPreprocessings,
                UserDefinedSearches = userDefinedSearches,
                SearchHistory = searchHistory,
                ProgressAggregatorFactory = progressAggregatorFactory,
                PreprocessingStepsFactory = preprocessingStepsFactory,
                WorkspacesManager = workspacesManager,
                RecentlyUsedLogs = recentlyUsedLogs,
                LogProviderFactoryRegistry = logProviderFactoryRegistry,
                UserDefinedFormatsManager = userDefinedFormatsManager,
                PluginFormatsManager = userDefinedFormatsManager,
                FormatDefinitionsRepository = formatDefinitionsRepository,
                TempFilesManager = tempFilesManager,
                StorageManager = storageManager,
                TelemetryUploader = telemetryUploader,
                ProgressAggregator = progressAggregator,
                PostprocessorsManager = postprocessorsManager,
                CorrelationManager = correlationManager,
                ExpensibilityEntryPoint = expensibilityModel,
                AnalyticsShortNames = analyticsShortNames,
                SynchronizationContext = modelSynchronizationContext,
                AutoUpdater = autoUpdater,
                CommandLineHandler = commandLineHandler,
                LogSourceNamesProvider = logSourceNamesProvider,
                HeartBeatTimer = heartBeatTimer,
                ThreadColorsLease = threadColorsLease,
                PluginsManager = pluginsManager,
                TraceSourceFactory = traceSourceFactory,
                MatrixFactory = matrixFactory,
                RegexFactory = regexFactory,
                FieldsProcessorFactory = fieldsProcessorFactory,
            });
        }