Example #1
0
        /// <summary>
        /// Compute the layouts for the job plans.
        /// </summary>
        private void CreatePlanLayouts()
        {
            if (this.staticPlan == null)
            {
                this.comboBox_plan.Items.Remove("Static");
            }

            this.Status("Constructing dynamic plan", StatusKind.LongOp);
            this.dynamicPlanLayout = this.Job.ComputePlanLayout(this.Status);
            if (this.dynamicPlanLayout == null)
            {
                this.comboBox_plan.Items.Remove("Dynamic");
            }

            this.Status("Constructing job schedule", StatusKind.LongOp);
            try
            {
                this.jobSchedule = new DryadLinqJobSchedule(this.Job, this.HideCancelledVertices);
            }
            catch (Exception e)
            {
                Trace.TraceInformation("Exception while building job schedule: " + e.Message);
                this.jobSchedule = null;
            }
// ReSharper disable CompareOfFloatsByEqualityOperator
            if (this.jobSchedule == null || this.jobSchedule.X == 0 || this.jobSchedule.Y == 0)
// ReSharper restore CompareOfFloatsByEqualityOperator
            {
                // degenerate plan, nothing to draw
                this.jobSchedule = null;
                this.comboBox_plan.Items.Remove("Schedule");
            }
            this.Status("Job plans constructed", StatusKind.OK);
            this.plansHaveBeenBuilt = true;
        }
Example #2
0
        /// <summary>
        /// Generate a layout suitable for drawing the plan.
        /// </summary>
        /// <returns>A graph layout.</returns>
        /// <param name="statusReporter">Delegate used to report errors.</param>
        // ReSharper disable once UnusedParameter.Global
        public GraphLayout ComputePlanLayout(StatusReporter statusReporter) 
        {
            IEnumerable<DryadLinqJobStage> stages = this.AllStages().OrderBy(s => s.StartTime).ToList();
            if (!stages.Any())
                // no layout to compute
                return null;

            DateTime jobStartTime = this.StartJMTime;
            DateTime lastTime = stages.Max(s => s.EndTime);
            if (lastTime == jobStartTime)
                // avoid the degenerate case
                lastTime = jobStartTime + new TimeSpan(0, 0, 1);

            GraphLayout result = new GraphLayout((lastTime - jobStartTime).TotalSeconds, stages.Count()*2);

            int currentStage = 0;
            foreach (DryadLinqJobStage s in stages)
            {
                // node represents the schedule: horizontal position is starttime - endtime
                DateTime endTime = s.EndTime;
                DateTime startTime = s.StartTime;
                if (endTime <= jobStartTime) // unknown time?
                    endTime = lastTime;      // assume still running
                if (startTime <= jobStartTime)
                    startTime = jobStartTime;
                GraphLayout.GraphNode node = new GraphLayout.GraphNode(
                    (startTime - jobStartTime).TotalSeconds, currentStage*2, (endTime - startTime).TotalSeconds, 1);
                node.Shape = GraphLayout.GraphNode.NodeShape.Box;
                node.Label = s.Name;
                node.Stage = s.Name;

                result.Add(node);
                currentStage++;
            }

            return result;
        }