Search in sources :

Example 1 with TABLE

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

the class RMAppsBlock method renderData.

@Override
protected void renderData(Block html) {
    TBODY<TABLE<Hamlet>> tbody = html.table("#apps").thead().tr().th(".id", "ID").th(".user", "User").th(".name", "Name").th(".type", "Application Type").th(".queue", "Queue").th(".priority", "Application Priority").th(".starttime", "StartTime").th(".finishtime", "FinishTime").th(".state", "State").th(".finalstatus", "FinalStatus").th(".runningcontainer", "Running Containers").th(".allocatedCpu", "Allocated CPU VCores").th(".allocatedMemory", "Allocated Memory MB").th(".queuePercentage", "% of Queue").th(".clusterPercentage", "% of Cluster").th(".progress", "Progress").th(".ui", "Tracking UI").th(".blacklisted", "Blacklisted Nodes")._()._().tbody();
    StringBuilder appsTableData = new StringBuilder("[\n");
    for (ApplicationReport appReport : appReports) {
        // hasn't filtering capability (YARN-1819).
        if (!reqAppStates.isEmpty() && !reqAppStates.contains(appReport.getYarnApplicationState())) {
            continue;
        }
        AppInfo app = new AppInfo(appReport);
        ApplicationAttemptId appAttemptId = ApplicationAttemptId.fromString(app.getCurrentAppAttemptId());
        String queuePercent = "N/A";
        String clusterPercent = "N/A";
        if (appReport.getApplicationResourceUsageReport() != null) {
            queuePercent = String.format("%.1f", appReport.getApplicationResourceUsageReport().getQueueUsagePercentage());
            clusterPercent = String.format("%.1f", appReport.getApplicationResourceUsageReport().getClusterUsagePercentage());
        }
        String blacklistedNodesCount = "N/A";
        RMAppAttempt appAttempt = rm.getRMContext().getRMApps().get(appAttemptId.getApplicationId()).getAppAttempts().get(appAttemptId);
        Set<String> nodes = null == appAttempt ? null : appAttempt.getBlacklistedNodes();
        if (nodes != null) {
            blacklistedNodesCount = String.valueOf(nodes.size());
        }
        String percent = StringUtils.format("%.1f", app.getProgress());
        appsTableData.append("[\"<a href='").append(url("app", app.getAppId())).append("'>").append(app.getAppId()).append("</a>\",\"").append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(app.getUser()))).append("\",\"").append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(app.getName()))).append("\",\"").append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(app.getType()))).append("\",\"").append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(app.getQueue()))).append("\",\"").append(String.valueOf(app.getPriority())).append("\",\"").append(app.getStartedTime()).append("\",\"").append(app.getFinishedTime()).append("\",\"").append(app.getAppState() == null ? UNAVAILABLE : app.getAppState()).append("\",\"").append(app.getFinalAppStatus()).append("\",\"").append(app.getRunningContainers() == -1 ? "N/A" : String.valueOf(app.getRunningContainers())).append("\",\"").append(app.getAllocatedCpuVcores() == -1 ? "N/A" : String.valueOf(app.getAllocatedCpuVcores())).append("\",\"").append(app.getAllocatedMemoryMB() == -1 ? "N/A" : String.valueOf(app.getAllocatedMemoryMB())).append("\",\"").append(queuePercent).append("\",\"").append(clusterPercent).append("\",\"").append("<br title='").append(percent).append("'> <div class='").append(C_PROGRESSBAR).append("' title='").append(join(percent, '%')).append("'> ").append("<div class='").append(C_PROGRESSBAR_VALUE).append("' style='").append(join("width:", percent, '%')).append("'> </div> </div>").append("\",\"<a ");
        String trackingURL = app.getTrackingUrl() == null || app.getTrackingUrl().equals(UNAVAILABLE) || app.getAppState() == YarnApplicationState.NEW ? null : app.getTrackingUrl();
        String trackingUI = app.getTrackingUrl() == null || app.getTrackingUrl().equals(UNAVAILABLE) || app.getAppState() == YarnApplicationState.NEW ? "Unassigned" : app.getAppState() == YarnApplicationState.FINISHED || app.getAppState() == YarnApplicationState.FAILED || app.getAppState() == YarnApplicationState.KILLED ? "History" : "ApplicationMaster";
        appsTableData.append(trackingURL == null ? "#" : "href='" + trackingURL).append("'>").append(trackingUI).append("</a>\",").append("\"").append(blacklistedNodesCount).append("\"],\n");
    }
    if (appsTableData.charAt(appsTableData.length() - 2) == ',') {
        appsTableData.delete(appsTableData.length() - 2, appsTableData.length() - 1);
    }
    appsTableData.append("]");
    html.script().$type("text/javascript")._("var appsTableData=" + appsTableData)._();
    tbody._()._();
}
Also used : TABLE(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE) ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) RMAppAttempt(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) AppInfo(org.apache.hadoop.yarn.server.webapp.dao.AppInfo)

