Matcher m = sanitizeLabelPattern.matcher(label);
return m.replaceAll("_");
}
private void generateDAGVizFile(TezDAGID dagId, DAGPlan dagPB) {
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())
+ ", initializer=" + 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 logDirs = System.getenv(Environment.LOG_DIRS.name());
String outputFile = "";
if (logDirs != null && !logDirs.isEmpty()) {
int pos = logDirs.indexOf(",");
if (pos != -1) {
outputFile += logDirs.substring(0, pos);
} else {
outputFile += logDirs;
}
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);
}
}