Search in sources :

Example 21 with YarnApplicationState

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._()._();
}
Also used : DIV(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV) Log(org.apache.commons.logging.Log) Log4JLogger(org.apache.commons.logging.impl.Log4JLogger) Log4jWarningErrorMetricsAppender(org.apache.hadoop.yarn.util.Log4jWarningErrorMetricsAppender) YarnApplicationState(org.apache.hadoop.yarn.api.records.YarnApplicationState) LI(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.LI)

Example 22 with YarnApplicationState

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;
}
Also used : ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) YarnApplicationState(org.apache.hadoop.yarn.api.records.YarnApplicationState)

Example 23 with YarnApplicationState

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.");
        }
    }
}
Also used : FinalApplicationStatus(org.apache.hadoop.yarn.api.records.FinalApplicationStatus) YarnApplicationState(org.apache.hadoop.yarn.api.records.YarnApplicationState) IOException(java.io.IOException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException)

Example 24 with YarnApplicationState

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;
}
Also used : YarnApplicationState(org.apache.hadoop.yarn.api.records.YarnApplicationState) JobReport(org.apache.hadoop.mapreduce.v2.api.records.JobReport) GetJobReportResponse(org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetJobReportResponse)

Example 25 with YarnApplicationState

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;
}
Also used : ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) YarnApplicationState(org.apache.hadoop.yarn.api.records.YarnApplicationState) ApplicationIdNotProvidedException(org.apache.hadoop.yarn.exceptions.ApplicationIdNotProvidedException) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) SubmitApplicationRequest(org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest) YarnException(org.apache.hadoop.yarn.exceptions.YarnException)

Aggregations

YarnApplicationState (org.apache.hadoop.yarn.api.records.YarnApplicationState)41 ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)27 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)14 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)11 IOException (java.io.IOException)10 FinalApplicationStatus (org.apache.hadoop.yarn.api.records.FinalApplicationStatus)8 HashSet (java.util.HashSet)7 ApplicationSubmissionContext (org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext)7 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)6 ArrayList (java.util.ArrayList)5 ContainerLaunchContext (org.apache.hadoop.yarn.api.records.ContainerLaunchContext)5 YarnClient (org.apache.hadoop.yarn.client.api.YarnClient)5 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)5 Test (org.junit.Test)5 Path (org.apache.hadoop.fs.Path)4 Resource (org.apache.hadoop.yarn.api.records.Resource)4 YarnClientApplication (org.apache.hadoop.yarn.client.api.YarnClientApplication)4 File (java.io.File)3 HashMap (java.util.HashMap)3 FileSystem (org.apache.hadoop.fs.FileSystem)3