static void Main(string[] args)
        {
            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
            var configuration = new ConfigurationBuilder()
                                .AddJsonFile("appsettings.json")
                                .Build();
            var appSettings = configuration.Get <AppSettings>();
            var log         = Common.Logging.NLog.NLog.Instace;

            NLog.LogManager.LoadConfiguration("nlog.config");
            var queue                          = new CommandProcessingQueue <IExecutableCommand>(log, "ProcessingQueue");
            var dalRepositories                = DAL.RepositoriesFactory.Instance;
            var dbmsRepositories               = DBMS.Postgres.RepositoriesFactory.Instance;
            var dbSystemInfo                   = dbmsRepositories.GetDatabaseSystemInfoRepository().LoadInfo();
            var toSqlValueStringConverter      = new DBMS.Postgres.ToSqlValueStringConverter();
            var dbObjectDefinitionGenerator    = new DBMS.Postgres.DbObjectDefinitionGenerator(dbSystemInfo.SupportsIncludeInIndices, toSqlValueStringConverter);
            var attributeHPartitioningDesigner = new AttributeHPartitioningDesigner(dbSystemInfo.SupportsHashHPartitioning);
            var commandFactory                 = new CommandFactory(log, appSettings, dalRepositories, dbmsRepositories, dbObjectDefinitionGenerator, toSqlValueStringConverter, attributeHPartitioningDesigner);
            var chainFactory                   = new CommandChainFactory(commandFactory);
            var requestsLoader                 = new AnalysisRequestsLoader(log, queue, dalRepositories.GetWorkloadAnalysesRepository(), chainFactory);

            requestsLoader.Start();
            Console.WriteLine("Analyzer is running. Press any key to exit...");
            Console.ReadLine();
            requestsLoader.Stop();
            requestsLoader.Dispose();
            queue.Dispose();
        }