Example 2 with TABLE

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

the class AppBlock method generateApplicationTable.

protected void generateApplicationTable(Block html, UserGroupInformation callerUGI, Collection<ApplicationAttemptReport> attempts) {
    // Application Attempt Table
    TBODY<TABLE<Hamlet>> tbody = html.table("#attempts").thead().tr().th(".id", "Attempt ID").th(".started", "Started").th(".node", "Node").th(".logs", "Logs")._()._().tbody();
    StringBuilder attemptsTableData = new StringBuilder("[\n");
    for (final ApplicationAttemptReport appAttemptReport : attempts) {
        AppAttemptInfo appAttempt = new AppAttemptInfo(appAttemptReport);
        ContainerReport containerReport;
        try {
            final GetContainerReportRequest request = GetContainerReportRequest.newInstance(appAttemptReport.getAMContainerId());
            if (callerUGI == null) {
                containerReport = appBaseProt.getContainerReport(request).getContainerReport();
            } else {
                containerReport = callerUGI.doAs(new PrivilegedExceptionAction<ContainerReport>() {

                    @Override
                    public ContainerReport run() throws Exception {
                        ContainerReport report = null;
                        if (request.getContainerId() != null) {
                            try {
                                report = appBaseProt.getContainerReport(request).getContainerReport();
                            } catch (ContainerNotFoundException ex) {
                                LOG.warn(ex.getMessage());
                            }
                        }
                        return report;
                    }
                });
            }
        } catch (Exception e) {
            String message = "Failed to read the AM container of the application attempt " + appAttemptReport.getApplicationAttemptId() + ".";
            LOG.error(message, e);
            html.p()._(message)._();
            return;
        }
        long startTime = 0L;
        String logsLink = null;
        String nodeLink = null;
        if (containerReport != null) {
            ContainerInfo container = new ContainerInfo(containerReport);
            startTime = container.getStartedTime();
            logsLink = containerReport.getLogUrl();
            nodeLink = containerReport.getNodeHttpAddress();
        }
        attemptsTableData.append("[\"<a href='").append(url("appattempt", appAttempt.getAppAttemptId())).append("'>").append(appAttempt.getAppAttemptId()).append("</a>\",\"").append(startTime).append("\",\"<a ").append(nodeLink == null ? "#" : "href='" + nodeLink).append("'>").append(nodeLink == null ? "N/A" : StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(nodeLink))).append("</a>\",\"<a ").append(logsLink == null ? "#" : "href='" + logsLink).append("'>").append(logsLink == null ? "N/A" : "Logs").append("</a>\"],\n");
    }
    if (attemptsTableData.charAt(attemptsTableData.length() - 2) == ',') {
        attemptsTableData.delete(attemptsTableData.length() - 2, attemptsTableData.length() - 1);
    }
    attemptsTableData.append("]");
    html.script().$type("text/javascript")._("var attemptsTableData=" + attemptsTableData)._();
    tbody._()._();
}
Also used : AppAttemptInfo(org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo) ApplicationAttemptReport(org.apache.hadoop.yarn.api.records.ApplicationAttemptReport) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) AuthenticationException(org.apache.hadoop.security.authentication.client.AuthenticationException) ContainerNotFoundException(org.apache.hadoop.yarn.exceptions.ContainerNotFoundException) GetContainerReportRequest(org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportRequest) 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) ContainerNotFoundException(org.apache.hadoop.yarn.exceptions.ContainerNotFoundException)

Example 3 with TABLE

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

the class AppsBlock method renderData.

