Search in sources :

Example 1 with AppState

use of com.tencent.angel.master.app.AppState in project angel by Tencent.

the class YarnContainerAllocator method doUnregistration.

@VisibleForTesting
protected void doUnregistration() throws YarnException, IOException, InterruptedException {
    FinalApplicationStatus finishState = FinalApplicationStatus.UNDEFINED;
    App app = context.getApp();
    // get application finish state
    AppState appState = app.getInternalState();
    if (appState == AppState.SUCCEEDED) {
        finishState = FinalApplicationStatus.SUCCEEDED;
    } else if (appState == AppState.KILLED) {
        finishState = FinalApplicationStatus.KILLED;
    } else if (appState == AppState.FAILED) {
        finishState = FinalApplicationStatus.FAILED;
    }
    // build application diagnostics
    StringBuilder sb = new StringBuilder();
    for (String s : app.getDiagnostics()) {
        sb.append(s).append("\n");
    }
    LOG.info("Setting job diagnostics to " + sb.toString());
    // TODO:add a job history for angel
    String historyUrl = "angel does not have history url now";
    // build unregister request
    FinishApplicationMasterRequest request = FinishApplicationMasterRequest.newInstance(finishState, sb.toString(), historyUrl);
    // send unregister request to rm
    while (true) {
        try {
            FinishApplicationMasterResponse response = amRmProtocol.finishApplicationMaster(request);
            if (response.getIsUnregistered()) {
                break;
            }
        } catch (Exception x) {
            LOG.error("unregister failed ", x);
            break;
        }
        LOG.info("Waiting for application to be successfully unregistered.");
        Thread.sleep(rmPollInterval);
    }
    successfullyUnregistered.set(true);
}
Also used : App(com.tencent.angel.master.app.App) AppState(com.tencent.angel.master.app.AppState) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) IOException(java.io.IOException) YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 App (com.tencent.angel.master.app.App)1 AppState (com.tencent.angel.master.app.AppState)1 IOException (java.io.IOException)1 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)1 YarnRuntimeException (org.apache.hadoop.yarn.exceptions.YarnRuntimeException)1