Search in sources :

Example 11 with TABLE

use of org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE in project hadoop by apache.

the class RMAppAttemptBlock method createResourceRequestsTable.

private void createResourceRequestsTable(Block html) {
    AppInfo app = new AppInfo(rm, rm.getRMContext().getRMApps().get(this.appAttemptId.getApplicationId()), true, WebAppUtils.getHttpSchemePrefix(conf));
    List<ResourceRequestInfo> resourceRequests = app.getResourceRequests();
    if (resourceRequests == null || resourceRequests.isEmpty()) {
        return;
    }
    DIV<Hamlet> div = html.div(_INFO_WRAP);
    // Requests Table
    TBODY<TABLE<DIV<Hamlet>>> tbody = div.h3("Total Outstanding Resource Requests: " + getTotalResource(resourceRequests)).table("#resourceRequests").thead().tr().th(".priority", "Priority").th(".resource", "ResourceName").th(".capacity", "Capability").th(".containers", "NumContainers").th(".relaxlocality", "RelaxLocality").th(".labelexpression", "NodeLabelExpression")._()._().tbody();
    StringBuilder resourceRequestTableData = new StringBuilder("[\n");
    for (ResourceRequestInfo resourceRequest : resourceRequests) {
        if (resourceRequest.getNumContainers() == 0) {
            continue;
        }
        resourceRequestTableData.append("[\"").append(String.valueOf(resourceRequest.getPriority())).append("\",\"").append(resourceRequest.getResourceName()).append("\",\"").append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(String.valueOf(resourceRequest.getCapability())))).append("\",\"").append(String.valueOf(resourceRequest.getNumContainers())).append("\",\"").append(String.valueOf(resourceRequest.getRelaxLocality())).append("\",\"").append(resourceRequest.getNodeLabelExpression() == null ? "N/A" : resourceRequest.getNodeLabelExpression()).append("\"],\n");
    }
    if (resourceRequestTableData.charAt(resourceRequestTableData.length() - 2) == ',') {
        resourceRequestTableData.delete(resourceRequestTableData.length() - 2, resourceRequestTableData.length() - 1);
    }
    resourceRequestTableData.append("]");
    html.script().$type("text/javascript")._("var resourceRequestsTableData=" + resourceRequestTableData)._();
    tbody._()._();
    div._();
}
Also used : Hamlet(org.apache.hadoop.yarn.webapp.hamlet.Hamlet) TABLE(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE) ResourceRequestInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceRequestInfo) AppInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppInfo)

Example 12 with TABLE

use of org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE in project hadoop by apache.

the class AppAttemptBlock method render.

