Example #1
0
        public LogSource(ILogSourcesManagerInternal owner, int id,
                         ILogProviderFactory providerFactory, IConnectionParams connectionParams,
                         IModelThreads threads, ITempFilesManager tempFilesManager, Persistence.IStorageManager storageManager,
                         IInvokeSynchronization invoker, Settings.IGlobalSettingsAccessor globalSettingsAccess, IBookmarks bookmarks)
        {
            this.owner                = owner;
            this.tracer               = new LJTraceSource("LogSource", string.Format("ls{0:D2}", id));
            this.tempFilesManager     = tempFilesManager;
            this.invoker              = invoker;
            this.globalSettingsAccess = globalSettingsAccess;
            this.bookmarks            = bookmarks;

            try
            {
                this.logSourceThreads              = new LogSourceThreads(this.tracer, threads, this);
                this.timeGaps                      = new TimeGapsDetector(tracer, invoker, new LogSourceGapsSource(this));
                this.timeGaps.OnTimeGapsChanged   += timeGaps_OnTimeGapsChanged;
                this.logSourceSpecificStorageEntry = CreateLogSourceSpecificStorageEntry(providerFactory, connectionParams, storageManager);

                var extendedConnectionParams = connectionParams.Clone(true);
                this.LoadPersistedSettings(extendedConnectionParams);
                this.provider = providerFactory.CreateFromConnectionParams(this, extendedConnectionParams);
            }
            catch (Exception e)
            {
                tracer.Error(e, "Failed to initialize log source");
                ((ILogSource)this).Dispose();
                throw;
            }

            this.owner.Container.Add(this);
            this.owner.FireOnLogSourceAdded(this);

            this.LoadBookmarks();
        }
        public NetworkCredentialsStorage(Persistence.IStorageEntry settingsEntry, Persistence.ICredentialsProtection credentialsProtection)
        {
            this.settingsEntry         = settingsEntry;
            this.credentialsProtection = credentialsProtection;

            Load();
        }
Example #3
0
 public FieldsProcessorImpl(
     InitializationParams initializationParams,
     IEnumerable <string> inputFieldNames,
     IEnumerable <ExtensionInfo> extensions,
     Persistence.IStorageEntry cacheEntry,
     LJTraceSource trace,
     Telemetry.ITelemetryCollector telemetryCollector,
     IMetadataReferencesProvider metadataReferencesProvider,
     IAssemblyLoader assemblyLoader
     )
 {
     if (inputFieldNames == null)
     {
         throw new ArgumentNullException(nameof(inputFieldNames));
     }
     initializationParams.InitializeInstance(this);
     if (extensions != null)
     {
         this.extensions.AddRange(extensions);
     }
     this.inputFieldNames            = inputFieldNames.Select((name, idx) => name ?? string.Format("Field{0}", idx)).ToList();
     this.cacheEntry                 = cacheEntry;
     this.trace                      = trace;
     this.telemetryCollector         = telemetryCollector;
     this.metadataReferencesProvider = metadataReferencesProvider;
     this.assemblyLoader             = assemblyLoader;
 }
Example #4
0
        public PresenterPersistentState(
            Persistence.IStorageManager storageManager,
            string globalStateStorageEntryName,
            string logSourceSpecificStateSectionName,
            IChangeNotification changeNotification,
            Func <ImmutableHashSet <string> > availableTagsSelector,
            Func <IEnumerable <ILogSource> > sourcesSelector
            )
        {
            this.changeNotification        = changeNotification;
            this.stateEntry                = storageManager.GetEntry(globalStateStorageEntryName);
            this.logSourceStateSectionName = logSourceSpecificStateSectionName;
            this.availableTagsSelector     = CreateAvailableTagsSelectorAdapter(availableTagsSelector);
            this.sourcesSelector           = sourcesSelector;

            this.getDefaultPredicate = Selectors.Create(
                this.availableTagsSelector,
                availableTags => TagsPredicate.MakeMatchAnyPredicate(availableTags)
                );

            this.getTagsPredicate = Selectors.Create(
                getDefaultPredicate,
                sourcesSelector,
                () => savedTagsRevision,
                (defaultPredicate, sources, _revision) => LoadPredicate(sources, defaultPredicate, logSourceStateSectionName)
                );
        }
Example #5
0
 public Factory(
     Persistence.IStorageManager storageManager,
     Telemetry.ITelemetryCollector telemetryCollector
     )
 {
     this.cacheEntry         = storageManager.GetEntry("user-code-cache", 0x81012232);
     this.telemetryCollector = telemetryCollector;
 }
