Example #1
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);
        }
Example #2
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());
        }
Example #3
0
        private static Dictionary <TimeSpan, IExecutableCommand> PlanRegularTasks(IMergeStatisticsChainFactory mergeStatisticsChainFactory, IDateTimeSelectorsProvider dateTimeSelectors)
        {
            var regularTasks = new Dictionary <TimeSpan, IExecutableCommand>();

            regularTasks.Add(new TimeSpan(1, 0, 0), new ActionCommand(() =>
            {
                DateTime now  = DateTime.Now;
                DateTime from = now.AddDays(-7);
                DateTime to   = now.AddDays(-9);
                MergeStatistics(from, to, dateTimeSelectors.HourSelector);
                return(true);
            }));
            regularTasks.Add(new TimeSpan(2, 0, 0), new ActionCommand(() =>
            {
                DateTime now  = DateTime.Now;
                DateTime from = now.AddDays(-14);
                DateTime to   = now.AddDays(-16);
                MergeStatistics(from, to, dateTimeSelectors.DaySelector);
                return(true);
            }));
            #region void MergeStatistics(DateTime from, DateTime to, IDateTimeSelector dateTimeSelector)
            void MergeStatistics(DateTime from, DateTime to, IDateTimeSelector dateTimeSelector)
            {
                ParallelCommandStepsCreator parallelSteps = new ParallelCommandStepsCreator();

                parallelSteps.AddParallelStep(mergeStatisticsChainFactory.MergeStatisticsChain(new MergeNormalizedStatementStatisticsContext()
                {
                    CreatedDateFrom  = from,
                    CreatedDateTo    = to,
                    DateTimeSelector = dateTimeSelector
                }).AsChainableCommand());
                parallelSteps.AddParallelStep(mergeStatisticsChainFactory.MergeStatisticsChain(new MergeNormalizedStatementRelationStatisticsContext()
                {
                    CreatedDateFrom  = from,
                    CreatedDateTo    = to,
                    DateTimeSelector = dateTimeSelector
                }).AsChainableCommand());
                parallelSteps.AddParallelStep(mergeStatisticsChainFactory.MergeStatisticsChain(new MergeNormalizedStatementIndexStatisticsContext()
                {
                    CreatedDateFrom  = from,
                    CreatedDateTo    = to,
                    DateTimeSelector = dateTimeSelector
                }).AsChainableCommand());
                parallelSteps.AddParallelStep(mergeStatisticsChainFactory.MergeStatisticsChain(new MergeTotalRelationStatisticsContext()
                {
                    CreatedDateFrom  = from,
                    CreatedDateTo    = to,
                    DateTimeSelector = dateTimeSelector
                }).AsChainableCommand());
                parallelSteps.AddParallelStep(mergeStatisticsChainFactory.MergeStatisticsChain(new MergeTotalIndexStatisticsContext()
                {
                    CreatedDateFrom  = from,
                    CreatedDateTo    = to,
                    DateTimeSelector = dateTimeSelector
                }).AsChainableCommand());
                parallelSteps.AddParallelStep(mergeStatisticsChainFactory.MergeStatisticsChain(new MergeTotalStoredProcedureStatisticsContext()
                {
                    CreatedDateFrom  = from,
                    CreatedDateTo    = to,
                    DateTimeSelector = dateTimeSelector
                }).AsChainableCommand());
                parallelSteps.AddParallelStep(mergeStatisticsChainFactory.MergeStatisticsChain(new MergeTotalViewStatisticsContext()
                {
                    CreatedDateFrom  = from,
                    CreatedDateTo    = to,
                    DateTimeSelector = dateTimeSelector
                }).AsChainableCommand());
                parallelSteps.CreateParallelCommand().Execute();
            }

            #endregion
            return(regularTasks);
        }