Search in sources :

Example 1 with AdditionalInputOutputDetails

use of org.apache.tez.history.parser.datamodel.AdditionalInputOutputDetails 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);
}
Also used : Graph(org.apache.tez.dag.utils.Graph) AdditionalInputOutputDetails(org.apache.tez.history.parser.datamodel.AdditionalInputOutputDetails) VertexInfo(org.apache.tez.history.parser.datamodel.VertexInfo) EdgeInfo(org.apache.tez.history.parser.datamodel.EdgeInfo)

Aggregations

Graph (org.apache.tez.dag.utils.Graph)1 AdditionalInputOutputDetails (org.apache.tez.history.parser.datamodel.AdditionalInputOutputDetails)1 EdgeInfo (org.apache.tez.history.parser.datamodel.EdgeInfo)1 VertexInfo (org.apache.tez.history.parser.datamodel.VertexInfo)1