Example #6
0
 public PreprocessingCredentialsCache(
     NSWindow parentWindow,
     Persistence.IStorageEntry credentialsCacheStorage,
     ISynchronizationContext uiInvoke)
 {
     this.credentialsCacheStorage = credentialsCacheStorage;
     this.parentWindow            = parentWindow;
     this.uiInvoke = uiInvoke;
 }
Example #7
0
 public PresentaterPersistentState(
     Persistence.IStorageManager storageManager,
     string globalStateStorageEntryName,
     string logSourceSpecificStateSectionName
     )
 {
     this.stateEntry = storageManager.GetEntry(globalStateStorageEntryName);
     this.logSourceStateSectionName = logSourceSpecificStateSectionName;
 }
Example #8
0
        public SearchHistory(
            Persistence.IStorageEntry globalSettings,
            IUserDefinedSearches userDefinedSearches
            )
        {
            this.globalSettings      = globalSettings;
            this.userDefinedSearches = userDefinedSearches;

            LoadSearchHistory();
        }
Example #9
0
 public Factory(
     Persistence.IStorageManager storageManager,
     Telemetry.ITelemetryCollector telemetryCollector,
     IMetadataReferencesProvider metadataReferencesProvider,
     IAssemblyLoader assemblyLoader
     )
 {
     this.cacheEntry                 = storageManager.GetEntry("user-code-cache", 0x81012232);
     this.telemetryCollector         = telemetryCollector;
     this.metadataReferencesProvider = metadataReferencesProvider ?? new DefaultMetadataReferencesProvider();
     this.assemblyLoader             = assemblyLoader ?? new DefaultAssemblyLoader();
 }
Example #10
0
        public TelemetryCollector(
            Persistence.IStorageManager storage,
            ITelemetryUploader telemetryUploader,
            IInvokeSynchronization synchronization,
            MultiInstance.IInstancesCounter instancesCounter,
            IShutdown shutdown,
            ILogSourcesManager logSourcesManager,
            IMemBufferTraceAccess traceAccess
            )
        {
            this.telemetryUploader = telemetryUploader;
            this.synchronization   = synchronization;
            this.traceAccess       = traceAccess;

            this.telemetryStorageEntry = storage.GetEntry("telemetry");
            this.sessionStartedMillis  = Environment.TickCount;

            this.currentSessionId = telemetryUploader.IsTelemetryConfigured ?
                                    ("session" + Guid.NewGuid().ToString("n")) : null;

            this.transactionInvoker = new AsyncInvokeHelper(synchronization,
                                                            (Action)(() => DoSessionsRegistryTransaction(TransactionFlag.Default)), new object[0]);

            shutdown.Cleanup += (s, e) => shutdown.AddCleanupTask(DisposeAsync());

            if (currentSessionId != null)
            {
                CreateCurrentSessionSection();
                InitStaticTelemetryProperties();

                logSourcesManager.OnLogSourceAdded += (s, e) =>
                {
                    ++totalNfOfLogs;
                    var nfOfSimultaneousLogs = logSourcesManager.Items.Count();
                    maxNfOfSimultaneousLogs = Math.Max(maxNfOfSimultaneousLogs, nfOfSimultaneousLogs);
                };
            }

            if (telemetryUploader.IsTelemetryConfigured && instancesCounter.IsPrimaryInstance)
            {
                this.workerCancellation     = new CancellationTokenSource();
                this.workerCancellationTask = new TaskCompletionSource <int>();
                this.worker = TaskUtils.StartInThreadPoolTaskScheduler(Worker);
            }
        }
Example #11
0
        private static HashSet <string> LoadTags(Persistence.IStorageEntry entry, string sectionName)
        {
            HashSet <string> loadedTags = null;

            using (var section = entry.OpenXMLSection(sectionName, Persistence.StorageSectionOpenFlag.ReadOnly))
            {
                var tagsElt = section.Data.SafeElement(Constants.StateRootEltName).SafeElement(Constants.TagsEltName);
                if (tagsElt != null)
                {
                    loadedTags = new HashSet <string>();
                    foreach (var tagElt in tagsElt.SafeElements(Constants.TagEltName))
                    {
                        if (!string.IsNullOrEmpty(tagElt.Value))
                        {
                            loadedTags.Add(tagElt.Value);
                        }
                    }
                }
            }
            return(loadedTags);
        }
