Search in sources :

Example 1 with ResponseInfo

use of org.apache.hadoop.yarn.webapp.ResponseInfo in project hadoop by apache.

the class TestCommonViews method testInfoBlock.

@Test
public void testInfoBlock() {
    Injector injector = WebAppTests.createMockInjector(this);
    ResponseInfo info = injector.getInstance(ResponseInfo.class);
}
Also used : ResponseInfo(org.apache.hadoop.yarn.webapp.ResponseInfo) Injector(com.google.inject.Injector) Test(org.junit.Test)

Example 2 with ResponseInfo

use of org.apache.hadoop.yarn.webapp.ResponseInfo in project hadoop by apache.

the class HsJobBlock method render.

/*
   * (non-Javadoc)
   * @see org.apache.hadoop.yarn.webapp.view.HtmlBlock#render(org.apache.hadoop.yarn.webapp.view.HtmlBlock.Block)
   */
@Override
protected void render(Block html) {
    String jid = $(JOB_ID);
    if (jid.isEmpty()) {
        html.p()._("Sorry, can't do anything without a JobID.")._();
        return;
    }
    JobId jobID = MRApps.toJobID(jid);
    Job j = appContext.getJob(jobID);
    if (j == null) {
        html.p()._("Sorry, ", jid, " not found.")._();
        return;
    }
    if (j instanceof UnparsedJob) {
        final int taskCount = j.getTotalMaps() + j.getTotalReduces();
        UnparsedJob oversizedJob = (UnparsedJob) j;
        html.p()._("The job has a total of " + taskCount + " tasks. ")._("Any job larger than " + oversizedJob.getMaxTasksAllowed() + " will not be loaded.")._();
        html.p()._("You can either use the CLI tool: 'mapred job -history'" + " to view large jobs or adjust the property " + JHAdminConfig.MR_HS_LOADED_JOBS_TASKS_MAX + ".")._();
        return;
    }
    List<AMInfo> amInfos = j.getAMInfos();
    JobInfo job = new JobInfo(j);
    ResponseInfo infoBlock = info("Job Overview")._("Job Name:", job.getName())._("User Name:", job.getUserName())._("Queue:", job.getQueueName())._("State:", job.getState())._("Uberized:", job.isUber())._("Submitted:", new Date(job.getSubmitTime()))._("Started:", job.getStartTimeStr())._("Finished:", new Date(job.getFinishTime()))._("Elapsed:", StringUtils.formatTime(Times.elapsed(job.getStartTime(), job.getFinishTime(), false)));
    String amString = amInfos.size() == 1 ? "ApplicationMaster" : "ApplicationMasters";
    // todo - switch to use JobInfo
    List<String> diagnostics = j.getDiagnostics();
    if (diagnostics != null && !diagnostics.isEmpty()) {
        StringBuffer b = new StringBuffer();
        for (String diag : diagnostics) {
            b.append(addTaskLinks(diag));
        }
        infoBlock._r("Diagnostics:", b.toString());
    }
    if (job.getNumMaps() > 0) {
        infoBlock._("Average Map Time", StringUtils.formatTime(job.getAvgMapTime()));
    }
    if (job.getNumReduces() > 0) {
        infoBlock._("Average Shuffle Time", StringUtils.formatTime(job.getAvgShuffleTime()));
        infoBlock._("Average Merge Time", StringUtils.formatTime(job.getAvgMergeTime()));
        infoBlock._("Average Reduce Time", StringUtils.formatTime(job.getAvgReduceTime()));
    }
    for (ConfEntryInfo entry : job.getAcls()) {
        infoBlock._("ACL " + entry.getName() + ":", entry.getValue());
    }
    DIV<Hamlet> div = html._(InfoBlock.class).div(_INFO_WRAP);
    // MRAppMasters Table
    TABLE<DIV<Hamlet>> table = div.table("#job");
    table.tr().th(amString)._().tr().th(_TH, "Attempt Number").th(_TH, "Start Time").th(_TH, "Node").th(_TH, "Logs")._();
    boolean odd = false;
    for (AMInfo amInfo : amInfos) {
        AMAttemptInfo attempt = new AMAttemptInfo(amInfo, job.getId(), job.getUserName(), "", "");
        table.tr((odd = !odd) ? _ODD : _EVEN).td(String.valueOf(attempt.getAttemptId())).td(new Date(attempt.getStartTime()).toString()).td().a(".nodelink", url(MRWebAppUtil.getYARNWebappScheme(), attempt.getNodeHttpAddress()), attempt.getNodeHttpAddress())._().td().a(".logslink", url(attempt.getLogsLink()), "logs")._()._();
    }
    table._();
    div._();
    html.div(_INFO_WRAP).table("#job").tr().th(_TH, "Task Type").th(_TH, "Total").th(_TH, "Complete")._().tr(_ODD).th().a(url("tasks", jid, "m"), "Map")._().td(String.valueOf(String.valueOf(job.getMapsTotal()))).td(String.valueOf(String.valueOf(job.getMapsCompleted())))._().tr(_EVEN).th().a(url("tasks", jid, "r"), "Reduce")._().td(String.valueOf(String.valueOf(job.getReducesTotal()))).td(String.valueOf(String.valueOf(job.getReducesCompleted())))._()._().table("#job").tr().th(_TH, "Attempt Type").th(_TH, "Failed").th(_TH, "Killed").th(_TH, "Successful")._().tr(_ODD).th("Maps").td().a(url("attempts", jid, "m", TaskAttemptStateUI.FAILED.toString()), String.valueOf(job.getFailedMapAttempts()))._().td().a(url("attempts", jid, "m", TaskAttemptStateUI.KILLED.toString()), String.valueOf(job.getKilledMapAttempts()))._().td().a(url("attempts", jid, "m", TaskAttemptStateUI.SUCCESSFUL.toString()), String.valueOf(job.getSuccessfulMapAttempts()))._()._().tr(_EVEN).th("Reduces").td().a(url("attempts", jid, "r", TaskAttemptStateUI.FAILED.toString()), String.valueOf(job.getFailedReduceAttempts()))._().td().a(url("attempts", jid, "r", TaskAttemptStateUI.KILLED.toString()), String.valueOf(job.getKilledReduceAttempts()))._().td().a(url("attempts", jid, "r", TaskAttemptStateUI.SUCCESSFUL.toString()), String.valueOf(job.getSuccessfulReduceAttempts()))._()._()._()._();
}
Also used : ResponseInfo(org.apache.hadoop.yarn.webapp.ResponseInfo) InfoBlock(org.apache.hadoop.yarn.webapp.view.InfoBlock) Hamlet(org.apache.hadoop.yarn.webapp.hamlet.Hamlet) Date(java.util.Date) ConfEntryInfo(org.apache.hadoop.mapreduce.v2.app.webapp.dao.ConfEntryInfo) AMInfo(org.apache.hadoop.mapreduce.v2.api.records.AMInfo) DIV(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV) UnparsedJob(org.apache.hadoop.mapreduce.v2.hs.UnparsedJob) JobInfo(org.apache.hadoop.mapreduce.v2.hs.webapp.dao.JobInfo) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) UnparsedJob(org.apache.hadoop.mapreduce.v2.hs.UnparsedJob) JobId(org.apache.hadoop.mapreduce.v2.api.records.JobId) AMAttemptInfo(org.apache.hadoop.mapreduce.v2.hs.webapp.dao.AMAttemptInfo)

