Beispiel #1
0
        private IDataFlowPipelineEngine CreateAndInitializePipeline()
        {
            progressUI1.Clear();

            IDataFlowPipelineEngine pipeline = null;

            try
            {
                pipeline = PipelineFactory.Create(_pipelineSelectionUI.Pipeline, fork);
            }
            catch (Exception exception)
            {
                fork.OnNotify(this, new NotifyEventArgs(ProgressEventType.Error, "Could not instantiate pipeline", exception));
                return(null);
            }


            try
            {
                pipeline.Initialize(_initializationObjects.ToArray());
            }
            catch (Exception exception)
            {
                fork.OnNotify(this, new NotifyEventArgs(ProgressEventType.Error, "Failed to Initialize pipeline", exception));
                return(null);
            }

            return(pipeline);
        }
        /// <summary>
        /// Attempts to create an instance of <see cref="IDataFlowPipelineEngine"/> described by the blueprint <paramref name="pipeline"/>.  Components are then checked if they
        /// support <see cref="ICheckable"/> using the <paramref name="checkNotifier"/> to record the results.
        /// </summary>
        /// <param name="pipeline">The blueprint to attempt to generate</param>
        /// <param name="checkNotifier">The event notifier to record how it went</param>
        /// <param name="initizationObjects">The objects available for fulfilling IPipelineRequirements</param>
        public void Check(IPipeline pipeline, ICheckNotifier checkNotifier, object[] initizationObjects)
        {
            //Try to construct the pipeline into an in memory Engine based on the in Catalogue blueprint (Pipeline)
            IDataFlowPipelineEngine dataFlowPipelineEngine = null;

            try
            {
                dataFlowPipelineEngine = Create(pipeline, new FromCheckNotifierToDataLoadEventListener(checkNotifier));
                checkNotifier.OnCheckPerformed(new CheckEventArgs("Pipeline successfully constructed in memory", CheckResult.Success));
            }
            catch (Exception exception)
            {
                checkNotifier.OnCheckPerformed(
                    new CheckEventArgs("Failed to construct pipeline, see Exception for details", CheckResult.Fail,
                                       exception));
            }

            if (initizationObjects == null)
            {
                checkNotifier.OnCheckPerformed(new CheckEventArgs("initizationObjects parameter has not been set (this is a programmer error most likely ask your developer to fix it - this parameter should be empty not null)",
                                                                  CheckResult.Fail));
                return;
            }

            //Initialize each component with the initialization objects so that they can check themselves (note that this should be preview data, hopefully the components don't run off and start nuking stuff just because they got their GO objects)
            if (dataFlowPipelineEngine != null)
            {
                try
                {
                    dataFlowPipelineEngine.Initialize(initizationObjects);
                    checkNotifier.OnCheckPerformed(
                        new CheckEventArgs(
                            "Pipeline sucesfully initialized with " +
                            initizationObjects.Length + " initialization objects",
                            CheckResult.Success));
                }
                catch (Exception exception)
                {
                    checkNotifier.OnCheckPerformed(
                        new CheckEventArgs(
                            "Pipeline initialization failed, there were " + initizationObjects.Length +
                            " objects for use in initialization (" +
                            string.Join(",", initizationObjects.Select(o => o.ToString())) + ")", CheckResult.Fail,
                            exception));
                }

                checkNotifier.OnCheckPerformed(new CheckEventArgs("About to check engine/components", CheckResult.Success));
                dataFlowPipelineEngine.Check(checkNotifier);
            }
        }
