Ejemplo n.º 1
0
        public void Activate()
        {
            if (activated)
            {
                return;
            }

            Logging.Progress("Activating Computation");

            activated = true;

            this.Reachability.UpdateReachabilityPartialOrder(this);

            this.MaterializeAll();

            this.Controller.DoStartupBarrier();

            this.currentState = InternalComputationState.Active;

            this.Controller.Workers.WakeUp();

            foreach (var streamingInput in this.streamingInputs)
            {
                streamingInput.Activate();
            }

            this.NotifyOnStartup();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Blocks until all computation is complete and resources are released.
        /// </summary>
        public void Join()
        {
            if (this.CurrentState == InternalComputationState.Inactive)
            {
                throw new Exception("Joining graph manager before calling Activate()");
            }
            else
            {
                if (this.DomainReporting)
                {
                    foreach (var input in this.streamingInputs)
                    {
                        input.Join();
                    }

                    var largestRealInputEpoch = this.inputs.Max(x => x.CurrentEpoch);
                    Logging.Info("Largest real epoch " + largestRealInputEpoch + " current stats " + RootDomainStatisticsStage.CurrentEpoch);
                    while (this.RootDomainStatisticsStage.CurrentEpoch < largestRealInputEpoch)
                    {
                        this.RootDomainStatisticsStage.OnNext(new string[] { });
                    }
                    Logging.Info("New stats " + RootDomainStatisticsStage.CurrentEpoch);
                    // wait until all real inputs have drained (possibly generating new logging)
                    if (largestRealInputEpoch > 0)
                    {
                        Logging.Info("Syncing stats " + (largestRealInputEpoch - 1));
                        this.Sync(largestRealInputEpoch - 1);
                    }
                    // now shut down the reporting
                    Console.WriteLine("Calling reporting completed");
                    this.RootDomainStatisticsStage.OnCompleted();
                }
                else
                {
                    foreach (var input in this.streamingInputs)
                    {
                        input.Join();
                    }
                }

                // wait for all progress updates to drain.
                // this.ProgressTracker.BlockUntilComplete();
                this.ShutdownCounter.Wait();

                if (this.exception != null)
                {
                    throw new Exception("Error during Naiad execution", this.exception);
                }

                NotifyOnShutdown();

                this.isJoined     = true;
                this.currentState = InternalComputationState.Complete;
            }
        }