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);
}
Aggregations