use of org.apache.hadoop.yarn.api.records.YarnApplicationState in project hadoop by apache.
the class TestSubmitApplicationWithRMHA method verifySubmitApp.
private void verifySubmitApp(MockRM rm, RMApp app, ApplicationId expectedAppId) throws Exception {
int maxWaittingTimes = 20;
int count = 0;
while (true) {
YarnApplicationState state = rm.getApplicationReport(app.getApplicationId()).getYarnApplicationState();
if (!state.equals(YarnApplicationState.NEW) && !state.equals(YarnApplicationState.NEW_SAVING)) {
break;
}
if (count > maxWaittingTimes) {
break;
}
Thread.sleep(200);
count++;
}
// Verify submittion is successful
YarnApplicationState state = rm.getApplicationReport(app.getApplicationId()).getYarnApplicationState();
Assert.assertTrue(state == YarnApplicationState.ACCEPTED || state == YarnApplicationState.SUBMITTED);
Assert.assertEquals(expectedAppId, app.getApplicationId());
}
use of org.apache.hadoop.yarn.api.records.YarnApplicationState in project hadoop by apache.
the class EntityGroupFSTimelineStore method getAppState.
/**
* Ask the RM for the state of the application.
* This method has to be synchronized to control traffic to RM
* @param appId application ID
* @param yarnClient
* @return the state or {@link AppState#UNKNOWN} if it could not
* be determined
* @throws IOException
*/
private static synchronized AppState getAppState(ApplicationId appId, YarnClient yarnClient) throws IOException {
AppState appState = AppState.ACTIVE;
try {
ApplicationReport report = yarnClient.getApplicationReport(appId);
YarnApplicationState yarnState = report.getYarnApplicationState();
if (APP_FINAL_STATES.contains(yarnState)) {
appState = AppState.COMPLETED;
}
} catch (ApplicationNotFoundException e) {
appState = AppState.UNKNOWN;
} catch (YarnException e) {
throw new IOException(e);
}
return appState;
}
use of org.apache.hadoop.yarn.api.records.YarnApplicationState in project weave by continuuity.
the class YarnWeaveController method doStartUp.
@Override
protected void doStartUp() {
super.doStartUp();
// Submit and poll the status of the yarn application
try {
processController = startUp.call();
YarnApplicationReport report = processController.getReport();
LOG.debug("Application {} submit", report.getApplicationId());
YarnApplicationState state = report.getYarnApplicationState();
StopWatch stopWatch = new StopWatch();
stopWatch.start();
stopWatch.split();
long maxTime = TimeUnit.MILLISECONDS.convert(Constants.APPLICATION_MAX_START_SECONDS, TimeUnit.SECONDS);
LOG.info("Checking yarn application status");
while (!hasRun(state) && stopWatch.getSplitTime() < maxTime) {
report = processController.getReport();
state = report.getYarnApplicationState();
LOG.debug("Yarn application status: {}", state);
TimeUnit.SECONDS.sleep(1);
stopWatch.split();
}
LOG.info("Yarn application is in state {}", state);
if (state != YarnApplicationState.RUNNING) {
LOG.info("Yarn application is not in running state. Shutting down controller.", 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);
}
}
use of org.apache.hadoop.yarn.api.records.YarnApplicationState in project alluxio by Alluxio.
the class Client method monitorApplication.
/**
* Monitor the submitted application until app is running, finished, killed or failed.
*
* @throws YarnException if errors occur when obtaining application report from ResourceManager
* @throws IOException if errors occur when obtaining application report from ResourceManager
*/
private void monitorApplication() throws YarnException, IOException {
while (true) {
// Check app status every 5 seconds
CommonUtils.sleepMs(5 * Constants.SECOND_MS);
// Get application report for the appId we are interested in
ApplicationReport report = mYarnClient.getApplicationReport(mAppId);
YarnApplicationState state = report.getYarnApplicationState();
FinalApplicationStatus dsStatus = report.getFinalApplicationStatus();
switch(state) {
case RUNNING:
System.out.println("Application is running. Tracking url is " + report.getTrackingUrl());
return;
case FINISHED:
if (FinalApplicationStatus.SUCCEEDED == dsStatus) {
System.out.println("Application has completed successfully");
} else {
System.out.println("Application finished unsuccessfully. YarnState=" + state.toString() + ", DSFinalStatus=" + dsStatus.toString());
}
return;
// intended to fall through
case KILLED:
case FAILED:
System.out.println("Application did not finish. YarnState=" + state.toString() + ", DSFinalStatus=" + dsStatus.toString());
return;
default:
System.out.println("Application is in state " + state + ". Waiting.");
}
}
}
use of org.apache.hadoop.yarn.api.records.YarnApplicationState in project apex-core by apache.
the class InlineAM method monitorApplication.
/**
* Monitor the submitted application for completion. Kill application if time
* expires.
*
* @param appId
* Application Id of application to be monitored
* @return true if application completed successfully
* @throws YarnRemoteException
*/
private ApplicationReport monitorApplication(ApplicationId appId, Set<YarnApplicationState> finalState) throws YarnException, IOException {
while (true) {
// Check app status every 1 second.
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
LOG.debug("Thread sleep in monitoring loop interrupted");
}
// Get application report for the appId we are interested in
ApplicationReport report = rmClient.getApplicationReport(appId);
LOG.info("Got application report from ASM for" + ", appId=" + appId.getId() + ", appAttemptId=" + report.getCurrentApplicationAttemptId() + ", clientToken=" + 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();
if (finalState.contains(state)) {
return report;
}
}
}
Aggregations