/// <summary> /// Terminates the logging sub-systems. /// </summary> public void Stop() { if (!IsRunning) { throw new InvalidOperationException("The LogController has not been started."); } IsRunning = false; // // stop cache monitor thread if (_InternalThreadWorker.IsRunning) { // wait for thread to finish; do not cancel while (_InternalThreadWorker.IsRunning) { Threading.ThreadingHelper.Sleep(5); } } _InternalThreadWorker.Stop(); _InternalThreadWorker = null; // stop the log marshal LogMarshal.Close(); // get final statistics InternalGetStatistics(); LogMarshal = null; }
public LogControllerThreadWorker(LogMarshal logMarshal, LogControllerSettings logSettings, Logging.ILogStatistics logStats, FileStorage.IFileStore archiveFileStore, IArchiveFilenameFactory archiveFilenameFactory) { _LogMarshal = logMarshal; _LogSettings = logSettings; _LogStats = logStats; _ArchiveFileStore = archiveFileStore; _ArchiveFilenameFactory = archiveFilenameFactory; }
/// <summary> /// Initializes a component. /// </summary> /// <param name="logMarshal">The <see cref="LogMarshal"/> provided by the <see cref="LogController"/>.</param> /// <param name="communicationController">The <see cref="ICommunicationController"/> used by this component to create <see cref="Networking.IClient"/>s.</param> /// <param name="logSourceId">The value used as the source id when creating log entries.</param> public void Initialize(LogMarshal logMarshal, ICommunicationController communicationController, string logSourceId) { _LogMarshal = logMarshal ?? throw new ArgumentNullException(nameof(logMarshal)); _CommunicationController = communicationController ?? throw new ArgumentNullException(nameof(communicationController)); if (string.IsNullOrWhiteSpace(logSourceId)) { throw new ArgumentNullException(nameof(logSourceId)); } _LogSourceId = logSourceId; }
/// <summary> /// Initializes and engages the logging sub-systems. /// </summary> public void Start() { if (IsRunning) { throw new InvalidOperationException("The LogController has already been started."); } // create/open LogMarshal LogMarshal = new LogMarshal(_Log, Settings); LogMarshal.Open(); _FinalStatistics = null; // create/start cache flush and archive monitor thread _InternalThreadWorker = new LogControllerThreadWorker(LogMarshal, Settings, _ArchiveStatistics, _LogArchiveFileStore, _ArchiveFilenameFactory); _InternalThreadWorker.Start(); // IsRunning = true; StartTime = DateTimeOffset.Now; }
/// <summary> /// Prepares the component to be handled by the <see cref="ComponentController"/>. /// </summary> /// <param name="logMarshal">The <see cref="LogMarshal"/> provided by the <see cref="LogController"/>.</param> /// <param name="client">The <see cref="Networking.IClient"/> made for this component.</param> /// <param name="workingClient">A <see cref="Networking.IClient"/> made for temporary, unrestricted, communications. This client is not opened by default and should be closed when not being used.</param> /// <param name="logSourceId">The value used as the source id when creating log entries.</param> /// <param name="networkLogSourceId">The value used as the source id when creating network specific log entries.</param> /// <param name="packageConfiguration">The <see cref="Packaging.IPackageConfiguration"/> for the package this component was located in.</param> /// <param name="customConfiguration">The custom configuration, if found; otherwise, null.</param> /// <param name="installRootPath">The root path where the <see cref="Installation.IInstaller"/> installs packages.</param> /// <param name="installPath">The install directory path where this component's package has been installed.</param> /// <param name="temporaryPath">A temporary folder for the <see cref="IComponent"/> to use.</param> /// <param name="longTermStoragePath">A permanent folder for the <see cref="IComponent"/> to use.</param> /// <param name="folderAccessItems">A collection of folders.</param> public void Initialize(LogMarshal logMarshal, Networking.IClient client, Networking.IClient workingClient, string logSourceId, string networkLogSourceId, Packaging.IPackageConfiguration packageConfiguration, Configuration.IConfigurationGroup customConfiguration, string installRootPath, string installPath, string temporaryPath, string longTermStoragePath, IFolderAccessItems folderAccessItems) { _LogMarshal = logMarshal ?? throw new ArgumentNullException(nameof(logMarshal)); Client = client ?? throw new ArgumentNullException(nameof(client)); WorkingClient = workingClient ?? throw new ArgumentNullException(nameof(workingClient)); if (Client.ClientConfiguration.ReceivableTypesFilter.Count() > 0) { // add required message types to receivable message types filter var list = new List <Networking.IPayloadTypeInfo>(Client.ClientConfiguration.ReceivableTypesFilter); list.Add(new Networking.PayloadTypeInfo(typeof(SupportsComponentDesignationRequest))); Client.ClientConfiguration.ReplaceReceivableTypesFilter(list); } // if (string.IsNullOrWhiteSpace(logSourceId)) { throw new ArgumentNullException(nameof(logSourceId)); } LogSourceId = logSourceId; // if (string.IsNullOrWhiteSpace(networkLogSourceId)) { throw new ArgumentNullException(nameof(networkLogSourceId)); } _NetworkLogSourceId = networkLogSourceId; // PackageConfiguration = packageConfiguration ?? throw new ArgumentNullException(nameof(packageConfiguration)); CustomConfiguration = customConfiguration; // if (string.IsNullOrWhiteSpace(installRootPath)) { throw new ArgumentNullException(nameof(installRootPath)); } InstallRootPath = installRootPath; // if (string.IsNullOrWhiteSpace(installPath)) { throw new ArgumentNullException(nameof(installPath)); } InstallPath = installPath; // if (string.IsNullOrWhiteSpace(temporaryPath)) { throw new ArgumentNullException(nameof(temporaryPath)); } TemporaryPath = temporaryPath; // if (string.IsNullOrWhiteSpace(longTermStoragePath)) { throw new ArgumentNullException(nameof(longTermStoragePath)); } LongTermStoragePath = longTermStoragePath; // FolderAccessItems = folderAccessItems ?? throw new ArgumentNullException(nameof(folderAccessItems)); }