in twill-yarn/src/main/java/org/apache/twill/yarn/YarnTwillController.java [92:134]
protected void doStartUp() {
super.doStartUp();
// Submit and poll the status of the yarn application
try {
processController = startUp.call();
YarnApplicationReport report = processController.getReport();
ApplicationId appId = report.getApplicationId();
LOG.debug("Application {} with id {} submitted", appName, appId);
YarnApplicationState state = report.getYarnApplicationState();
Stopwatch stopWatch = new Stopwatch();
stopWatch.start();
long maxTime = TimeUnit.MILLISECONDS.convert(Constants.APPLICATION_MAX_START_SECONDS, TimeUnit.SECONDS);
LOG.debug("Checking yarn application status for {} {}", appName, appId);
while (!hasRun(state) && stopWatch.elapsedTime(TimeUnit.MILLISECONDS) < maxTime) {
report = processController.getReport();
state = report.getYarnApplicationState();
LOG.debug("Yarn application status for {} {}: {}", appName, appId, state);
TimeUnit.SECONDS.sleep(1);
stopWatch.reset();
stopWatch.start();
}
LOG.info("Yarn application {} {} is in state {}", appName, appId, state);
if (state != YarnApplicationState.RUNNING) {
LOG.info("Yarn application {} {} is not in running state. Shutting down controller.",
appName, appId, Constants.APPLICATION_MAX_START_SECONDS);
forceShutDown();
} else {
try {
URL resourceUrl = URI.create(String.format("http://%s:%d", report.getHost(), report.getRpcPort()))
.resolve(TrackerService.PATH).toURL();
resourcesClient = new ResourceReportClient(resourceUrl);
} catch (IOException e) {
resourcesClient = null;
}
}
} catch (Exception e) {
throw Throwables.propagate(e);
}
}