Search in sources :

Example 1 with DAGAppMasterState

use of org.apache.tez.dag.app.DAGAppMasterState in project tez by apache.

the class TaskSchedulerManager method getFinalAppStatus.

// Not synchronized to avoid deadlocks from TaskScheduler callbacks.
// TaskScheduler uses a separate thread for it's callbacks. Since this method
// returns a value which is required, the TaskScheduler wait for the call to
// complete and can hence lead to a deadlock if called from within a TSEH lock.
public AppFinalStatus getFinalAppStatus() {
    FinalApplicationStatus finishState = FinalApplicationStatus.UNDEFINED;
    StringBuffer sb = new StringBuffer();
    if (dagAppMaster == null) {
        finishState = FinalApplicationStatus.UNDEFINED;
        sb.append("App not yet initialized");
    } else {
        DAGAppMasterState appMasterState = dagAppMaster.getState();
        if (appMasterState == DAGAppMasterState.SUCCEEDED) {
            finishState = FinalApplicationStatus.SUCCEEDED;
        } else if (appMasterState == DAGAppMasterState.KILLED || (appMasterState == DAGAppMasterState.RUNNING && isSignalled)) {
            finishState = FinalApplicationStatus.KILLED;
        } else if (appMasterState == DAGAppMasterState.FAILED || appMasterState == DAGAppMasterState.ERROR) {
            finishState = FinalApplicationStatus.FAILED;
        } else {
            finishState = FinalApplicationStatus.UNDEFINED;
        }
        finishState = hadoopShim.applyFinalApplicationStatusCorrection(finishState, dagAppMaster.isSession(), appMasterState == DAGAppMasterState.ERROR);
        List<String> diagnostics = dagAppMaster.getDiagnostics();
        if (diagnostics != null) {
            for (String s : diagnostics) {
                sb.append(s).append("\n");
            }
        }
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Setting job diagnostics to " + sb.toString());
    }
    // history url
    return new AppFinalStatus(finishState, sb.toString(), historyUrl);
}
Also used : FinalApplicationStatus(org.apache.hadoop.yarn.api.records.FinalApplicationStatus) AppFinalStatus(org.apache.tez.serviceplugins.api.TaskSchedulerContext.AppFinalStatus) DAGAppMasterState(org.apache.tez.dag.app.DAGAppMasterState)

Example 2 with DAGAppMasterState

use of org.apache.tez.dag.app.DAGAppMasterState in project tez by apache.

the class LocalClient method startDAGAppMaster.

protected void startDAGAppMaster(final ApplicationSubmissionContext appContext) throws IOException {
    if (dagAmThread == null) {
        try {
            dagAmThread = createDAGAppMaster(appContext);
            dagAmThread.start();
            // Wait until DAGAppMaster is started
            long waitingTime = 0;
            while (amFailException == null) {
                if (dagAppMaster != null) {
                    DAGAppMasterState dagAMState = dagAppMaster.getState();
                    LOG.info("DAGAppMaster state: " + dagAMState);
                    if (dagAMState.equals(DAGAppMasterState.NEW)) {
                        LOG.info("DAGAppMaster is not started wait for 100ms...");
                    } else if (dagAMState.equals(DAGAppMasterState.INITED)) {
                        LOG.info("DAGAppMaster is not startetd wait for 100ms...");
                    } else if (dagAMState.equals(DAGAppMasterState.ERROR)) {
                        throw new TezException("DAGAppMaster got an error during initialization");
                    } else if (dagAMState.equals(DAGAppMasterState.KILLED)) {
                        throw new TezException("DAGAppMaster is killed");
                    } else {
                        break;
                    }
                }
                if (waitingTime < TIME_OUT) {
                    LOG.info("DAGAppMaster is not created wait for 100ms...");
                    Thread.sleep(100);
                    waitingTime += 100;
                } else {
                    throw new TezException("Time out creating DAGAppMaster");
                }
            }
        } catch (Throwable t) {
            LOG.error("Error starting DAGAppMaster", t);
            if (dagAmThread != null) {
                dagAmThread.interrupt();
            }
            throw new IOException(t);
        }
        if (amFailException != null) {
            throw new IOException(amFailException);
        }
    }
}
Also used : TezException(org.apache.tez.dag.api.TezException) IOException(java.io.IOException) DAGAppMasterState(org.apache.tez.dag.app.DAGAppMasterState)

Aggregations

DAGAppMasterState (org.apache.tez.dag.app.DAGAppMasterState)2 IOException (java.io.IOException)1 FinalApplicationStatus (org.apache.hadoop.yarn.api.records.FinalApplicationStatus)1 TezException (org.apache.tez.dag.api.TezException)1 AppFinalStatus (org.apache.tez.serviceplugins.api.TaskSchedulerContext.AppFinalStatus)1