Example #12
0
        public TelemetryCollector(
            Persistence.IStorageManager storage,
            ITelemetryUploader telemetryUploader,
            ISynchronizationContext synchronization,
            MultiInstance.IInstancesCounter instancesCounter,
            IShutdown shutdown,
            IMemBufferTraceAccess traceAccess,
            ITraceSourceFactory traceSourceFactory
            )
        {
            this.trace             = traceSourceFactory.CreateTraceSource("Telemetry");
            this.telemetryUploader = telemetryUploader;
            this.synchronization   = synchronization;
            this.traceAccess       = traceAccess;

            this.telemetryStorageEntry = storage.GetEntry("telemetry");
            this.sessionStartedMillis  = Environment.TickCount;

            this.currentSessionId = telemetryUploader.IsTelemetryConfigured ?
                                    ("session" + Guid.NewGuid().ToString("n")) : null;

            this.transactionInvoker = new AsyncInvokeHelper(synchronization,
                                                            () => DoSessionsRegistryTransaction(TransactionFlag.Default));

            shutdown.Cleanup += (s, e) => shutdown.AddCleanupTask(DisposeAsync());

            if (currentSessionId != null)
            {
                CreateCurrentSessionSection();
                InitStaticTelemetryProperties();
            }

            if (telemetryUploader.IsTelemetryConfigured && instancesCounter.IsPrimaryInstance)
            {
                this.workerCancellation     = new CancellationTokenSource();
                this.workerCancellationTask = new TaskCompletionSource <int>();
                this.worker = TaskUtils.StartInThreadPoolTaskScheduler(Worker);
            }
        }
Example #13
0
        public LogSource(ILogSourcesManagerInternal owner, int id,
                         ILogProviderFactory providerFactory, IConnectionParams connectionParams,
                         IModelThreadsInternal threads, ITempFilesManager tempFilesManager, Persistence.IStorageManager storageManager,
                         ISynchronizationContext modelSyncContext, Settings.IGlobalSettingsAccessor globalSettingsAccess, IBookmarks bookmarks,
                         ITraceSourceFactory traceSourceFactory, RegularExpressions.IRegexFactory regexFactory, LogMedia.IFileSystem fileSystem)
        {
            this.owner                = owner;
            this.tracer               = traceSourceFactory.CreateTraceSource("LogSource", string.Format("ls{0:D2}", id));
            this.tempFilesManager     = tempFilesManager;
            this.modelSyncContext     = modelSyncContext;
            this.globalSettingsAccess = globalSettingsAccess;
            this.bookmarks            = bookmarks;
            this.traceSourceFactory   = traceSourceFactory;
            this.regexFactory         = regexFactory;
            this.fileSystem           = fileSystem;

            try
            {
                this.logSourceThreads              = new LogSourceThreads(this.tracer, threads, this);
                this.timeGaps                      = new TimeGapsDetector(tracer, modelSyncContext, new LogSourceGapsSource(this), traceSourceFactory);
                this.timeGaps.OnTimeGapsChanged   += timeGaps_OnTimeGapsChanged;
                this.logSourceSpecificStorageEntry = CreateLogSourceSpecificStorageEntry(providerFactory, connectionParams, storageManager);

                var extendedConnectionParams = connectionParams.Clone(true);
                this.LoadPersistedSettings(extendedConnectionParams);
                this.provider = providerFactory.CreateFromConnectionParams(this, extendedConnectionParams);
            }
            catch (Exception e)
            {
                tracer.Error(e, "Failed to initialize log source");
                ((ILogSource)this).Dispose();
                throw;
            }

            this.owner.Add(this);
            this.owner.FireOnLogSourceAdded(this);

            this.LoadBookmarks();
        }
Example #14
0
        public AutoUpdater(
            MultiInstance.IInstancesCounter mutualExecutionCounter,
            IUpdateDownloader updateDownloader,
            ITempFilesManager tempFiles,
            IShutdown shutdown,
            IInvokeSynchronization eventInvoker,
            IFirstStartDetector firstStartDetector,
            Telemetry.ITelemetryCollector telemetry,
            Persistence.IStorageManager storage
            )
        {
            this.mutualExecutionCounter = mutualExecutionCounter;
            this.updateDownloader       = updateDownloader;
            this.tempFiles            = tempFiles;
            this.manualCheckRequested = new TaskCompletionSource <int>();
            this.firstStartDetector   = firstStartDetector;

            this.managedAssembliesPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            this.updateInfoFilePath    = Path.Combine(managedAssembliesPath, updateInfoFileName);
            this.installationDir       = Path.GetFullPath(
                Path.Combine(managedAssembliesPath, installationPathRootRelativeToManagedAssembliesLocation));

            this.eventInvoker = eventInvoker;
            this.telemetry    = telemetry;
            this.storage      = storage;

            shutdown.Cleanup += (s, e) => ((IDisposable)this).Dispose();

            this.updatesStorageEntry = storage.GetEntry("updates");

            bool isFirstInstance        = mutualExecutionCounter.IsPrimaryInstance;
            bool isDownloaderConfigured = updateDownloader.IsDownloaderConfigured;

            if (!isDownloaderConfigured)
            {
                trace.Info("autoupdater is disabled - update downloader not configured");
                isActiveAutoUpdaterInstance = false;

                state = AutoUpdateState.Disabled;
            }
            else if (!isFirstInstance)
            {
                trace.Info("autoupdater is deactivated - not a first instance of logjoint");
                isActiveAutoUpdaterInstance = false;

                state = AutoUpdateState.Inactive;
            }
            else
            {
                trace.Info("autoupdater is enabled");
                isActiveAutoUpdaterInstance = true;

                state = AutoUpdateState.Idle;

                workerCancellation      = new CancellationTokenSource();
                workerCancellationToken = workerCancellation.Token;
                workerCancellationTask  = new TaskCompletionSource <int>();

                worker = TaskUtils.StartInThreadPoolTaskScheduler(Worker);
            }
        }
