use of org.apache.tez.dag.utils.Graph in project tez by apache.
the class Utils method generateDAGVizFile.
public static void generateDAGVizFile(DagInfo dagInfo, String fileName, @Nullable List<String> criticalVertices) throws IOException {
Graph graph = new Graph(sanitizeLabelForViz(dagInfo.getName()));
for (VertexInfo v : dagInfo.getVertices()) {
String nodeLabel = sanitizeLabelForViz(v.getVertexName()) + "[" + getShortClassName(v.getProcessorClassName() + ", tasks=" + v.getTasks().size() + ", time=" + v.getTimeTaken() + " ms]");
Graph.Node n = graph.newNode(sanitizeLabelForViz(v.getVertexName()), nodeLabel);
boolean criticalVertex = (criticalVertices != null) ? criticalVertices.contains(v.getVertexName()) : false;
if (criticalVertex) {
n.setColor("red");
}
for (AdditionalInputOutputDetails input : v.getAdditionalInputInfoList()) {
Graph.Node inputNode = graph.getNode(sanitizeLabelForViz(v.getVertexName()) + "_" + sanitizeLabelForViz(input.getName()));
inputNode.setLabel(sanitizeLabelForViz(v.getVertexName()) + "[" + sanitizeLabelForViz(input.getName()) + "]");
inputNode.setShape("box");
inputNode.addEdge(n, "Input name=" + input.getName() + " [inputClass=" + getShortClassName(input.getClazz()) + ", initializer=" + getShortClassName(input.getInitializer()) + "]");
}
for (AdditionalInputOutputDetails output : v.getAdditionalOutputInfoList()) {
Graph.Node outputNode = graph.getNode(sanitizeLabelForViz(v.getVertexName()) + "_" + sanitizeLabelForViz(output.getName()));
outputNode.setLabel(sanitizeLabelForViz(v.getVertexName()) + "[" + sanitizeLabelForViz(output.getName()) + "]");
outputNode.setShape("box");
n.addEdge(outputNode, "Output name=" + output.getName() + " [outputClass=" + getShortClassName(output.getClazz()) + ", committer=" + getShortClassName(output.getInitializer()) + "]");
}
}
for (EdgeInfo e : dagInfo.getEdges()) {
Graph.Node n = graph.getNode(sanitizeLabelForViz(e.getInputVertexName()));
n.addEdge(graph.getNode(sanitizeLabelForViz(e.getOutputVertexName())), "[input=" + getShortClassName(e.getEdgeSourceClass()) + ", output=" + getShortClassName(e.getEdgeDestinationClass()) + ", dataMovement=" + e.getDataMovementType().trim() + "]");
}
graph.save(fileName);
}
use of org.apache.tez.dag.utils.Graph in project tez by apache.
the class DAGAppMaster method generateDAGVizFile.
private void generateDAGVizFile(TezDAGID dagId, DAGPlan dagPB, String[] logDirs) {
Graph graph = new Graph(sanitizeLabelForViz(dagPB.getName()));
for (VertexPlan v : dagPB.getVertexList()) {
String nodeLabel = sanitizeLabelForViz(v.getName()) + "[" + getShortClassName(v.getProcessorDescriptor().getClassName() + "]");
Graph.Node n = graph.newNode(sanitizeLabelForViz(v.getName()), nodeLabel);
for (DAGProtos.RootInputLeafOutputProto input : v.getInputsList()) {
Graph.Node inputNode = graph.getNode(sanitizeLabelForViz(v.getName()) + "_" + sanitizeLabelForViz(input.getName()));
inputNode.setLabel(sanitizeLabelForViz(v.getName()) + "[" + sanitizeLabelForViz(input.getName()) + "]");
inputNode.setShape("box");
inputNode.addEdge(n, "Input" + " [inputClass=" + getShortClassName(input.getIODescriptor().getClassName()) + ", initializer=" + getShortClassName(input.getControllerDescriptor().getClassName()) + "]");
}
for (DAGProtos.RootInputLeafOutputProto output : v.getOutputsList()) {
Graph.Node outputNode = graph.getNode(sanitizeLabelForViz(v.getName()) + "_" + sanitizeLabelForViz(output.getName()));
outputNode.setLabel(sanitizeLabelForViz(v.getName()) + "[" + sanitizeLabelForViz(output.getName()) + "]");
outputNode.setShape("box");
n.addEdge(outputNode, "Output" + " [outputClass=" + getShortClassName(output.getIODescriptor().getClassName()) + ", committer=" + getShortClassName(output.getControllerDescriptor().getClassName()) + "]");
}
}
for (DAGProtos.EdgePlan e : dagPB.getEdgeList()) {
Graph.Node n = graph.getNode(sanitizeLabelForViz(e.getInputVertexName()));
n.addEdge(graph.getNode(sanitizeLabelForViz(e.getOutputVertexName())), "[" + "input=" + getShortClassName(e.getEdgeSource().getClassName()) + ", output=" + getShortClassName(e.getEdgeDestination().getClassName()) + ", dataMovement=" + e.getDataMovementType().name().trim() + ", schedulingType=" + e.getSchedulingType().name().trim() + "]");
}
String outputFile = "";
if (logDirs != null && logDirs.length != 0) {
outputFile += logDirs[0];
outputFile += File.separator;
}
outputFile += dagId.toString() + ".dot";
try {
LOG.info("Generating DAG graphviz file" + ", dagId=" + dagId.toString() + ", filePath=" + outputFile);
graph.save(outputFile);
} catch (Exception e) {
LOG.warn("Error occurred when trying to save graph structure" + " for dag " + dagId.toString(), e);
}
}
Aggregations