Beispiel #3
0
        public void SetTo(IPipeline pipeline, IPipelineUseCase useCase)
        {
            _useCase = useCase;

            _pipeline = pipeline;
            if (_pipeline != null)
            {
                _pipeline.ClearAllInjections();
            }

            //clear the diagram
            flpPipelineDiagram.Controls.Clear();

            pipelineSmiley.Reset();

            try
            {
                //if there is a pipeline
                if (_pipeline != null)
                {
                    try
                    {
                        _pipelineFactory = new DataFlowPipelineEngineFactory(_useCase, _pipeline);

                        //create it
                        IDataFlowPipelineEngine pipelineInstance = _pipelineFactory.Create(pipeline, new ThrowImmediatelyDataLoadEventListener());

                        //initialize it (unless it is design time)
                        if (!_useCase.IsDesignTime)
                        {
                            pipelineInstance.Initialize(_useCase.GetInitializationObjects().ToArray());
                        }
                    }
                    catch (Exception ex)
                    {
                        pipelineSmiley.Fatal(ex);
                    }

                    //There is a pipeline set but we might have been unable to fully realize it so setup stuff based on PipelineComponents

                    //was there an explicit instance?
                    if (_useCase.ExplicitSource != null)
                    {
                        AddExplicit(_useCase.ExplicitSource);//if so add it
                    }
                    else
                    //there wasn't an explicit one so there was a PipelineComponent maybe? albiet one that might be broken?
                    if (pipeline.SourcePipelineComponent_ID != null)
                    {
                        AddPipelineComponent((int)pipeline.SourcePipelineComponent_ID, DataFlowComponentVisualisation.Role.Source, pipeline.Repository);    //add the possibly broken PipelineComponent to the diagram
                    }
                    else
                    {
                        AddBlankComponent(DataFlowComponentVisualisation.Role.Source);    //the user hasn't put one in yet
                    }
                    foreach (var middleComponent in pipeline.PipelineComponents.Where(c => c.ID != pipeline.SourcePipelineComponent_ID && c.ID != pipeline.DestinationPipelineComponent_ID).OrderBy(comp => comp.Order))
                    {
                        AddPipelineComponent(middleComponent, DataFlowComponentVisualisation.Role.Middle);//add the possibly broken PipelineComponent to the diagram
                    }
                    //was there an explicit instance?
                    if (_useCase.ExplicitDestination != null)
                    {
                        AddDividerIfReorderingAvailable();
                        AddExplicit(_useCase.ExplicitDestination);//if so add it
                    }
                    else
                    //there wasn't an explicit one so there was a PipelineComponent maybe? albiet one that might be broken?
                    if (pipeline.DestinationPipelineComponent_ID != null)
                    {
                        AddPipelineComponent((int)pipeline.DestinationPipelineComponent_ID, DataFlowComponentVisualisation.Role.Destination, pipeline.Repository);    //add the possibly broken PipelineComponent to the diagram
                    }
                    else
                    {
                        AddDividerIfReorderingAvailable();
                        AddBlankComponent(DataFlowComponentVisualisation.Role.Destination);    //the user hasn't put one in yet
                    }


                    return;
                }


                //Fallback
                //user has not picked a pipeline yet, show him the shell (factory)
                //factory has no source, add empty source
                if (_useCase.ExplicitSource == null)
                {
                    AddBlankComponent(DataFlowComponentVisualisation.Role.Source);
                }
                else
                {
                    AddExplicit(_useCase.ExplicitSource);
                }


                //factory has no source, add empty source
                if (_useCase.ExplicitDestination == null)
                {
                    AddBlankComponent(DataFlowComponentVisualisation.Role.Destination);
                }
                else
                {
                    AddExplicit(_useCase.ExplicitDestination);
                }
            }
            finally
            {
                Invalidate();
            }
        }
        public void Check(ICheckNotifier notifier)
        {
            try
            {
                if (_cacheProgress.Pipeline_ID == null)
                {
                    throw new Exception("CacheProgress " + _cacheProgress.ID + " doesn't have a caching pipeline!");
                }

                IPipeline pipeline = null;
                try
                {
                    pipeline = _cacheProgress.Pipeline;
                }
                catch (Exception e)
                {
                    notifier.OnCheckPerformed(new CheckEventArgs("Error when trying to load Pipeline ID = " + _cacheProgress.Pipeline_ID.Value, CheckResult.Fail, e));
                }

                if (pipeline == null)
                {
                    notifier.OnCheckPerformed(new CheckEventArgs("Could not run Pipeline checks due to previous errors", CheckResult.Fail));
                }
                else
                {
                    var checker = new PipelineChecker(pipeline);
                    checker.Check(notifier);
                }

                if (_cacheProgress.CacheFillProgress == null && _cacheProgress.LoadProgress.OriginDate == null)
                {
                    //if we don't know what dates to request
                    notifier.OnCheckPerformed(
                        new CheckEventArgs(
                            "Both the CacheFillProgress and the LoadProgress.OriginDate are null, this means we don't know where the cache has filled up to and we don't know when the dataset is supposed to start.  This means it is impossible to know what dates to fetch",
                            CheckResult.Fail));
                }

                if (_cacheProgress.PermissionWindow_ID != null && !_cacheProgress.PermissionWindow.WithinPermissionWindow(DateTime.UtcNow))
                {
                    notifier.OnCheckPerformed(new CheckEventArgs(
                                                  "Current time is " + DateTime.UtcNow +
                                                  " which is not a permitted time according to the configured PermissionWindow " + _cacheProgress.PermissionWindow.Description +
                                                  " of the CacheProgress " + _cacheProgress,
                                                  CheckResult.Warning));
                }

                var shortfall = _cacheProgress.GetShortfall();

                if (shortfall <= TimeSpan.Zero)
                {
                    if (_cacheProgress.CacheLagPeriod == null)
                    {
                        notifier.OnCheckPerformed(
                            new CheckEventArgs(
                                "CacheProgress reports that it has loaded up till " + _cacheProgress.CacheFillProgress +
                                " which is in the future.  So we don't need to load this cache.", CheckResult.Warning));
                    }
                    else
                    {
                        notifier.OnCheckPerformed(
                            new CheckEventArgs(
                                "CacheProgress reports that it has loaded up till " + _cacheProgress.CacheFillProgress +
                                " but there is a lag period of " + _cacheProgress.CacheLagPeriod +
                                " which means we are not due to load any cached data yet.", CheckResult.Warning));
                    }
                }

                var factory = new CachingPipelineUseCase(_cacheProgress);
                IDataFlowPipelineEngine engine = null;
                try
                {
                    engine = factory.GetEngine(new FromCheckNotifierToDataLoadEventListener(notifier));
                }
                catch (Exception e)
                {
                    notifier.OnCheckPerformed(new CheckEventArgs("Could not create IDataFlowPipelineEngine", CheckResult.Fail, e));
                }

                if (engine != null)
                {
                    engine.Check(notifier);
                }
            }
            catch (Exception e)
            {
                notifier.OnCheckPerformed(
                    new CheckEventArgs(
                        "Entire checking process for cache progress " + _cacheProgress +
                        " crashed, see Exception for details", CheckResult.Fail, e));
            }
        }
 /// <summary>
 /// Describes an event happening on <paramref name="sender"/>
 /// </summary>
 /// <param name="sender"></param>
 public PipelineEngineEventArgs(IDataFlowPipelineEngine sender)
 {
     PipelineEngine = sender;
 }