/// <summary> /// Continuation for refreshing the query plan. /// </summary> private void PlanComputed(bool cancelled, DryadJobStaticPlan plan) { if (cancelled) return; this.staticPlan = plan; if (this.staticPlan != null) { this.staticPlan.AddFictitiousStages(); this.staticGraph = this.BuildAGLGraph(); } this.CreatePlanLayouts(); this.AssignPlanColors(); if (this.planVisible != PlanVisible.Static) this.FitPlanToWindow(); this.DrawQueryPlan(); }
/// <summary> /// Build an AGL graph corresponding to a dryadlinq job static plan. /// </summary> /// <returns>An AGL graph.</returns> private static Msagl.Drawing.Graph BuildAGLGraph(DryadJobStaticPlan plan) { Msagl.Drawing.Graph retval = new Msagl.Drawing.Graph(); foreach (DryadJobStaticPlan.Stage stage in plan.GetAllStages()) { Msagl.Drawing.Node node = new Msagl.Drawing.Node(stage.Id.ToString()); node.UserData = stage; if (stage.IsVirtual) { if (stage.IsTee) node.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Octagon; else node.Attr.Shape = Msagl.Drawing.Shape.InvHouse; } else { if (stage.Name == "JobManager") { node.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Diamond; } else if (stage.Name == "All vertices") node.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Box; else node.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Ellipse; } string nodeName = stage.Name; if (stage.IsInput || stage.IsOutput) { nodeName = string.Join(",", nodeName.Split(',').Select(Path.GetFileName).ToArray()); nodeName = Path.GetFileName(nodeName); const int maxNodeNameLen = 40; if (nodeName.Length > maxNodeNameLen) { nodeName = nodeName.Substring(0, maxNodeNameLen / 2) + "..." + nodeName.Substring(nodeName.Length - maxNodeNameLen / 2); } } if (stage.Replication != 1) node.LabelText = stage.Replication + " x " + nodeName; else node.LabelText = nodeName; retval.AddNode(node); } foreach (DryadJobStaticPlan.Connection connection in plan.GetAllConnections()) { Msagl.Drawing.Edge e = retval.AddEdge(connection.From.Id.ToString(), connection.To.Id.ToString()); if (connection.Arity == DryadJobStaticPlan.Connection.ConnectionType.AllToAll) e.Attr.LineWidth = 3; if (connection.ConnectionManager != "None") e.LabelText = connection.ConnectionManager; e.Attr.Color = FormColorToAglColor(System.Drawing.Color.FromName(connection.Color())); e.UserData = connection; } return retval; }