private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            var entries       = groupBox.Provide();
            var lastTimestamp = lastProcessedEvidence.Provide();

            foreach (var entry in entries)
            {
                if (entry.Timestamp >= lastTimestamp)
                {
                    LogEntryProcessingContext context = new LogEntryProcessingContext();
                    context.Entry = entry;
                    queue.Enqueue(chainFactory.LogEntryProcessingChain(context));
                    lastProcessedEvidence.Publish(entry.Timestamp);
                    entriesCounter++;
                }
                else
                {
                    // already processed
                }
            }
            DateTime now = DateTime.Now;

            if (entriesCounter >= PERSISTENCE_THRESHOLD_ENTRIES_COUNT || (now - lastStatePersistenceDate).TotalSeconds >= PERSISTENCE_THRESHOLD_ELAPSED_SECONDS)
            {
                InitiatePersistence();
                entriesCounter           = 0;
                lastStatePersistenceDate = now;
            }
        }
Пример #2
0
 public LoadDatabaseInfoForLogEntryCommand(ILog log, LogEntryProcessingContext context, IDatabasesRepository databasesRepository,
                                           DAL.Contracts.ISettingPropertiesRepository settingPropertiesRepository)
 {
     this.log                         = log;
     this.context                     = context;
     this.databasesRepository         = databasesRepository;
     this.settingPropertiesRepository = settingPropertiesRepository;
 }
Пример #3
0
        private IChainableCommand CreateViewStatisticsProcessingChain(LogEntryProcessingContext context)
        {
            CommandChainCreator chain = new CommandChainCreator();

            chain.Add(new ActionCommand(() => context.DatabaseCollectingConfiguration.IsEnabledGeneralCollection));
            chain.Add(statisticsProcessingCommands.EnqueueCommand());
            chain.Add(statisticsProcessingCommands.PublishTotalViewStatisticsCommand(context));
            return(chain.AsChainableCommand());
        }
        public IChainableCommand LoadQueryPlanToContextCommand(LogEntryProcessingContext context)
        {
            LogEntryProcessingWrapperContext wrapperContext = new LogEntryProcessingWrapperContext();

            wrapperContext.InnerContext = context;
            var chain = new CommandChainCreator();

            chain.Add(new LoadDebugTreesToContextCommand(() => context.Entry.PlanTrees, () => wrapperContext.QueryPlans));
            chain.Add(new LoadQueryPlansToContextCommand(wrapperContext));
            return(chain.AsChainableCommand());
        }
Пример #5
0
        public IExecutableCommand LogEntryProcessingChain(LogEntryProcessingContext context)
        {
            ParallelCommandStepsCreator parallelSteps = new ParallelCommandStepsCreator();

            parallelSteps.AddParallelStep(CreateStatementProcessingChain(context));
            parallelSteps.AddParallelStep(CreateViewStatisticsProcessingChain(context));

            CommandChainCreator chain = new CommandChainCreator();

            chain.Add(generalCommands.LoadDatabaseInfoForLogEntryCommand(context));
            chain.Add(parallelSteps.CreateParallelCommand());

            return(chain.FirstCommand);
        }
Пример #6
0
        private IChainableCommand CreateStatementProcessingChain(LogEntryProcessingContext context)
        {
            CommandChainCreator chain = new CommandChainCreator();

            chain.Add(new ActionCommand(() => context.DatabaseCollectingConfiguration.IsEnabledStatementCollection));
            chain.Add(new ActionCommand(() =>
            {
                generalCommands.ExternalStatementNormalizationCommand(context).Execute();
                if (string.IsNullOrEmpty(context.StatementData.NormalizedStatement))
                {
                    externalCommands.NormalizeStatementCommand(log, context).Execute();
                }
                return(!string.IsNullOrEmpty(context.StatementData.NormalizedStatement));
            }));
            chain.Add(generalCommands.ComputeNormalizedStatementFingerprintCommand(context));
            chain.Add(generalCommands.PublishNormalizedStatementCommand(context));


            ParallelCommandStepsCreator parallelSteps = new ParallelCommandStepsCreator();

            CommandChainCreator queryTreeProcessingChain = new CommandChainCreator();

            queryTreeProcessingChain.Add(externalCommands.LoadQueryTreeToContextCommand(context));
            queryTreeProcessingChain.Add(generalCommands.PublishNormalizedStatementDefinitionCommand(context));
            parallelSteps.AddParallelStep(queryTreeProcessingChain.AsChainableCommand());

            CommandChainCreator queryPlanProcessingChain = new CommandChainCreator();

            queryPlanProcessingChain.Add(externalCommands.LoadQueryPlanToContextCommand(context));
            queryPlanProcessingChain.Add(generalCommands.PublishNormalizedStatementIndexStatisticsCommand(context));
            queryPlanProcessingChain.Add(generalCommands.PublishNormalizedStatementRelationStatisticsCommand(context));
            parallelSteps.AddParallelStep(queryPlanProcessingChain.AsChainableCommand());

            chain.Add(parallelSteps.CreateParallelCommand());
            chain.Add(generalCommands.PublishNormalizedStatementStatisticsCommand(context));
            return(chain.AsChainableCommand());
        }
 public PublishNormalizedStatementCommand(LogEntryProcessingContext context, IStatementsProcessingDataAccumulator statementDataAccumulator)
 {
     this.context = context;
     this.statementDataAccumulator = statementDataAccumulator;
 }
 public IChainableCommand NormalizeStatementCommand(ILog log, LogEntryProcessingContext context)
 {
     return(new NormalizeStatementCommand(log, context));
 }
 public ComputeNormalizedStatementFingerprintCommand(LogEntryProcessingContext context)
 {
     this.context = context;
 }
 public IgnoreOwnLogEntriesCommand(LogEntryProcessingContext context)
 {
     this.context = context;
 }
 public NormalizeStatementCommand(ILog log, LogEntryProcessingContext context)
 {
     this.log     = log;
     this.context = context;
 }
Пример #12
0
 public IChainableCommand PublishNormalizedStatementRelationStatisticsCommand(LogEntryProcessingContext context)
 {
     return(new PublishNormalizedStatementRelationStatisticsCommand(context, statementDataAccumulator));
 }
Пример #13
0
 public IChainableCommand LoadDatabaseInfoForLogEntryCommand(LogEntryProcessingContext context)
 {
     return(new LoadDatabaseInfoForLogEntryCommand(log, context, dbmsRepositories.GetDatabasesRepository(), dalRepositories.GetSettingPropertiesRepository()));
 }
Пример #14
0
 public IChainableCommand ExternalStatementNormalizationCommand(LogEntryProcessingContext context)
 {
     return(new ExternalStatementNormalizationCommand(log, configuration.ExternalSqlNormalization, context));
 }
Пример #15
0
 public IChainableCommand ComputeNormalizedStatementFingerprintCommand(LogEntryProcessingContext context)
 {
     return(new ComputeNormalizedStatementFingerprintCommand(context));
 }
Пример #16
0
 public ExternalStatementNormalizationCommand(ILog log, IExternalSqlNormalizationConfiguration externalNormalizationConfig, LogEntryProcessingContext context)
 {
     this.log = log;
     this.externalNormalizationConfig = externalNormalizationConfig;
     this.context = context;
 }