Example 3 with ResponseInfo

use of org.apache.hadoop.yarn.webapp.ResponseInfo in project hadoop by apache.

the class AppBlock method generateOverviewTable.

/**
   * Generate overview table for app web page.
   * @param app app info.
   * @param schedulerPath schedule path.
   * @param webUiType web ui type.
   * @param appReport app report.
   */
private void generateOverviewTable(AppInfo app, String schedulerPath, String webUiType, ApplicationReport appReport) {
    ResponseInfo overviewTable = info("Application Overview")._("User:", schedulerPath, app.getUser())._("Name:", app.getName())._("Application Type:", app.getType())._("Application Tags:", app.getApplicationTags() == null ? "" : app.getApplicationTags())._("Application Priority:", clarifyAppPriority(app.getPriority()))._("YarnApplicationState:", app.getAppState() == null ? UNAVAILABLE : clarifyAppState(app.getAppState()))._("Queue:", schedulerPath, app.getQueue())._("FinalStatus Reported by AM:", clairfyAppFinalStatus(app.getFinalAppStatus()))._("Started:", Times.format(app.getStartedTime()))._("Elapsed:", StringUtils.formatTime(Times.elapsed(app.getStartedTime(), app.getFinishedTime())))._("Tracking URL:", app.getTrackingUrl() == null || app.getTrackingUrl().equals(UNAVAILABLE) ? null : root_url(app.getTrackingUrl()), app.getTrackingUrl() == null || app.getTrackingUrl().equals(UNAVAILABLE) ? "Unassigned" : app.getAppState() == YarnApplicationState.FINISHED || app.getAppState() == YarnApplicationState.FAILED || app.getAppState() == YarnApplicationState.KILLED ? "History" : "ApplicationMaster");
    if (webUiType != null && webUiType.equals(YarnWebParams.RM_WEB_UI)) {
        LogAggregationStatus status = getLogAggregationStatus();
        if (status == null) {
            overviewTable._("Log Aggregation Status:", "N/A");
        } else if (status == LogAggregationStatus.DISABLED || status == LogAggregationStatus.NOT_START || status == LogAggregationStatus.SUCCEEDED) {
            overviewTable._("Log Aggregation Status:", status.name());
        } else {
            overviewTable._("Log Aggregation Status:", root_url("logaggregationstatus", app.getAppId()), status.name());
        }
        long timeout = appReport.getApplicationTimeouts().get(ApplicationTimeoutType.LIFETIME).getRemainingTime();
        if (timeout < 0) {
            overviewTable._("Application Timeout (Remaining Time):", "Unlimited");
        } else {
            overviewTable._("Application Timeout (Remaining Time):", String.format("%d seconds", timeout));
        }
    }
    overviewTable._("Diagnostics:", app.getDiagnosticsInfo() == null ? "" : app.getDiagnosticsInfo());
    overviewTable._("Unmanaged Application:", app.isUnmanagedApp());
    overviewTable._("Application Node Label expression:", app.getAppNodeLabelExpression() == null ? "<Not set>" : app.getAppNodeLabelExpression());
    overviewTable._("AM container Node Label expression:", app.getAmNodeLabelExpression() == null ? "<Not set>" : app.getAmNodeLabelExpression());
}
Also used : ResponseInfo(org.apache.hadoop.yarn.webapp.ResponseInfo) LogAggregationStatus(org.apache.hadoop.yarn.api.records.LogAggregationStatus)