Example #2
0
        static void Main(string[] args)
        {
            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
            var configuration = new ConfigurationBuilder()
                                .AddJsonFile("appsettings.json")
                                .Build();
            var appSettings = configuration.Get <AppSettings>();

            var log = Common.Logging.NLog.NLog.Instace;

            NLog.LogManager.LoadConfiguration("nlog.config");
            var collectorConfiguration      = new CollectorConfiguration(appSettings);
            var logProcessor                = new Postgres.LogProcessor(collectorConfiguration.LogProcessing);
            var logEntryGroupBox            = new Postgres.LogEntryGroupBox();
            var oneFileProcessor            = new FileProcessor(log, collectorConfiguration.LogProcessing, logProcessor, logEntryGroupBox);
            var continuousFileProcessor     = new ContinuousFileProcessor(log, collectorConfiguration.LogProcessing, logProcessor, logEntryGroupBox);
            var logProcessingService        = new LogProcessingService(collectorConfiguration.LogProcessing, oneFileProcessor, continuousFileProcessor);
            var logEntriesProcessingQueue   = new CommandProcessingQueue <IExecutableCommand>(log, "LogEntriesProcessingQueue");
            var statisticsProcessingQueue   = new CommandProcessingQueue <IExecutableCommand>(log, "StatisticsProcessingQueue");
            var dateTimeSelectors           = DateTimeSelectorsProvider.Instance;
            var statementDataAccumulator    = new StatementsProcessingDataAccumulator(dateTimeSelectors.MinuteSelector);
            var statisticsDataAccumulator   = new StatisticsProcessingDataAccumulator(dateTimeSelectors.MinuteSelector, CacheProvider.Instance.MemoryCache);
            var postgresRepositories        = DBMS.Postgres.RepositoriesFactory.Instance;
            var dalRepositories             = RepositoriesFactory.Instance;
            var lastProcessedEvidence       = new LastProcessedLogEntryEvidence(log, dalRepositories.GetSettingPropertiesRepository());
            var dependencyHierarchyProvider = new DatabaseDependencyHierarchyProvider(log, new Postgres.DatabaseDependencyHierarchyBuilder(log, postgresRepositories), postgresRepositories.GetDatabasesRepository());
            var generalCommands             = new GeneralProcessingCommandFactory(log, collectorConfiguration, statementDataAccumulator, postgresRepositories,
                                                                                  dalRepositories, lastProcessedEvidence);
            var externalCommands               = new Postgres.LogEntryProcessingCommandFactory(postgresRepositories);
            var statisticsCommands             = new StatisticsProcessingCommandFactory(log, statisticsProcessingQueue, statisticsDataAccumulator, postgresRepositories, dalRepositories, dependencyHierarchyProvider);
            var logEntryProcessingChainFactory = new LogEntryProcessingChainFactory(log, generalCommands, statisticsCommands, externalCommands, dalRepositories);
            var statisticsChainFactory         = new StatisticsProcessingChainFactory(statisticsCommands);
            var logEntryProcessingService      = new LogEntryProcessingService(logEntryGroupBox, logEntriesProcessingQueue, logEntryProcessingChainFactory, lastProcessedEvidence);
            var statisticsCollectorService     = new StatisticsCollectorService(statisticsProcessingQueue, statisticsChainFactory);

            var mergeStatisticsCommands     = new MergeStatisticsCommandFactory(dalRepositories);
            var mergeStatisticsChainFactory = new MergeStatisticsChainFactory(mergeStatisticsCommands);
            var regularTasks  = PlanRegularTasks(mergeStatisticsChainFactory, dateTimeSelectors);
            var taskScheduler = new RegularTaskScheduler(statisticsProcessingQueue, regularTasks);

            statisticsCollectorService.Start();
            logProcessingService.Start();
            logEntryProcessingService.Start();
            taskScheduler.Start();
            Console.WriteLine("Collector is running. Press any key to exit...");
            Console.ReadLine();
            dependencyHierarchyProvider.Dispose();
            taskScheduler.Dispose();
            logProcessingService.Dispose();
            continuousFileProcessor.Dispose();
            logEntryGroupBox.Dispose();
            logEntryProcessingService.Dispose();
            statisticsCollectorService.Dispose();
            logEntriesProcessingQueue.Dispose();
            statisticsProcessingQueue.Dispose();
        }
Example #3
0
        static void Main(string[] args)
        {
            var log              = Common.Logging.NLog.NLog.Instace;
            var queue            = new CommandProcessingQueue <IExecutableCommand>(log, "ProcessingQueue");
            var dalRepositories  = DAL.RepositoriesFactory.Instance;
            var dbmsRepositories = DBMS.Postgres.RepositoriesFactory.Instance;
            var razorEngine      = new RazorEngine();
            var commands         = new CommandFactory(log, dalRepositories, dbmsRepositories, razorEngine);
            var chains           = new CommandChainFactory(commands);
            var regularTasks     = PlanRegularTasks(chains);
            var taskScheduler    = new RegularTaskScheduler(queue, regularTasks);

            taskScheduler.Start();
            Console.WriteLine("ReportingService is running. Type in S to immediately send current report. Type in any other key to exit...");
            bool canQuit = false;

            do
            {
                var line = (Console.ReadLine() ?? "").ToLower();
                if (line == "s")
                {
                    DateTime now     = DateTime.Now;
                    var      context = new ReportContextWithModel <SummaryEmailModel>();
                    context.DateFromInclusive = now.AddDays(-1);
                    context.DateToExclusive   = now;
                    context.TemplateId        = DAL.Contracts.SettingPropertyKeys.EMAIL_TEMPLATE_SUMMARY_REPORT;
                    try
                    {
                        chains.SummaryReportChain(context).Execute();
                        Console.WriteLine("Current report sent.");
                    }
                    catch (Exception ex)
                    {
                        Console.Write(ex);
                    }
                    canQuit = false;
                }
                else
                {
                    canQuit = true;
                }
            } while (!canQuit);
            taskScheduler.Stop();
            taskScheduler.Dispose();
            queue.Dispose();
            razorEngine.Dispose();
        }