@Override
protected void render(Block html) {
    String attemptid = $(APPLICATION_ATTEMPT_ID);
    if (attemptid.isEmpty()) {
        puts("Bad request: requires application attempt ID");
        return;
    }
    try {
        appAttemptId = ApplicationAttemptId.fromString(attemptid);
    } catch (IllegalArgumentException e) {
        puts("Invalid application attempt ID: " + attemptid);
        return;
    }
    UserGroupInformation callerUGI = getCallerUGI();
    ApplicationAttemptReport appAttemptReport;
    try {
        final GetApplicationAttemptReportRequest request = GetApplicationAttemptReportRequest.newInstance(appAttemptId);
        if (callerUGI == null) {
            appAttemptReport = appBaseProt.getApplicationAttemptReport(request).getApplicationAttemptReport();
        } else {
            appAttemptReport = callerUGI.doAs(new PrivilegedExceptionAction<ApplicationAttemptReport>() {

                @Override
                public ApplicationAttemptReport run() throws Exception {
                    return appBaseProt.getApplicationAttemptReport(request).getApplicationAttemptReport();
                }
            });
        }
    } catch (Exception e) {
        String message = "Failed to read the application attempt " + appAttemptId + ".";
        LOG.error(message, e);
        html.p()._(message)._();
        return;
    }
    if (appAttemptReport == null) {
        puts("Application Attempt not found: " + attemptid);
        return;
    }
    boolean exceptionWhenGetContainerReports = false;
    Collection<ContainerReport> containers = null;
    try {
        final GetContainersRequest request = GetContainersRequest.newInstance(appAttemptId);
        if (callerUGI == null) {
            containers = appBaseProt.getContainers(request).getContainerList();
        } else {
            containers = callerUGI.doAs(new PrivilegedExceptionAction<Collection<ContainerReport>>() {

                @Override
                public Collection<ContainerReport> run() throws Exception {
                    return appBaseProt.getContainers(request).getContainerList();
                }
            });
        }
    } catch (RuntimeException e) {
        // have this block to suppress the findbugs warning
        exceptionWhenGetContainerReports = true;
    } catch (Exception e) {
        exceptionWhenGetContainerReports = true;
    }
    AppAttemptInfo appAttempt = new AppAttemptInfo(appAttemptReport);
    setTitle(join("Application Attempt ", attemptid));
    String node = "N/A";
    if (appAttempt.getHost() != null && appAttempt.getRpcPort() >= 0 && appAttempt.getRpcPort() < 65536) {
        node = appAttempt.getHost() + ":" + appAttempt.getRpcPort();
    }
    generateOverview(appAttemptReport, containers, appAttempt, node);
    if (exceptionWhenGetContainerReports) {
        html.p()._("Sorry, Failed to get containers for application attempt" + attemptid + ".")._();
        return;
    }
    createAttemptHeadRoomTable(html);
    html._(InfoBlock.class);
    createTablesForAttemptMetrics(html);
    // Container Table
    TBODY<TABLE<Hamlet>> tbody = html.table("#containers").thead().tr().th(".id", "Container ID").th(".node", "Node").th(".exitstatus", "Container Exit Status").th(".logs", "Logs")._()._().tbody();
    StringBuilder containersTableData = new StringBuilder("[\n");
    for (ContainerReport containerReport : containers) {
        ContainerInfo container = new ContainerInfo(containerReport);
        containersTableData.append("[\"<a href='").append(url("container", container.getContainerId())).append("'>").append(container.getContainerId()).append("</a>\",\"<a ").append(container.getNodeHttpAddress() == null ? "#" : "href='" + container.getNodeHttpAddress()).append("'>").append(container.getNodeHttpAddress() == null ? "N/A" : StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(container.getNodeHttpAddress()))).append("</a>\",\"").append(container.getContainerExitStatus()).append("\",\"<a href='").append(container.getLogUrl() == null ? "#" : container.getLogUrl()).append("'>").append(container.getLogUrl() == null ? "N/A" : "Logs").append("</a>\"],\n");
    }
    if (containersTableData.charAt(containersTableData.length() - 2) == ',') {
        containersTableData.delete(containersTableData.length() - 2, containersTableData.length() - 1);
    }
    containersTableData.append("]");
    html.script().$type("text/javascript")._("var containersTableData=" + containersTableData)._();
    tbody._()._();
}
Also used : AppAttemptInfo(org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo) ApplicationAttemptReport(org.apache.hadoop.yarn.api.records.ApplicationAttemptReport) GetApplicationAttemptReportRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportRequest) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) TABLE(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE) ContainerReport(org.apache.hadoop.yarn.api.records.ContainerReport) ContainerInfo(org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo) GetContainersRequest(org.apache.hadoop.yarn.api.protocolrecords.GetContainersRequest) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Example 13 with TABLE

use of org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE in project hadoop by apache.

the class JobsBlock method render.

@Override
protected void render(Block html) {
    TBODY<TABLE<Hamlet>> tbody = html.h2("Active Jobs").table("#jobs").thead().tr().th(".id", "Job ID").th(".name", "Name").th(".state", "State").th("Map Progress").th("Maps Total").th("Maps Completed").th("Reduce Progress").th("Reduces Total").th("Reduces Completed")._()._().tbody();
    for (Job j : appContext.getAllJobs().values()) {
        JobInfo job = new JobInfo(j, false);
        tbody.tr().td().span().$title(String.valueOf(job.getId()))._().a(url("job", job.getId()), job.getId())._().td(job.getName()).td(job.getState()).td().span().$title(job.getMapProgressPercent())._().div(_PROGRESSBAR).$title(// tooltip
        join(job.getMapProgressPercent(), '%')).div(_PROGRESSBAR_VALUE).$style(join("width:", job.getMapProgressPercent(), '%'))._()._()._().td(String.valueOf(job.getMapsTotal())).td(String.valueOf(job.getMapsCompleted())).td().span().$title(job.getReduceProgressPercent())._().div(_PROGRESSBAR).$title(// tooltip
        join(job.getReduceProgressPercent(), '%')).div(_PROGRESSBAR_VALUE).$style(join("width:", job.getReduceProgressPercent(), '%'))._()._()._().td(String.valueOf(job.getReducesTotal())).td(String.valueOf(job.getReducesCompleted()))._();
    }
    tbody._()._();
}
Also used : TABLE(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE) JobInfo(org.apache.hadoop.mapreduce.v2.app.webapp.dao.JobInfo) Job(org.apache.hadoop.mapreduce.v2.app.job.Job)

