Search in sources :

Example 1 with DAGNotRunningException

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;
}
Also used : TezException(org.apache.tez.dag.api.TezException) TezUncheckedException(org.apache.tez.dag.api.TezUncheckedException) DAGProtos(org.apache.tez.dag.api.records.DAGProtos) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) DAGNotRunningException(org.apache.tez.dag.api.DAGNotRunningException) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with DAGNotRunningException

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;
}
Also used : TezException(org.apache.tez.dag.api.TezException) DAGNotRunningException(org.apache.tez.dag.api.DAGNotRunningException) TezDAGID(org.apache.tez.dag.records.TezDAGID) DAG(org.apache.tez.dag.app.dag.DAG)

Aggregations

DAGNotRunningException (org.apache.tez.dag.api.DAGNotRunningException)2 TezException (org.apache.tez.dag.api.TezException)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)1 ApplicationNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException)1 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)1 TezUncheckedException (org.apache.tez.dag.api.TezUncheckedException)1 DAGProtos (org.apache.tez.dag.api.records.DAGProtos)1 DAG (org.apache.tez.dag.app.dag.DAG)1 TezDAGID (org.apache.tez.dag.records.TezDAGID)1