use of org.apache.tez.dag.api.DAGNotRunningException in project tez by apache.
the class DAGClientImpl method getDAGStatusViaRM.
/**
* Get the DAG status via the YARN ResourceManager
* @return the dag status, inferred from the RM App state. Does not return null.
* @throws TezException
* @throws IOException
*/
@VisibleForTesting
protected DAGStatus getDAGStatusViaRM() throws TezException, IOException {
if (LOG.isDebugEnabled()) {
LOG.debug("GetDAGStatus via AM for app: " + appId + " dag:" + dagId);
}
ApplicationReport appReport;
try {
appReport = frameworkClient.getApplicationReport(appId);
} catch (ApplicationNotFoundException e) {
LOG.info("DAG is no longer running - application not found by YARN", e);
throw new DAGNotRunningException(e);
} catch (YarnException e) {
throw new TezException(e);
}
if (appReport == null) {
throw new TezException("Unknown/Invalid appId: " + appId);
}
DAGProtos.DAGStatusProto.Builder builder = DAGProtos.DAGStatusProto.newBuilder();
DAGStatus dagStatus = new DAGStatus(builder, DagStatusSource.RM);
DAGProtos.DAGStatusStateProto dagState;
switch(appReport.getYarnApplicationState()) {
case NEW:
case NEW_SAVING:
case SUBMITTED:
case ACCEPTED:
dagState = DAGProtos.DAGStatusStateProto.DAG_SUBMITTED;
break;
case RUNNING:
dagState = DAGProtos.DAGStatusStateProto.DAG_RUNNING;
break;
case FAILED:
dagState = DAGProtos.DAGStatusStateProto.DAG_FAILED;
break;
case KILLED:
dagState = DAGProtos.DAGStatusStateProto.DAG_KILLED;
break;
case FINISHED:
switch(appReport.getFinalApplicationStatus()) {
case UNDEFINED:
case FAILED:
dagState = DAGProtos.DAGStatusStateProto.DAG_FAILED;
break;
case KILLED:
dagState = DAGProtos.DAGStatusStateProto.DAG_KILLED;
break;
case SUCCEEDED:
dagState = DAGProtos.DAGStatusStateProto.DAG_SUCCEEDED;
break;
default:
throw new TezUncheckedException("Encountered unknown final application" + " status from YARN" + ", appState=" + appReport.getYarnApplicationState() + ", finalStatus=" + appReport.getFinalApplicationStatus());
}
break;
default:
throw new TezUncheckedException("Encountered unknown application state" + " from YARN, appState=" + appReport.getYarnApplicationState());
}
builder.setState(dagState);
// workaround before YARN-2560 is fixed
if (appReport.getFinalApplicationStatus() == FinalApplicationStatus.FAILED || appReport.getFinalApplicationStatus() == FinalApplicationStatus.KILLED) {
long startTime = System.currentTimeMillis();
while ((appReport.getDiagnostics() == null || appReport.getDiagnostics().isEmpty()) && (System.currentTimeMillis() - startTime) < diagnoticsWaitTimeout) {
try {
Thread.sleep(100);
appReport = frameworkClient.getApplicationReport(appId);
} catch (YarnException e) {
throw new TezException(e);
} catch (InterruptedException e) {
throw new TezException(e);
}
}
}
if (appReport.getDiagnostics() != null) {
builder.addAllDiagnostics(Collections.singleton(appReport.getDiagnostics()));
}
return dagStatus;
}
use of org.apache.tez.dag.api.DAGNotRunningException in project tez by apache.
the class DAGClientHandler method getDAG.
DAG getDAG(String dagIdStr) throws TezException {
TezDAGID dagId;
try {
dagId = TezDAGID.fromString(dagIdStr);
} catch (IllegalArgumentException e) {
throw new TezException("Bad dagId: " + dagIdStr, e);
}
DAG currentDAG = getCurrentDAG();
if (currentDAG == null) {
throw new TezException("No running dag at present");
}
final String currentDAGIdStr = currentDAG.getID().toString();
if (!currentDAGIdStr.equals(dagIdStr)) {
if (getAllDagIDs().contains(dagIdStr)) {
if (LOG.isDebugEnabled()) {
LOG.debug("Looking for finished dagId " + dagIdStr + " current dag is " + currentDAGIdStr);
}
throw new DAGNotRunningException("DAG " + dagIdStr + " Not running, current dag is " + currentDAGIdStr);
} else {
LOG.warn("Current DAGID : " + currentDAGIdStr + ", Looking for string (not found): " + dagIdStr + ", dagIdObj: " + dagId);
throw new TezException("Unknown dagId: " + dagIdStr);
}
}
return currentDAG;
}
Aggregations