Example 14 with TABLE

use of org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE in project hadoop by apache.

the class HsJobsBlock 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) {
    TBODY<TABLE<Hamlet>> tbody = html.h2("Retired Jobs").table("#jobs").thead().tr().th("Submit Time").th("Start Time").th("Finish Time").th(".id", "Job ID").th(".name", "Name").th("User").th("Queue").th(".state", "State").th("Maps Total").th("Maps Completed").th("Reduces Total").th("Reduces Completed").th("Elapsed Time")._()._().tbody();
    LOG.info("Getting list of all Jobs.");
    // Write all the data into a JavaScript array of arrays for JQuery
    // DataTables to display
    StringBuilder jobsTableData = new StringBuilder("[\n");
    for (Job j : appContext.getAllJobs().values()) {
        JobInfo job = new JobInfo(j);
        jobsTableData.append("[\"").append(dateFormat.format(new Date(job.getSubmitTime()))).append("\",\"").append(job.getFormattedStartTimeStr(dateFormat)).append("\",\"").append(dateFormat.format(new Date(job.getFinishTime()))).append("\",\"").append("<a href='").append(url("job", job.getId())).append("'>").append(job.getId()).append("</a>\",\"").append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(job.getName()))).append("\",\"").append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(job.getUserName()))).append("\",\"").append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(job.getQueueName()))).append("\",\"").append(job.getState()).append("\",\"").append(String.valueOf(job.getMapsTotal())).append("\",\"").append(String.valueOf(job.getMapsCompleted())).append("\",\"").append(String.valueOf(job.getReducesTotal())).append("\",\"").append(String.valueOf(job.getReducesCompleted())).append("\",\"").append(StringUtils.formatTimeSortable(Times.elapsed(job.getStartTime(), job.getFinishTime(), false))).append("\"],\n");
    }
    //Remove the last comma and close off the array of arrays
    if (jobsTableData.charAt(jobsTableData.length() - 2) == ',') {
        jobsTableData.delete(jobsTableData.length() - 2, jobsTableData.length() - 1);
    }
    jobsTableData.append("]");
    html.script().$type("text/javascript")._("var jobsTableData=" + jobsTableData)._();
    tbody._().tfoot().tr().th().input("search_init").$type(InputType.text).$name("submit_time").$value("Submit Time")._()._().th().input("search_init").$type(InputType.text).$name("start_time").$value("Start Time")._()._().th().input("search_init").$type(InputType.text).$name("finish_time").$value("Finish Time")._()._().th().input("search_init").$type(InputType.text).$name("job_id").$value("Job ID")._()._().th().input("search_init").$type(InputType.text).$name("name").$value("Name")._()._().th().input("search_init").$type(InputType.text).$name("user").$value("User")._()._().th().input("search_init").$type(InputType.text).$name("queue").$value("Queue")._()._().th().input("search_init").$type(InputType.text).$name("state").$value("State")._()._().th().input("search_init").$type(InputType.text).$name("maps_total").$value("Maps Total")._()._().th().input("search_init").$type(InputType.text).$name("maps_completed").$value("Maps Completed")._()._().th().input("search_init").$type(InputType.text).$name("reduces_total").$value("Reduces Total")._()._().th().input("search_init").$type(InputType.text).$name("reduces_completed").$value("Reduces Completed")._()._().th().input("search_init").$type(InputType.text).$name("elapsed_time").$value("Elapsed Time")._()._()._()._()._();
}
Also used : TABLE(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE) JobInfo(org.apache.hadoop.mapreduce.v2.hs.webapp.dao.JobInfo) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) Date(java.util.Date)

