public Maintenance(IActive active, IParser parser, IPersister persister, ILogger logger) { _parser = parser ?? throw new ArgumentNullException(nameof(parser)); _active = active ?? throw new ArgumentNullException(nameof(active)); _persister = persister ?? throw new ArgumentNullException(nameof(persister)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
/// <summary> /// Constructor. /// </summary> /// <param name="logger"></param> /// <param name="paths"></param> public Directory(ILogger logger, List<string> paths ) { // The logger _logger = logger ?? throw new ArgumentNullException(nameof(logger)); // The path _paths = paths ?? throw new ArgumentNullException(nameof(paths)); }
public SqlitePersisterWords(IPerformance performance, IWordsParts wordsParts, int maxNumCharactersPerWords, ILogger logger) { // the maximum word len _maxNumCharactersPerWords = maxNumCharactersPerWords; // the words parts interfaces _wordsParts = wordsParts ?? throw new ArgumentNullException(nameof(wordsParts)); // save the logger _logger = logger ?? throw new ArgumentNullException(nameof(logger)); // create the counter, _counterAddOrUpdate = new SqlPerformanceCounter(performance, "Database: Add Or Update word", _logger); }
public Parser(interfaces.Configs.IConfig config, IPersister persister, ILogger logger, IDirectory directory) { // set the config values. _config = config ?? throw new ArgumentNullException(nameof(config)); // set the persister. _persister = persister ?? throw new ArgumentNullException(nameof(persister)); // save the logger _logger = logger ?? throw new ArgumentNullException(nameof(logger)); // save the directory parser _directory = directory ?? throw new ArgumentNullException(nameof(directory)); }
public Processor( IList <IFileParser> fileParsers, IProcessors processorsConfig, ITimers timersConfig, IMaintenance maintenanceConfig, IParser parser, IPersister persister, ILogger logger, IDirectory directory, IPerformance performance ) { // save the logger _logger = logger ?? throw new ArgumentNullException(nameof(logger)); const string directoryCounterName = "Processor: Average time processing Directories"; const string fileCounterName = "Processor: Average time processing Files"; const string parserCounterName = "Processor: Average time parsing files/folders"; // Create the various processors, they will not start doing anything just yet // or at least, they shouldn't var directoriesCounter = new ProcessorPerformanceCounter(performance, directoryCounterName, logger); var filesCounter = new ProcessorPerformanceCounter(performance, fileCounterName, logger); var parserCounter = new ProcessorPerformanceCounter(performance, parserCounterName, logger); _eventTimer = new ProcessorTimer( new List <IProcessor> { new Folders(directoriesCounter, processorsConfig.UpdatesFolderPerEvent, persister, logger, directory, timersConfig.EventsMaxWaitTransactionMs), new Files(filesCounter, processorsConfig.UpdatesFilesPerEvent, fileParsers, processorsConfig.IgnoreFiles, persister, logger, directory, timersConfig.EventsMaxWaitTransactionMs) }, _logger, processorsConfig.EventsProcessorMs); _maintenanceTimer = new ProcessorTimer( new List <IProcessor> { new Maintenance(maintenanceConfig.Active, parser, persister, logger) }, _logger, (int)TimeSpan.FromMinutes(processorsConfig.MaintenanceProcessorMinutes).TotalMilliseconds); _parserTimer = new ProcessorTimer( new List <IProcessor> { new Parser(parserCounter, parser, logger) }, _logger, (int)TimeSpan.FromMinutes(processorsConfig.ParserProcessorMinutes).TotalMilliseconds); }
/// <summary> /// Make sure that we have a valid category. /// </summary> /// <param name="counter"></param> /// <param name="logger"></param> public void Initialise(Counter counter, ILogger logger) { // we will need to re-create all the counters... DisposeAllCounters(); // enter the lock so we can create the counter. lock (Lock) { // build the collection data var counterCreationDataCollection = BuildCollectionData(counter); // if the category does not exist, try and create it. if (!PerformanceCounterCategory.Exists(counter.CategoryName)) { PerformanceCounterCategory.Create(counter.CategoryName, counter.CategoryHelp, PerformanceCounterCategoryType.SingleInstance, counterCreationDataCollection); logger.Information($"Created performance category: {counter.CategoryName} for counter: {counter.Name}"); return; } if (PerformanceCounterCategory.CounterExists(counter.Name, counter.CategoryName)) { return; } var category = PerformanceCounterCategory.GetCategories() .First(cat => cat.CategoryName == counter.CategoryName); var counters = category.GetCounters(); foreach (var c in counters) { counterCreationDataCollection.Add(new CounterCreationData(c.CounterName, c.CounterHelp, c.CounterType)); } PerformanceCounterCategory.Delete(counter.CategoryName); PerformanceCounterCategory.Create(counter.CategoryName, counter.CategoryHelp, PerformanceCounterCategoryType.SingleInstance, counterCreationDataCollection); logger.Information($"Updated performance category: {counter.CategoryName} for counter: {counter.Name}"); } }
public SqlitePersister(IPerformance performance, IList <IFileParser> parsers, ILogger logger, ConfigSqliteDatabase config, int maxNumCharactersPerWords, int maxNumCharactersPerParts ) { // save the logger _logger = logger ?? throw new ArgumentNullException(nameof(logger)); // performance _performance = performance ?? throw new ArgumentNullException(nameof(performance)); // the configuration _config = config ?? throw new ArgumentNullException(nameof(config)); // create the configuration table. Config = new SqlitePersisterConfig(); // create the counters Counts = new SqlitePersisterCounts(logger); // word parts WordsParts = new SqlitePersisterWordsParts(logger); // create the words Words = new SqlitePersisterWords(performance, WordsParts, maxNumCharactersPerWords, logger); // file words. FilesWords = new SqlitePersisterFilesWords(Words, logger); // create the files / Folders. Folders = new SqlitePersisterFolders(Counts, parsers, logger); // the parts Parts = new SqlitePersisterParts(maxNumCharactersPerParts); // the query Query = new SqlitePersisterQuery(maxNumCharactersPerParts, logger); }
public TransactionsManager(IPerformance performance, ILogger logger) { _counterBegin = new TransactionPerformanceCounter(performance, "Database: Begin", logger); _counterCommit = new TransactionPerformanceCounter(performance, "Database: Commit", logger); _counterRollback = new TransactionPerformanceCounter(performance, "Database: Rollback", logger); }
/// <summary> /// Return a performance counter, making sure that the category is created properly. /// </summary> /// <param name="categoryName"></param> /// <param name="categoryHelp"></param> /// <param name="counterName"></param> /// <param name="type"></param> /// <param name="logger"></param> /// <returns></returns> protected Counter(string categoryName, string categoryHelp, string counterName, Type type, ILogger logger) { CategoryName = categoryName; CategoryHelp = categoryHelp; // save the counter name Name = counterName ?? throw new ArgumentNullException(nameof(counterName)); // save the performance type. Type = type; // initialise it. Manager.Instance.Initialise(this, logger); }
public SqlPerformanceCounter(IPerformance performance, string counterName, ILogger logger) : base(performance.CategoryName, performance.CategoryHelp, counterName, helper.Performance.Type.Timed, logger) { }