protected void renderData(Block html) {
    TBODY<TABLE<Hamlet>> tbody = html.table("#apps").thead().tr().th(".id", "ID").th(".user", "User").th(".name", "Name").th(".type", "Application Type").th(".queue", "Queue").th(".priority", "Application Priority").th(".starttime", "StartTime").th(".finishtime", "FinishTime").th(".state", "State").th(".finalstatus", "FinalStatus").th(".progress", "Progress").th(".ui", "Tracking UI")._()._().tbody();
    StringBuilder appsTableData = new StringBuilder("[\n");
    for (ApplicationReport appReport : appReports) {
        // hasn't filtering capability (YARN-1819).
        if (!reqAppStates.isEmpty() && !reqAppStates.contains(appReport.getYarnApplicationState())) {
            continue;
        }
        AppInfo app = new AppInfo(appReport);
        String percent = StringUtils.format("%.1f", app.getProgress());
        appsTableData.append("[\"<a href='").append(url("app", app.getAppId())).append("'>").append(app.getAppId()).append("</a>\",\"").append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(app.getUser()))).append("\",\"").append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(app.getName()))).append("\",\"").append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(app.getType()))).append("\",\"").append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(app.getQueue()))).append("\",\"").append(String.valueOf(app.getPriority())).append("\",\"").append(app.getStartedTime()).append("\",\"").append(app.getFinishedTime()).append("\",\"").append(app.getAppState() == null ? UNAVAILABLE : app.getAppState()).append("\",\"").append(app.getFinalAppStatus()).append("\",\"").append("<br title='").append(percent).append("'> <div class='").append(C_PROGRESSBAR).append("' title='").append(join(percent, '%')).append("'> ").append("<div class='").append(C_PROGRESSBAR_VALUE).append("' style='").append(join("width:", percent, '%')).append("'> </div> </div>").append("\",\"<a ");
        String trackingURL = app.getTrackingUrl() == null || app.getTrackingUrl().equals(UNAVAILABLE) ? null : app.getTrackingUrl();
        String trackingUI = app.getTrackingUrl() == null || app.getTrackingUrl().equals(UNAVAILABLE) ? "Unassigned" : app.getAppState() == YarnApplicationState.FINISHED || app.getAppState() == YarnApplicationState.FAILED || app.getAppState() == YarnApplicationState.KILLED ? "History" : "ApplicationMaster";
        appsTableData.append(trackingURL == null ? "#" : "href='" + trackingURL).append("'>").append(trackingUI).append("</a>\"],\n");
    }
    if (appsTableData.charAt(appsTableData.length() - 2) == ',') {
        appsTableData.delete(appsTableData.length() - 2, appsTableData.length() - 1);
    }
    appsTableData.append("]");
    html.script().$type("text/javascript")._("var appsTableData=" + appsTableData)._();
    tbody._()._();
}
Also used : TABLE(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE) ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) AppInfo(org.apache.hadoop.yarn.server.webapp.dao.AppInfo)

Example 4 with TABLE

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

the class ConfBlock 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 job = appContext.getJob(jobID);
    if (job == null) {
        html.p()._("Sorry, ", jid, " not found.")._();
        return;
    }
    Path confPath = job.getConfFile();
    try {
        ConfInfo info = new ConfInfo(job);
        html.div().a("/jobhistory/downloadconf/" + jid, confPath.toString());
        TBODY<TABLE<Hamlet>> tbody = html.table("#conf").thead().tr().th(_TH, "key").th(_TH, "value").th(_TH, "source chain")._()._().tbody();
        for (ConfEntryInfo entry : info.getProperties()) {
            StringBuffer buffer = new StringBuffer();
            String[] sources = entry.getSource();
            //Skip the last entry, because it is always the same HDFS file, and
            // output them in reverse order so most recent is output first
            boolean first = true;
            for (int i = (sources.length - 2); i >= 0; i--) {
                if (!first) {
                    buffer.append(" <- ");
                }
                first = false;
                buffer.append(sources[i]);
            }
            tbody.tr().td(entry.getName()).td(entry.getValue()).td(buffer.toString())._();
        }
        tbody._().tfoot().tr().th().input("search_init").$type(InputType.text).$name("key").$value("key")._()._().th().input("search_init").$type(InputType.text).$name("value").$value("value")._()._().th().input("search_init").$type(InputType.text).$name("source chain").$value("source chain")._()._()._()._()._();
    } catch (IOException e) {
        LOG.error("Error while reading " + confPath, e);
        html.p()._("Sorry got an error while reading conf file. ", confPath);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) ConfInfo(org.apache.hadoop.mapreduce.v2.app.webapp.dao.ConfInfo) IOException(java.io.IOException) ConfEntryInfo(org.apache.hadoop.mapreduce.v2.app.webapp.dao.ConfEntryInfo) TABLE(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) JobId(org.apache.hadoop.mapreduce.v2.api.records.JobId)

