use of org.apache.hadoop.yarn.api.records.YarnApplicationState in project hadoop by apache.
the class NavBlock method render.
@Override
public void render(Block html) {
boolean addErrorsAndWarningsLink = false;
Log log = LogFactory.getLog(NavBlock.class);
if (log instanceof Log4JLogger) {
Log4jWarningErrorMetricsAppender appender = Log4jWarningErrorMetricsAppender.findAppender();
if (appender != null) {
addErrorsAndWarningsLink = true;
}
}
UL<DIV<Hamlet>> mainList = html.div("#nav").h3("Cluster").ul().li().a(url("cluster"), "About")._().li().a(url("nodes"), "Nodes")._().li().a(url("nodelabels"), "Node Labels")._();
UL<LI<UL<DIV<Hamlet>>>> subAppsList = mainList.li().a(url("apps"), "Applications").ul();
subAppsList.li()._();
for (YarnApplicationState state : YarnApplicationState.values()) {
subAppsList.li().a(url("apps", state.toString()), state.toString())._();
}
subAppsList._()._();
UL<DIV<Hamlet>> tools = mainList.li().a(url("scheduler"), "Scheduler")._()._().h3("Tools").ul();
tools.li().a("/conf", "Configuration")._().li().a("/logs", "Local logs")._().li().a("/stacks", "Server stacks")._().li().a("/jmx?qry=Hadoop:*", "Server metrics")._();
if (addErrorsAndWarningsLink) {
tools.li().a(url("errors-and-warnings"), "Errors/Warnings")._();
}
tools._()._();
}
use of org.apache.hadoop.yarn.api.records.YarnApplicationState 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.YarnApplicationState in project kitten by cloudera.
the class YarnClientServiceImpl method shutDown.
@Override
protected void shutDown() {
if (finalReport != null) {
YarnApplicationState state = finalReport.getYarnApplicationState();
FinalApplicationStatus status = finalReport.getFinalApplicationStatus();
String diagnostics = finalReport.getDiagnostics();
if (YarnApplicationState.FINISHED == state) {
if (FinalApplicationStatus.SUCCEEDED == status) {
LOG.info("Application completed successfully.");
} else {
LOG.info("Application finished unsuccessfully." + " State = " + state.toString() + ", FinalStatus = " + status.toString());
}
} else if (YarnApplicationState.KILLED == state || YarnApplicationState.FAILED == state) {
LOG.info("Application did not complete successfully." + " State = " + state.toString() + ", FinalStatus = " + status.toString());
if (diagnostics != null) {
LOG.info("Diagnostics = " + diagnostics);
}
}
} else {
// Otherwise, we need to kill the application, if it was created.
if (applicationId != null) {
LOG.info("Killing application id = " + applicationId);
try {
yarnClient.killApplication(applicationId);
} catch (YarnException e) {
LOG.error("Exception thrown killing application", e);
} catch (IOException e) {
LOG.error("IOException thrown killing application", e);
}
LOG.info("Application was killed.");
}
}
}
use of org.apache.hadoop.yarn.api.records.YarnApplicationState in project hadoop by apache.
the class NotRunningJob method getJobReport.
@Override
public GetJobReportResponse getJobReport(GetJobReportRequest request) throws IOException {
JobReport jobReport = recordFactory.newRecordInstance(JobReport.class);
jobReport.setJobId(request.getJobId());
jobReport.setJobState(jobState);
jobReport.setUser(applicationReport.getUser());
jobReport.setStartTime(applicationReport.getStartTime());
YarnApplicationState state = applicationReport.getYarnApplicationState();
if (state == YarnApplicationState.KILLED || state == YarnApplicationState.FAILED || state == YarnApplicationState.FINISHED) {
jobReport.setDiagnostics(applicationReport.getDiagnostics());
}
jobReport.setJobName(applicationReport.getName());
jobReport.setTrackingUrl(applicationReport.getTrackingUrl());
jobReport.setFinishTime(applicationReport.getFinishTime());
GetJobReportResponse resp = recordFactory.newRecordInstance(GetJobReportResponse.class);
resp.setJobReport(jobReport);
return resp;
}
use of org.apache.hadoop.yarn.api.records.YarnApplicationState in project hadoop by apache.
the class YarnClientImpl method submitApplication.
@Override
public ApplicationId submitApplication(ApplicationSubmissionContext appContext) throws YarnException, IOException {
ApplicationId applicationId = appContext.getApplicationId();
if (applicationId == null) {
throw new ApplicationIdNotProvidedException("ApplicationId is not provided in ApplicationSubmissionContext");
}
SubmitApplicationRequest request = Records.newRecord(SubmitApplicationRequest.class);
request.setApplicationSubmissionContext(appContext);
// Only when the security and the timeline service are both enabled
if (isSecurityEnabled() && timelineV1ServiceEnabled) {
addTimelineDelegationToken(appContext.getAMContainerSpec());
}
//TODO: YARN-1763:Handle RM failovers during the submitApplication call.
rmClient.submitApplication(request);
int pollCount = 0;
long startTime = System.currentTimeMillis();
EnumSet<YarnApplicationState> waitingStates = EnumSet.of(YarnApplicationState.NEW, YarnApplicationState.NEW_SAVING, YarnApplicationState.SUBMITTED);
EnumSet<YarnApplicationState> failToSubmitStates = EnumSet.of(YarnApplicationState.FAILED, YarnApplicationState.KILLED);
while (true) {
try {
ApplicationReport appReport = getApplicationReport(applicationId);
YarnApplicationState state = appReport.getYarnApplicationState();
if (!waitingStates.contains(state)) {
if (failToSubmitStates.contains(state)) {
throw new YarnException("Failed to submit " + applicationId + " to YARN : " + appReport.getDiagnostics());
}
LOG.info("Submitted application " + applicationId);
break;
}
long elapsedMillis = System.currentTimeMillis() - startTime;
if (enforceAsyncAPITimeout() && elapsedMillis >= asyncApiPollTimeoutMillis) {
throw new YarnException("Timed out while waiting for application " + applicationId + " to be submitted successfully");
}
// is blocked here too long.
if (++pollCount % 10 == 0) {
LOG.info("Application submission is not finished, " + "submitted application " + applicationId + " is still in " + state);
}
try {
Thread.sleep(submitPollIntervalMillis);
} catch (InterruptedException ie) {
String msg = "Interrupted while waiting for application " + applicationId + " to be successfully submitted.";
LOG.error(msg);
throw new YarnException(msg, ie);
}
} catch (ApplicationNotFoundException ex) {
// FailOver or RM restart happens before RMStateStore saves
// ApplicationState
LOG.info("Re-submit application " + applicationId + "with the " + "same ApplicationSubmissionContext");
rmClient.submitApplication(request);
}
}
return applicationId;
}
Aggregations