Example #15
0
        public AutoUpdater(
            IFactory factory,
            MultiInstance.IInstancesCounter mutualExecutionCounter,
            IShutdown shutdown,
            ISynchronizationContext eventInvoker,
            Telemetry.ITelemetryCollector telemetry,
            Persistence.IStorageManager storage,
            ITraceSourceFactory traceSourceFactory,
            Extensibility.IPluginsManagerInternal pluginsManager,
            IChangeNotification changeNotification
            )
        {
            this.updateDownloader = factory.CreateAppUpdateDownloader();
            this.checkRequested   = new TaskCompletionSource <int>();
            this.factory          = factory;
            this.pluginsManager   = pluginsManager;
            this.trace            = traceSourceFactory.CreateTraceSource("AutoUpdater");

            var entryAssemblyLocation = Assembly.GetEntryAssembly()?.Location;

            if (entryAssemblyLocation != null)
            {
                this.managedAssembliesPath = Path.GetDirectoryName(entryAssemblyLocation);
                this.updateInfoFilePath    = Path.Combine(managedAssembliesPath, Constants.updateInfoFileName);
                this.installationDir       = Path.GetFullPath(
                    Path.Combine(managedAssembliesPath, Constants.installationPathRootRelativeToManagedAssembliesLocation));
            }

            this.eventInvoker = eventInvoker;
            this.telemetry    = telemetry;
            this.storage      = storage;

            shutdown.Cleanup += (s, e) => ((IDisposable)this).Dispose();

            this.updatesStorageEntry = storage.GetEntry("updates");

            bool isFirstInstance        = mutualExecutionCounter.IsPrimaryInstance;
            bool isDownloaderConfigured = updateDownloader.IsDownloaderConfigured;

            if (entryAssemblyLocation == null)
            {
                trace.Info("autoupdater is disabled - no entry assembly");
                isActiveAutoUpdaterInstance = false;

                state = AutoUpdateState.Disabled;
            }
            else if (!isDownloaderConfigured)
            {
                trace.Info("autoupdater is disabled - update downloader not configured");
                isActiveAutoUpdaterInstance = false;

                state = AutoUpdateState.Disabled;
            }
            else if (!isFirstInstance)
            {
                trace.Info("autoupdater is deactivated - not a first instance of logjoint");
                isActiveAutoUpdaterInstance = false;

                state = AutoUpdateState.Inactive;
            }
            else
            {
                trace.Info("autoupdater is enabled");
                isActiveAutoUpdaterInstance = true;

                state = AutoUpdateState.Idle;

                workerCancellation      = new CancellationTokenSource();
                workerCancellationToken = workerCancellation.Token;
                workerCancellationTask  = new TaskCompletionSource <int>();

                changeListenerSubscription = changeNotification.CreateSubscription(Updaters.Create(
                                                                                       () => pluginsManager.InstallationRequests,
                                                                                       (_, prev) =>
                {
                    if (prev != null)
                    {
                        checkRequested.TrySetResult(1);
                    }
                }
                                                                                       ));

                worker = TaskUtils.StartInThreadPoolTaskScheduler(Worker);
            }
        }
Example #16
0
 public LogsPreprocessorCredentialsCache(ISynchronizationContext uiInvokeSynchronization, Persistence.IStorageEntry credentialsCacheStorage, Form appWindow)
 {
     this.credentialsCacheStorage = credentialsCacheStorage;
     this.uiInvokeSynchronization = uiInvokeSynchronization;
     this.appWindow = appWindow;
 }
        public NetworkCredentialsStorage(Persistence.IStorageEntry settingsEntry)
        {
            this.settingsEntry = settingsEntry;

            Load();
        }