in tez-api/src/main/java/org/apache/tez/client/TezClient.java [467:514]
public TezAppMasterStatus getAppMasterStatus() throws TezException, IOException {
// Supporting per-DAG app master case since user may choose to run the same
// code in that mode and the code should continue to work. Its easy to provide
// the correct view for per-DAG app master too.
ApplicationId appId = null;
if (isSession) {
appId = sessionAppId;
} else {
appId = lastSubmittedAppId;
}
Preconditions.checkState(appId != null, "Cannot get status without starting an application");
try {
ApplicationReport appReport = yarnClient.getApplicationReport(
appId);
switch (appReport.getYarnApplicationState()) {
case NEW:
case NEW_SAVING:
case ACCEPTED:
case SUBMITTED:
return TezAppMasterStatus.INITIALIZING;
case FINISHED:
case FAILED:
case KILLED:
return TezAppMasterStatus.SHUTDOWN;
case RUNNING:
if (!isSession) {
return TezAppMasterStatus.RUNNING;
}
try {
DAGClientAMProtocolBlockingPB proxy = getSessionAMProxy(appId);
if (proxy == null) {
return TezAppMasterStatus.INITIALIZING;
}
GetAMStatusResponseProto response = proxy.getAMStatus(null,
GetAMStatusRequestProto.newBuilder().build());
return DagTypeConverters.convertTezSessionStatusFromProto(
response.getStatus());
} catch (TezException e) {
LOG.info("Failed to retrieve AM Status via proxy", e);
} catch (ServiceException e) {
LOG.info("Failed to retrieve AM Status via proxy", e);
}
}
} catch (YarnException e) {
throw new TezException(e);
}
return TezAppMasterStatus.INITIALIZING;
}