Beispiel #1
0
 public OperationTracker(ScreenBuffer owner, string name, CancellationToken cancellation)
 {
     this.owner        = owner;
     this.name         = name;
     this.cancellation = cancellation;
     this.perfop       = owner.CreatePerfop(name);
 }
            public LogSourcePreprocessing(
                LogSourcesPreprocessingManager owner,
                IPreprocessingUserRequests userRequests,
                Action <YieldedProvider> providerYieldedCallback,
                IEnumerable <IPreprocessingStep> initialSteps,
                string preprocessingDisplayName,
                PreprocessingOptions options) :
                this(owner, userRequests, providerYieldedCallback)
            {
                this.displayName = preprocessingDisplayName;
                this.options     = options;
                preprocLogic     = async() =>
                {
                    using (var perfop = new Profiling.Operation(trace, displayName))
                    {
                        for (var steps = new Queue <IPreprocessingStep>(initialSteps); steps.Count > 0;)
                        {
                            if (cancellation.IsCancellationRequested)
                            {
                                break;
                            }
                            IPreprocessingStep currentStep = steps.Dequeue();
                            nextSteps = steps;
                            await currentStep.Execute(this).ConfigureAwait(continueOnCapturedContext: !isLongRunning);

                            perfop.Milestone("completed " + currentStep.ToString());
                            nextSteps          = null;
                            currentDescription = genericProcessingDescription;
                        }
                    }
                };
            }
Beispiel #3
0
 public LoadingState(Context ctx, IPostprocessorRunSummary lastRunSummary, TaskCompletionSource <int> flowCompletion) : base(ctx)
 {
     this.lastRunSummary = lastRunSummary;
     this.flowCompletion = flowCompletion;
     this.task           = ctx.modelSyncContext.InvokeAndAwait(async() =>
     {
         try
         {
             using (var existingSection = ctx.owner.logSourceRecord.logSource.LogSourceSpecificStorageEntry.OpenSaxXMLSection(
                        ctx.owner.metadata.MakePostprocessorOutputFileName(),
                        Persistence.StorageSectionOpenFlag.ReadOnly))
             {
                 if (existingSection.Reader == null)
                 {
                     return(null);
                 }
                 else
                 {
                     void updateProgress(object sender, HeartBeatEventArgs e)
                     {
                         if (e.IsNormalUpdate && Math.Abs(progress - existingSection.ReadProgress) > 1e-3)
                         {
                             progress = existingSection.ReadProgress;
                             ctx.fireChangeNotification();
                         }
                     }
                     ctx.heartbeat.OnTimer += updateProgress;
                     try
                     {
                         using (var perfop = new Profiling.Operation(ctx.tracer, "load output " + ctx.owner.metadata.Kind.ToString()))
                         {
                             return(await ctx.threadPoolSyncContext.Invoke(() => ctx.outputDataDeserializer.Deserialize(ctx.owner.metadata.Kind, new LogSourcePostprocessorDeserializationParams()
                             {
                                 Reader = existingSection.Reader,
                                 LogSource = ctx.owner.logSourceRecord.logSource,
                                 Cancellation = ctx.owner.logSourceRecord.cancellation.Token
                             })));
                         }
                     }
                     finally
                     {
                         ctx.heartbeat.OnTimer -= updateProgress;
                     }
                 }
             }
         }
         finally
         {
             ctx.scheduleRefresh();
         }
     });
 }
            public LogSourcePreprocessing(
                LogSourcesPreprocessingManager owner,
                IPreprocessingUserRequests userRequests,
                Action <YieldedProvider> providerYieldedCallback,
                RecentLogEntry recentLogEntry,
                PreprocessingOptions options
                ) :
                this(owner, userRequests, providerYieldedCallback)
            {
                this.options = options;
                preprocLogic = async() =>
                {
                    IConnectionParams            preprocessedConnectParams = null;
                    IFileBasedLogProviderFactory fileBasedFactory          = recentLogEntry.Factory as IFileBasedLogProviderFactory;
                    bool interrupted = false;
                    if (fileBasedFactory != null)
                    {
                        using (var perfop = new Profiling.Operation(trace, recentLogEntry.Factory.GetUserFriendlyConnectionName(recentLogEntry.ConnectionParams)))
                        {
                            PreprocessingStepParams currentParams = null;
                            foreach (var loadedStep in LoadStepsFromConnectionParams(recentLogEntry.ConnectionParams))
                            {
                                currentParams = await ProcessLoadedStep(loadedStep, currentParams).ConfigureAwait(continueOnCapturedContext: !isLongRunning);

                                perfop.Milestone(string.Format("completed {0} {1}", loadedStep.Action, loadedStep.Param));
                                if (currentParams == null)
                                {
                                    interrupted = true;
                                    break;
                                }
                                currentDescription = genericProcessingDescription;
                            }
                            if (currentParams != null)
                            {
                                preprocessedConnectParams = fileBasedFactory.CreateParams(currentParams.Uri);
                                currentParams.DumpToConnectionParams(preprocessedConnectParams);
                            }
                        }
                    }
                    if (!interrupted)
                    {
                        var provider = new YieldedProvider(recentLogEntry.Factory, preprocessedConnectParams ?? recentLogEntry.ConnectionParams, "",
                                                           (this.options & PreprocessingOptions.MakeLogHidden) != 0);
                        ((IPreprocessingStepCallback)this).YieldLogProvider(provider);
                    }
                };
            }
            public LogSourcePreprocessing(
                LogSourcesPreprocessingManager owner,
                Action <YieldedProvider> providerYieldedCallback,
                IEnumerable <IPreprocessingStep> initialSteps,
                string preprocessingDisplayName,
                PreprocessingOptions options) :
                this(owner, providerYieldedCallback)
            {
                this.displayName = preprocessingDisplayName;
                this.options     = options;
                preprocLogic     = async() =>
                {
                    using (var perfop = new Profiling.Operation(trace, displayName))
                    {
                        for (var steps = new Queue <IPreprocessingStep>(initialSteps); ;)
                        {
                            if (cancellation.IsCancellationRequested)
                            {
                                break;
                            }
                            nextSteps = steps;
                            if (steps.Count > 0)
                            {
                                IPreprocessingStep currentStep = steps.Dequeue();
                                await currentStep.Execute(this).ConfigureAwait(continueOnCapturedContext: !isLongRunning);

                                perfop.Milestone("completed " + currentStep.ToString());
                            }
                            else
                            {
                                foreach (var e in owner.extensions.Items)
                                {
                                    await e.FinalizePreprocessing(this).ConfigureAwait(continueOnCapturedContext: !isLongRunning);
                                }
                                perfop.Milestone("notified extensions about finalization");
                                if (steps.Count == 0)
                                {
                                    break;
                                }
                            }
                            nextSteps          = null;
                            currentDescription = genericProcessingDescription;
                        }
                    }
                };
            }
Beispiel #6
0
 public PieceOfWork(int id, LJTraceSource trace)
 {
     this.id     = id;
     this.perfop = new Profiling.Operation(trace, string.Format("#{0}", id));
 }