Search in sources :

Example 1 with THEAD

use of org.apache.hadoop.yarn.webapp.hamlet.Hamlet.THEAD 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)

Example 2 with THEAD

use of org.apache.hadoop.yarn.webapp.hamlet.Hamlet.THEAD 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

Hamlet (org.apache.hadoop.yarn.webapp.hamlet.Hamlet)2 TABLE (org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE)2 THEAD (org.apache.hadoop.yarn.webapp.hamlet.Hamlet.THEAD)2 Counter (org.apache.hadoop.mapreduce.Counter)1 CounterGroup (org.apache.hadoop.mapreduce.CounterGroup)1 TaskType (org.apache.hadoop.mapreduce.v2.api.records.TaskType)1 Task (org.apache.hadoop.mapreduce.v2.app.job.Task)1 TaskAttempt (org.apache.hadoop.mapreduce.v2.app.job.TaskAttempt)1 ReduceTaskAttemptInfo (org.apache.hadoop.mapreduce.v2.app.webapp.dao.ReduceTaskAttemptInfo)1 TaskAttemptInfo (org.apache.hadoop.mapreduce.v2.app.webapp.dao.TaskAttemptInfo)1 TaskInfo (org.apache.hadoop.mapreduce.v2.app.webapp.dao.TaskInfo)1 DIV (org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV)1 TBODY (org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY)1 TD (org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TD)1 TFOOT (org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TFOOT)1 TR (org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TR)1 C_TABLE (org.apache.hadoop.yarn.webapp.view.JQueryUI.C_TABLE)1