Example 4 with ResponseInfo

use of org.apache.hadoop.yarn.webapp.ResponseInfo in project hadoop by apache.

the class TestHsJobBlock method testHsJobBlockForNormalSizeJobShouldNotDisplayWarningMessage.

@Test
public void testHsJobBlockForNormalSizeJobShouldNotDisplayWarningMessage() {
    Configuration config = new Configuration();
    config.setInt(JHAdminConfig.MR_HS_LOADED_JOBS_TASKS_MAX, -1);
    JobHistory jobHistory = new JobHitoryStubWithAllNormalSizeJobs();
    jobHistory.init(config);
    HsJobBlock jobBlock = new HsJobBlock(jobHistory) {

        // override this so that the job block can fetch a job id.
        @Override
        public Map<String, String> moreParams() {
            Map<String, String> map = new HashMap<>();
            map.put(AMParams.JOB_ID, "job_0000_0001");
            return map;
        }

        // override this to avoid view context lookup in render()
        @Override
        public ResponseInfo info(String about) {
            return new ResponseInfo().about(about);
        }

        // override this to avoid view context lookup in render()
        @Override
        public String url(String... parts) {
            return StringHelper.ujoin("", parts);
        }
    };
    // set up the test block to render HsJobBLock to
    OutputStream outputStream = new ByteArrayOutputStream();
    HtmlBlock.Block block = createBlockToCreateTo(outputStream);
    jobBlock.render(block);
    block.getWriter().flush();
    String out = outputStream.toString();
    Assert.assertTrue("Should display job overview for the job.", out.contains("ApplicationMaster"));
}
Also used : ResponseInfo(org.apache.hadoop.yarn.webapp.ResponseInfo) Configuration(org.apache.hadoop.conf.Configuration) JobHistory(org.apache.hadoop.mapreduce.v2.hs.JobHistory) HashMap(java.util.HashMap) OutputStream(java.io.OutputStream) ByteArrayOutputStream(org.apache.commons.io.output.ByteArrayOutputStream) ByteArrayOutputStream(org.apache.commons.io.output.ByteArrayOutputStream) HtmlBlock(org.apache.hadoop.yarn.webapp.view.HtmlBlock) BlockForTest(org.apache.hadoop.yarn.webapp.view.BlockForTest) HtmlBlockForTest(org.apache.hadoop.yarn.webapp.view.HtmlBlockForTest) Test(org.junit.Test)

Aggregations

ResponseInfo (org.apache.hadoop.yarn.webapp.ResponseInfo)4 Test (org.junit.Test)2 Injector (com.google.inject.Injector)1 OutputStream (java.io.OutputStream)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 ByteArrayOutputStream (org.apache.commons.io.output.ByteArrayOutputStream)1 Configuration (org.apache.hadoop.conf.Configuration)1 AMInfo (org.apache.hadoop.mapreduce.v2.api.records.AMInfo)1 JobId (org.apache.hadoop.mapreduce.v2.api.records.JobId)1 Job (org.apache.hadoop.mapreduce.v2.app.job.Job)1 ConfEntryInfo (org.apache.hadoop.mapreduce.v2.app.webapp.dao.ConfEntryInfo)1 JobHistory (org.apache.hadoop.mapreduce.v2.hs.JobHistory)1 UnparsedJob (org.apache.hadoop.mapreduce.v2.hs.UnparsedJob)1 AMAttemptInfo (org.apache.hadoop.mapreduce.v2.hs.webapp.dao.AMAttemptInfo)1 JobInfo (org.apache.hadoop.mapreduce.v2.hs.webapp.dao.JobInfo)1 LogAggregationStatus (org.apache.hadoop.yarn.api.records.LogAggregationStatus)1 Hamlet (org.apache.hadoop.yarn.webapp.hamlet.Hamlet)1 DIV (org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV)1 BlockForTest (org.apache.hadoop.yarn.webapp.view.BlockForTest)1