use of org.apache.hadoop.yarn.api.records.ApplicationReport in project kitten by cloudera.
the class KittenClient method handle.
public int handle(YarnClientService service) throws Exception {
service.startAndWait();
if (!service.isRunning()) {
LOG.error("Service failed to startup, exiting...");
return 1;
}
String trackingUrl = null;
while (service.isRunning()) {
if (trackingUrl == null) {
Thread.sleep(1000);
ApplicationReport report = service.getApplicationReport();
YarnApplicationState yarnAppState = report.getYarnApplicationState();
if (yarnAppState == YarnApplicationState.RUNNING) {
trackingUrl = report.getTrackingUrl();
if (trackingUrl == null || trackingUrl.isEmpty()) {
LOG.info("Application is running, but did not specify a tracking URL");
trackingUrl = "";
} else {
LOG.info("Master Tracking URL = " + trackingUrl);
}
}
}
}
LOG.info("Checking final app report");
ApplicationReport report = service.getFinalReport();
if (report == null || report.getFinalApplicationStatus() != FinalApplicationStatus.SUCCEEDED) {
return 1;
}
LOG.info("Kitten client finishing...");
return 0;
}
use of org.apache.hadoop.yarn.api.records.ApplicationReport in project kitten by cloudera.
the class YarnClientServiceImpl method runOneIteration.
@Override
protected void runOneIteration() throws Exception {
if (isApplicationFinished()) {
LOG.info("Nothing to do, application is finished");
return;
}
ApplicationReport report = getApplicationReport();
if (report == null) {
LOG.error("No application report received");
} else if (DONE.contains(report.getYarnApplicationState()) || report.getFinalApplicationStatus() != FinalApplicationStatus.UNDEFINED) {
finalReport = report;
stop();
}
// Ensure that we haven't been running for all that long.
if (parameters.getClientTimeoutMillis() > 0 && stopwatch.elapsedMillis() > parameters.getClientTimeoutMillis()) {
LOG.warn("Stopping application due to timeout.");
timeout = true;
stop();
}
}
use of org.apache.hadoop.yarn.api.records.ApplicationReport in project jstorm by alibaba.
the class JstormOnYarn 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 YarnException
* @throws IOException
*/
private boolean monitorApplication(ApplicationId appId) throws YarnException, IOException {
Integer monitorTimes = JOYConstants.MONITOR_TIMES;
while (true) {
// Check app status every 1 second.
try {
Thread.sleep(JOYConstants.MONITOR_TIME_INTERVAL);
} catch (InterruptedException e) {
LOG.debug("Thread sleep in monitoring loop interrupted");
}
// Get application report for the appId we are interested in
ApplicationReport report = jstormClientContext.yarnClient.getApplicationReport(appId);
try {
File writename = new File(JOYConstants.RPC_ADDRESS_FILE);
writename.createNewFile();
BufferedWriter out = new BufferedWriter(new FileWriter(writename));
out.write(report.getHost() + JOYConstants.NEW_LINE);
out.write(report.getRpcPort() + JOYConstants.NEW_LINE);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
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");
return true;
} else {
LOG.info("Application did finished unsuccessfully." + " YarnState=" + state.toString() + ", DSFinalStatus=" + dsStatus.toString() + ". Breaking monitoring loop");
return false;
}
} else if (YarnApplicationState.KILLED == state || YarnApplicationState.FAILED == state) {
LOG.info("Application did not finish." + " YarnState=" + state.toString() + ", DSFinalStatus=" + dsStatus.toString() + ". Breaking monitoring loop");
return false;
} else if (YarnApplicationState.RUNNING == state) {
LOG.info("Application is running successfully. Breaking monitoring loop");
return true;
} else {
if (monitorTimes-- <= 0) {
forceKillApplication(appId);
return false;
}
}
}
}
use of org.apache.hadoop.yarn.api.records.ApplicationReport in project hadoop by apache.
the class ApplicationHistoryClientService method getApplications.
@Override
public GetApplicationsResponse getApplications(GetApplicationsRequest request) throws YarnException, IOException {
long startedBegin = request.getStartRange() == null ? 0L : request.getStartRange().getMinimumLong();
long startedEnd = request.getStartRange() == null ? Long.MAX_VALUE : request.getStartRange().getMaximumLong();
GetApplicationsResponse response = GetApplicationsResponse.newInstance(new ArrayList<ApplicationReport>(history.getApplications(request.getLimit(), startedBegin, startedEnd).values()));
return response;
}
use of org.apache.hadoop.yarn.api.records.ApplicationReport in project hadoop by apache.
the class ApplicationHistoryManagerOnTimelineStore method getApplications.
@Override
public Map<ApplicationId, ApplicationReport> getApplications(long appsNum, long appStartedTimeBegin, long appStartedTimeEnd) throws YarnException, IOException {
TimelineEntities entities = timelineDataManager.getEntities(ApplicationMetricsConstants.ENTITY_TYPE, null, null, appStartedTimeBegin, appStartedTimeEnd, null, null, appsNum == Long.MAX_VALUE ? this.maxLoadedApplications : appsNum, EnumSet.allOf(Field.class), UserGroupInformation.getLoginUser());
Map<ApplicationId, ApplicationReport> apps = new LinkedHashMap<ApplicationId, ApplicationReport>();
if (entities != null && entities.getEntities() != null) {
for (TimelineEntity entity : entities.getEntities()) {
try {
ApplicationReportExt app = generateApplicationReport(entity, ApplicationReportField.ALL);
apps.put(app.appReport.getApplicationId(), app.appReport);
} catch (Exception e) {
LOG.error("Error on generating application report for " + entity.getEntityId(), e);
}
}
}
return apps;
}
Aggregations