Example 15 with TABLE

use of org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE in project hadoop by apache.

the class HsTasksBlock 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) {
    if (app.getJob() == null) {
        html.h2($(TITLE));
        return;
    }
    TaskType type = null;
    String symbol = $(TASK_TYPE);
    if (!symbol.isEmpty()) {
        type = MRApps.taskType(symbol);
    }
    THEAD<TABLE<Hamlet>> thead;
    if (type != null)
        thead = html.table("#" + app.getJob().getID() + type).$class("dt-tasks").thead();
    else
        thead = html.table("#tasks").thead();
    //Create the spanning row
    int attemptColSpan = type == TaskType.REDUCE ? 8 : 3;
    thead.tr().th().$colspan(5).$class("ui-state-default")._("Task")._().th().$colspan(attemptColSpan).$class("ui-state-default")._("Successful Attempt")._()._();
    TR<THEAD<TABLE<Hamlet>>> theadRow = thead.tr().th("Name").th("State").th("Start Time").th("Finish Time").th("Elapsed Time").th(//Attempt
    "Start Time");
    if (type == TaskType.REDUCE) {
        //Attempt
        theadRow.th("Shuffle Finish Time");
        //Attempt
        theadRow.th("Merge Finish Time");
    }
    //Attempt
    theadRow.th("Finish Time");
    if (type == TaskType.REDUCE) {
        //Attempt
        theadRow.th("Elapsed Time Shuffle");
        //Attempt
        theadRow.th("Elapsed Time Merge");
        //Attempt
        theadRow.th("Elapsed Time Reduce");
    }
    //Attempt
    theadRow.th("Elapsed Time");
    TBODY<TABLE<Hamlet>> tbody = theadRow._()._().tbody();
    // Write all the data into a JavaScript array of arrays for JQuery
    // DataTables to display
    StringBuilder tasksTableData = new StringBuilder("[\n");
    for (Task task : app.getJob().getTasks().values()) {
        if (type != null && task.getType() != type) {
            continue;
        }
        TaskInfo info = new TaskInfo(task);
        String tid = info.getId();
        long startTime = info.getStartTime();
        long finishTime = info.getFinishTime();
        long elapsed = info.getElapsedTime();
        long attemptStartTime = -1;
        long shuffleFinishTime = -1;
        long sortFinishTime = -1;
        long attemptFinishTime = -1;
        long elapsedShuffleTime = -1;
        long elapsedSortTime = -1;
        ;
        long elapsedReduceTime = -1;
        long attemptElapsed = -1;
        TaskAttempt successful = info.getSuccessful();
        if (successful != null) {
            TaskAttemptInfo ta;
            if (type == TaskType.REDUCE) {
                ReduceTaskAttemptInfo rta = new ReduceTaskAttemptInfo(successful, type);
                shuffleFinishTime = rta.getShuffleFinishTime();
                sortFinishTime = rta.getMergeFinishTime();
                elapsedShuffleTime = rta.getElapsedShuffleTime();
                elapsedSortTime = rta.getElapsedMergeTime();
                elapsedReduceTime = rta.getElapsedReduceTime();
                ta = rta;
            } else {
                ta = new TaskAttemptInfo(successful, type, false);
            }
            attemptStartTime = ta.getStartTime();
            attemptFinishTime = ta.getFinishTime();
            attemptElapsed = ta.getElapsedTime();
        }
        tasksTableData.append("[\"").append("<a href='" + url("task", tid)).append("'>").append(tid).append("</a>\",\"").append(info.getState()).append("\",\"").append(startTime).append("\",\"").append(finishTime).append("\",\"").append(elapsed).append("\",\"").append(attemptStartTime).append("\",\"");
        if (type == TaskType.REDUCE) {
            tasksTableData.append(shuffleFinishTime).append("\",\"").append(sortFinishTime).append("\",\"");
        }
        tasksTableData.append(attemptFinishTime).append("\",\"");
        if (type == TaskType.REDUCE) {
            tasksTableData.append(elapsedShuffleTime).append("\",\"").append(elapsedSortTime).append("\",\"").append(elapsedReduceTime).append("\",\"");
        }
        tasksTableData.append(attemptElapsed).append("\"],\n");
    }
    //Remove the last comma and close off the array of arrays
    if (tasksTableData.charAt(tasksTableData.length() - 2) == ',') {
        tasksTableData.delete(tasksTableData.length() - 2, tasksTableData.length() - 1);
    }
    tasksTableData.append("]");
    html.script().$type("text/javascript")._("var tasksTableData=" + tasksTableData)._();
    TR<TFOOT<TABLE<Hamlet>>> footRow = tbody._().tfoot().tr();
    footRow.th().input("search_init").$type(InputType.text).$name("task").$value("ID")._()._().th().input("search_init").$type(InputType.text).$name("state").$value("State")._()._().th().input("search_init").$type(InputType.text).$name("start_time").$value("Start Time")._()._().th().input("search_init").$type(InputType.text).$name("finish_time").$value("Finish Time")._()._().th().input("search_init").$type(InputType.text).$name("elapsed_time").$value("Elapsed Time")._()._().th().input("search_init").$type(InputType.text).$name("attempt_start_time").$value("Start Time")._()._();
    if (type == TaskType.REDUCE) {
        footRow.th().input("search_init").$type(InputType.text).$name("shuffle_time").$value("Shuffle Time")._()._();
        footRow.th().input("search_init").$type(InputType.text).$name("merge_time").$value("Merge Time")._()._();
    }
    footRow.th().input("search_init").$type(InputType.text).$name("attempt_finish").$value("Finish Time")._()._();
    if (type == TaskType.REDUCE) {
        footRow.th().input("search_init").$type(InputType.text).$name("elapsed_shuffle_time").$value("Elapsed Shuffle Time")._()._();
        footRow.th().input("search_init").$type(InputType.text).$name("elapsed_merge_time").$value("Elapsed Merge Time")._()._();
        footRow.th().input("search_init").$type(InputType.text).$name("elapsed_reduce_time").$value("Elapsed Reduce Time")._()._();
    }
    footRow.th().input("search_init").$type(InputType.text).$name("attempt_elapsed").$value("Elapsed Time")._()._();
    footRow._()._()._();
}
Also used : Hamlet(org.apache.hadoop.yarn.webapp.hamlet.Hamlet) ReduceTaskAttemptInfo(org.apache.hadoop.mapreduce.v2.app.webapp.dao.ReduceTaskAttemptInfo) Task(org.apache.hadoop.mapreduce.v2.app.job.Task) TFOOT(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TFOOT) TABLE(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE) TaskInfo(org.apache.hadoop.mapreduce.v2.app.webapp.dao.TaskInfo) THEAD(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.THEAD) TaskType(org.apache.hadoop.mapreduce.v2.api.records.TaskType) TaskAttemptInfo(org.apache.hadoop.mapreduce.v2.app.webapp.dao.TaskAttemptInfo) ReduceTaskAttemptInfo(org.apache.hadoop.mapreduce.v2.app.webapp.dao.ReduceTaskAttemptInfo) TaskAttempt(org.apache.hadoop.mapreduce.v2.app.job.TaskAttempt)

Aggregations

TABLE (org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE)16 Hamlet (org.apache.hadoop.yarn.webapp.hamlet.Hamlet)6 THEAD (org.apache.hadoop.yarn.webapp.hamlet.Hamlet.THEAD)4 Date (java.util.Date)3 Job (org.apache.hadoop.mapreduce.v2.app.job.Job)3 TBODY (org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY)3 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)2 TaskType (org.apache.hadoop.mapreduce.v2.api.records.TaskType)2 Task (org.apache.hadoop.mapreduce.v2.app.job.Task)2 TaskInfo (org.apache.hadoop.mapreduce.v2.app.webapp.dao.TaskInfo)2 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)2 ApplicationAttemptReport (org.apache.hadoop.yarn.api.records.ApplicationAttemptReport)2 ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)2 ContainerReport (org.apache.hadoop.yarn.api.records.ContainerReport)2 AppInfo (org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppInfo)2 AppAttemptInfo (org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo)2 AppInfo (org.apache.hadoop.yarn.server.webapp.dao.AppInfo)2 ContainerInfo (org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo)2 AngelConf (com.tencent.angel.conf.AngelConf)1 PSAttempt (com.tencent.angel.master.ps.attempt.PSAttempt)1