Example 5 with TABLE

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

the class CountersBlock method render.

@Override
protected void render(Block html) {
    if (job == null) {
        html.p()._("Sorry, no counters for nonexistent", $(JOB_ID, "job"))._();
        return;
    }
    if (!$(TASK_ID).isEmpty() && task == null) {
        html.p()._("Sorry, no counters for nonexistent", $(TASK_ID, "task"))._();
        return;
    }
    if (total == null || total.getGroupNames() == null || total.countCounters() == 0) {
        String type = $(TASK_ID);
        if (type == null || type.isEmpty()) {
            type = $(JOB_ID, "the job");
        }
        html.p()._("Sorry it looks like ", type, " has no counters.")._();
        return;
    }
    String urlBase;
    String urlId;
    if (task != null) {
        urlBase = "singletaskcounter";
        urlId = MRApps.toString(task.getID());
    } else {
        urlBase = "singlejobcounter";
        urlId = MRApps.toString(job.getID());
    }
    int numGroups = 0;
    TBODY<TABLE<DIV<Hamlet>>> tbody = html.div(_INFO_WRAP).table("#counters").thead().tr().th(".group.ui-state-default", "Counter Group").th(".ui-state-default", "Counters")._()._().tbody();
    for (CounterGroup g : total) {
        CounterGroup mg = map == null ? null : map.getGroup(g.getName());
        CounterGroup rg = reduce == null ? null : reduce.getGroup(g.getName());
        ++numGroups;
        // This is mostly for demonstration :) Typically we'd introduced
        // a CounterGroup block to reduce the verbosity. OTOH, this
        // serves as an indicator of where we're in the tag hierarchy.
        TR<THEAD<TABLE<TD<TR<TBODY<TABLE<DIV<Hamlet>>>>>>>> groupHeadRow = tbody.tr().th().$title(g.getName()).$class("ui-state-default")._(fixGroupDisplayName(g.getDisplayName()))._().td().$class(C_TABLE).table(".dt-counters").$id(job.getID() + "." + g.getName()).thead().tr().th(".name", "Name");
        if (map != null) {
            groupHeadRow.th("Map").th("Reduce");
        }
        // Ditto
        TBODY<TABLE<TD<TR<TBODY<TABLE<DIV<Hamlet>>>>>>> group = groupHeadRow.th(map == null ? "Value" : "Total")._()._().tbody();
        for (Counter counter : g) {
            // Ditto
            TR<TBODY<TABLE<TD<TR<TBODY<TABLE<DIV<Hamlet>>>>>>>> groupRow = group.tr();
            if (task == null && mg == null && rg == null) {
                groupRow.td().$title(counter.getName())._(counter.getDisplayName())._();
            } else {
                groupRow.td().$title(counter.getName()).a(url(urlBase, urlId, g.getName(), counter.getName()), counter.getDisplayName())._();
            }
            if (map != null) {
                Counter mc = mg == null ? null : mg.findCounter(counter.getName());
                Counter rc = rg == null ? null : rg.findCounter(counter.getName());
                groupRow.td(mc == null ? "0" : String.format("%,d", mc.getValue())).td(rc == null ? "0" : String.format("%,d", rc.getValue()));
            }
            groupRow.td(String.format("%,d", counter.getValue()))._();
        }
        group._()._()._()._();
    }
    tbody._()._()._();
}
Also used : Hamlet(org.apache.hadoop.yarn.webapp.hamlet.Hamlet) CounterGroup(org.apache.hadoop.mapreduce.CounterGroup) TBODY(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY) TABLE(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE) C_TABLE(org.apache.hadoop.yarn.webapp.view.JQueryUI.C_TABLE) TD(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TD) DIV(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV) Counter(org.apache.hadoop.mapreduce.Counter) THEAD(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.THEAD) TR(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TR)

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