public static void printDAGStatus(DAGClient dagClient, String[] vertexNames,
boolean displayDAGCounters, boolean displayVertexCounters)
throws IOException, TezException {
Set<StatusGetOpts> opts = EnumSet.of(StatusGetOpts.GET_COUNTERS);
DAGStatus dagStatus = dagClient.getDAGStatus(
(displayDAGCounters ? opts : null));
Progress progress = dagStatus.getDAGProgress();
double vProgressFloat = 0.0f;
if (progress != null) {
System.out.println("");
System.out.println("DAG: State: "
+ dagStatus.getState()
+ " Progress: "
+ (progress.getTotalTaskCount() < 0 ? formatter.format(0.0f) :
formatter.format((double)(progress.getSucceededTaskCount())
/progress.getTotalTaskCount())));
for (String vertexName : vertexNames) {
VertexStatus vStatus = dagClient.getVertexStatus(vertexName,
(displayVertexCounters ? opts : null));
if (vStatus == null) {
System.out.println("Could not retrieve status for vertex: "
+ vertexName);
continue;
}
Progress vProgress = vStatus.getProgress();
if (vProgress != null) {
vProgressFloat = 0.0f;
if (vProgress.getTotalTaskCount() == 0) {
vProgressFloat = 1.0f;
} else if (vProgress.getTotalTaskCount() > 0) {
vProgressFloat = (double)vProgress.getSucceededTaskCount()
/vProgress.getTotalTaskCount();
}
System.out.println("VertexStatus:"
+ " VertexName: "
+ (vertexName.equals("ivertex1") ? "intermediate-reducer"
: vertexName)
+ " Progress: " + formatter.format(vProgressFloat));
}
if (displayVertexCounters) {
TezCounters counters = vStatus.getVertexCounters();
if (counters != null) {
System.out.println("Vertex Counters for " + vertexName + ": "
+ counters);
}
}
}
}
if (displayDAGCounters) {
TezCounters counters = dagStatus.getDAGCounters();
if (counters != null) {
System.out.println("DAG Counters: " + counters);
}
}
}