Source:
private boolean monitorApplication(ApplicationId appId) throws YarnException, IOException { boolean res = false; boolean needForceKill = false; while (true) { try { Thread.sleep(APP_MONITOR_INTERVAL); } catch (InterruptedException e) { LOG.warn("Thread sleep in monitoring loop interrupted"); break; } ApplicationReport report = yarnClient.getApplicationReport(appId); LOG.info("Got application report from ASM for" + ", appId=" + appId.getId() + ", clientToAMToken=" + report.getClientToAMToken() + ", appDiagnostics=" + report.getDiagnostics() + ", appMasterHost=" + report.getHost() + ", appQueue=" + report.getQueue() + ", appMasterRpcPort=" + report.getRpcPort() + ", appStartTime=" + report.getStartTime() + ", yarnAppState=" + report.getYarnApplicationState().toString() + ", distributedFinalState=" + report.getFinalApplicationStatus().toString() + ", appTrackingUrl=" + report.getTrackingUrl() + ", appUser=" + report.getUser()); YarnApplicationState state = report.getYarnApplicationState(); FinalApplicationStatus dsStatus = report.getFinalApplicationStatus(); if (YarnApplicationState.FINISHED == state) { if (FinalApplicationStatus.SUCCEEDED == dsStatus) { LOG.info("Application has completed successfully. " + "Breaking monitoring loop"); res = true; } else { LOG.info("Application did finished unsuccessfully. " + "YarnState={}, DSFinalStatus={}. Breaking monitoring loop", state.toString(), dsStatus.toString()); } break; } else if (YarnApplicationState.KILLED == state || YarnApplicationState.FAILED == state) { LOG.info("Application did not finish. YarnState={}, DSFinalStatus={}. " + "Breaking monitoring loop", state.toString(), dsStatus.toString()); break; } if (clientTimeout > 0 && System.currentTimeMillis() > (clientStartTime + clientTimeout)) { LOG.info("Reached client specified timeout for application. " + "Killing application"); needForceKill = true; break; } } if (needForceKill) { forceKillApplication(appId); } return res; }

Target:
private boolean monitorApplication(ApplicationId appId) throws YarnException, IOException { boolean res = false; boolean needForceKill = false; while (true) { try { Thread.sleep(APP_MONITOR_INTERVAL); } catch (InterruptedException e) { LOG.warn("Thread sleep in monitoring loop interrupted"); break; } ApplicationReport report = yarnClient.getApplicationReport(appId); LOG.info("Got application report from ASM for" + ", appId=" + appId.getId() + ", clientToAMToken=" + report.getClientToAMToken() + ", appDiagnostics=" + report.getDiagnostics() + ", appMasterHost=" + report.getHost() + ", appQueue=" + report.getQueue() + ", appMasterRpcPort=" + report.getRpcPort() + ", appStartTime=" + report.getStartTime() + ", yarnAppState=" + report.getYarnApplicationState().toString() + ", distributedFinalState=" + report.getFinalApplicationStatus().toString() + ", appTrackingUrl=" + report.getTrackingUrl() + ", appUser=" + report.getUser()); YarnApplicationState state = report.getYarnApplicationState(); FinalApplicationStatus dsStatus = report.getFinalApplicationStatus(); if (YarnApplicationState.FINISHED == state) { if (FinalApplicationStatus.SUCCEEDED == dsStatus) { LOG.info("Application has completed successfully. " + "Breaking monitoring loop"); res = true; } else { LOG.info("Application did finished unsuccessfully. " + "YarnState={}, DSFinalStatus={}. Breaking monitoring loop", state, dsStatus); } break; } else if (YarnApplicationState.KILLED == state || YarnApplicationState.FAILED == state) { LOG.info("Application did not finish. YarnState={}, DSFinalStatus={}. " + "Breaking monitoring loop", state, dsStatus); break; } if (clientTimeout > 0 && System.currentTimeMillis() > (clientStartTime + clientTimeout)) { LOG.info("Reached client specified timeout for application. " + "Killing application"); needForceKill = true; break; } } if (needForceKill) { forceKillApplication(appId); } return res; }