return _waitForCompletionWithStatusUpdates(true, statusGetOpts);
}
private DAGStatus _waitForCompletionWithStatusUpdates(boolean vertexUpdates,
@Nullable Set<StatusGetOpts> statusGetOpts) throws IOException, TezException, InterruptedException {
DAGStatus dagStatus;
boolean initPrinted = false;
boolean runningPrinted = false;
double dagProgress = -1.0; // Print the first one
// monitoring
while (true) {
dagStatus = getDAGStatus(statusGetOpts);
if (!initPrinted
&& (dagStatus.getState() == DAGStatus.State.INITING || dagStatus.getState() == DAGStatus.State.SUBMITTED)) {
initPrinted = true; // Print once
log("Waiting for DAG to start running");
}
if (dagStatus.getState() == DAGStatus.State.RUNNING
|| dagStatus.getState() == DAGStatus.State.SUCCEEDED
|| dagStatus.getState() == DAGStatus.State.FAILED
|| dagStatus.getState() == DAGStatus.State.KILLED
|| dagStatus.getState() == DAGStatus.State.ERROR) {
break;
}
Thread.sleep(SLEEP_FOR_COMPLETION);
}// End of while(true)
Set<String> vertexNames = Collections.emptySet();
while (!dagStatus.isCompleted()) {
if (!runningPrinted) {
log("DAG initialized: CurrentState=Running");
runningPrinted = true;
}
if (vertexUpdates && vertexNames.isEmpty()) {
vertexNames = getDAGStatus(statusGetOpts).getVertexProgress().keySet();
}
dagProgress = monitorProgress(vertexNames, dagProgress, null, dagStatus);
Thread.sleep(SLEEP_FOR_COMPLETION);
dagStatus = getDAGStatus(statusGetOpts);
}// end of while
// Always print the last status irrespective of progress change
monitorProgress(vertexNames, -1.0, statusGetOpts, dagStatus);
log("DAG completed. " + "FinalState=" + dagStatus.getState());
return dagStatus;
}