org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY Java Examples

The following examples show how to use org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AllApplicationsPage.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override
protected void render(Block html) {

  TBODY<TABLE<BODY<Hamlet>>> tableBody =
    html
      .body()
        .table("#applications")
          .thead()
            .tr()
              .td()._("ApplicationId")._()
              .td()._("ApplicationState")._()
            ._()
           ._()
           .tbody();
  for (Entry<ApplicationId, Application> entry : this.nmContext
      .getApplications().entrySet()) {
    AppInfo info = new AppInfo(entry.getValue());
    tableBody
      .tr()
        .td().a(url("application", info.getId()), info.getId())._()
        .td()._(info.getState())
        ._()
      ._();
  }
  tableBody._()._()._();
}
 
Example #2
Source File: AllContainersPage.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override
protected void render(Block html) {
  TBODY<TABLE<BODY<Hamlet>>> tableBody = html.body()
    .table("#containers")
      .thead()
        .tr()
          .td()._("ContainerId")._()
          .td()._("ContainerState")._()
          .td()._("logs")._()
        ._()
      ._().tbody();
  for (Entry<ContainerId, Container> entry : this.nmContext
      .getContainers().entrySet()) {
    ContainerInfo info = new ContainerInfo(this.nmContext, entry.getValue());
    tableBody
      .tr()
        .td().a(url("container", info.getId()), info.getId())
        ._()
        .td()._(info.getState())._()
        .td()
            .a(url(info.getShortLogLink()), "logs")._()
      ._();
  }
  tableBody._()._()._();
}
 
Example #3
Source File: AllContainersPage.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Override
protected void render(Block html) {
  TBODY<TABLE<BODY<Hamlet>>> tableBody = html.body()
    .table("#containers")
      .thead()
        .tr()
          .td()._("ContainerId")._()
          .td()._("ContainerState")._()
          .td()._("logs")._()
        ._()
      ._().tbody();
  for (Entry<ContainerId, Container> entry : this.nmContext
      .getContainers().entrySet()) {
    ContainerInfo info = new ContainerInfo(this.nmContext, entry.getValue());
    tableBody
      .tr()
        .td().a(url("container", info.getId()), info.getId())
        ._()
        .td()._(info.getState())._()
        .td()
            .a(url(info.getShortLogLink()), "logs")._()
      ._();
  }
  tableBody._()._()._();
}
 
Example #4
Source File: AllApplicationsPage.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Override
protected void render(Block html) {

  TBODY<TABLE<BODY<Hamlet>>> tableBody =
    html
      .body()
        .table("#applications")
          .thead()
            .tr()
              .td()._("ApplicationId")._()
              .td()._("ApplicationState")._()
            ._()
           ._()
           .tbody();
  for (Entry<ApplicationId, Application> entry : this.nmContext
      .getApplications().entrySet()) {
    AppInfo info = new AppInfo(entry.getValue());
    tableBody
      .tr()
        .td().a(url("application", info.getId()), info.getId())._()
        .td()._(info.getState())
        ._()
      ._();
  }
  tableBody._()._()._();
}
 
Example #5
Source File: CapacitySchedulerPage.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
protected void render(Block html) {
  TBODY<TABLE<Hamlet>> tbody =
      html.table("#userinfo").thead().$class("ui-widget-header").tr().th()
          .$class("ui-state-default")._("User Name")._().th()
          .$class("ui-state-default")._("Max Resource")._().th()
          .$class("ui-state-default")._("Used Resource")._().th()
          .$class("ui-state-default")._("Max AM Resource")._().th()
          .$class("ui-state-default")._("Used AM Resource")._().th()
          .$class("ui-state-default")._("Schedulable Apps")._().th()
          .$class("ui-state-default")._("Non-Schedulable Apps")._()._()._()
          .tbody();

  ArrayList<UserInfo> users = lqinfo.getUsers().getUsersList();
  for (UserInfo userInfo : users) {
    tbody.tr().td(userInfo.getUsername())
        .td(userInfo.getUserResourceLimit().toString())
        .td(userInfo.getResourcesUsed().toString())
        .td(lqinfo.getUserAMResourceLimit().toString())
        .td(userInfo.getAMResourcesUsed().toString())
        .td(Integer.toString(userInfo.getNumActiveApplications()))
        .td(Integer.toString(userInfo.getNumPendingApplications()))._();
  }

  html.div().$class("usersinfo").h5("Active Users Info")._();
  tbody._()._();
}
 
Example #6
Source File: NodeLabelsPage.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
protected void render(Block html) {
  TBODY<TABLE<Hamlet>> tbody = html.table("#nodelabels").
      thead().
      tr().
      th(".name", "Label Name").
      th(".numOfActiveNMs", "Num Of Active NMs").
      th(".totalResource", "Total Resource").
      _()._().
      tbody();
  
  RMNodeLabelsManager nlm = rm.getRMContext().getNodeLabelManager();
  for (NodeLabel info : nlm.pullRMNodeLabelsInfo()) {
    TR<TBODY<TABLE<Hamlet>>> row =
        tbody.tr().td(
            info.getLabelName().isEmpty() ? "<NO_LABEL>" : info
                .getLabelName());
    int nActiveNMs = info.getNumActiveNMs();
    if (nActiveNMs > 0) {
      row = row.td()
      .a(url("nodes",
          "?" + YarnWebParams.NODE_LABEL + "=" + info.getLabelName()),
          String.valueOf(nActiveNMs))
       ._();
    } else {
      row = row.td(String.valueOf(nActiveNMs));
    }
    row.td(info.getResource().toString())._();
  }
  tbody._()._();
}
 
Example #7
Source File: SingleCounterBlock.java    From big-c with Apache License 2.0 5 votes vote down vote up
@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;
  }
  
  String columnType = task == null ? "Task" : "Task Attempt";
  
  TBODY<TABLE<DIV<Hamlet>>> tbody = html.
    div(_INFO_WRAP).
    table("#singleCounter").
      thead().
        tr().
          th(".ui-state-default", columnType).
          th(".ui-state-default", "Value")._()._().
        tbody();
  for (Map.Entry<String, Long> entry : values.entrySet()) {
    TR<TBODY<TABLE<DIV<Hamlet>>>> row = tbody.tr();
    String id = entry.getKey();
    String val = entry.getValue().toString();
    if(task != null) {
      row.td(id);
      row.td().br().$title(val)._()._(val)._();
    } else {
      row.td().a(url("singletaskcounter",entry.getKey(),
          $(COUNTER_GROUP), $(COUNTER_NAME)), id)._();
      row.td().br().$title(val)._().a(url("singletaskcounter",entry.getKey(),
          $(COUNTER_GROUP), $(COUNTER_NAME)), val)._();
    }
    row._();
  }
  tbody._()._()._();
}
 
Example #8
Source File: SingleCounterBlock.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@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;
  }
  
  String columnType = task == null ? "Task" : "Task Attempt";
  
  TBODY<TABLE<DIV<Hamlet>>> tbody = html.
    div(_INFO_WRAP).
    table("#singleCounter").
      thead().
        tr().
          th(".ui-state-default", columnType).
          th(".ui-state-default", "Value")._()._().
        tbody();
  for (Map.Entry<String, Long> entry : values.entrySet()) {
    TR<TBODY<TABLE<DIV<Hamlet>>>> row = tbody.tr();
    String id = entry.getKey();
    String val = entry.getValue().toString();
    if(task != null) {
      row.td(id);
      row.td().br().$title(val)._()._(val)._();
    } else {
      row.td().a(url("singletaskcounter",entry.getKey(),
          $(COUNTER_GROUP), $(COUNTER_NAME)), id)._();
      row.td().br().$title(val)._().a(url("singletaskcounter",entry.getKey(),
          $(COUNTER_GROUP), $(COUNTER_NAME)), val)._();
    }
    row._();
  }
  tbody._()._()._();
}
 
Example #9
Source File: NodeLabelsPage.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
protected void render(Block html) {
  TBODY<TABLE<Hamlet>> tbody = html.table("#nodelabels").
      thead().
      tr().
      th(".name", "Label Name").
      th(".numOfActiveNMs", "Num Of Active NMs").
      th(".totalResource", "Total Resource").
      _()._().
      tbody();
  
  RMNodeLabelsManager nlm = rm.getRMContext().getNodeLabelManager();
  for (NodeLabel info : nlm.pullRMNodeLabelsInfo()) {
    TR<TBODY<TABLE<Hamlet>>> row =
        tbody.tr().td(
            info.getLabelName().isEmpty() ? "<NO_LABEL>" : info
                .getLabelName());
    int nActiveNMs = info.getNumActiveNMs();
    if (nActiveNMs > 0) {
      row = row.td()
      .a(url("nodes",
          "?" + YarnWebParams.NODE_LABEL + "=" + info.getLabelName()),
          String.valueOf(nActiveNMs))
       ._();
    } else {
      row = row.td(String.valueOf(nActiveNMs));
    }
    row.td(info.getResource().toString())._();
  }
  tbody._()._();
}
 
Example #10
Source File: CapacitySchedulerPage.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
protected void render(Block html) {
  TBODY<TABLE<Hamlet>> tbody =
          html.table("#userinfo").thead().$class("ui-widget-header").tr().th()
                  .$class("ui-state-default")._("User Name")._().th()
                  .$class("ui-state-default")._("Max Resource")._().th()
                  .$class("ui-state-default")._("Used Resource")._().th()
                  .$class("ui-state-default")._("Max AM Resource")._().th()
                  .$class("ui-state-default")._("Used AM Resource")._().th()
                  .$class("ui-state-default")._("Schedulable Apps")._().th()
                  .$class("ui-state-default")._("Non-Schedulable Apps")._()._()._()
                  .tbody();

  ArrayList<UserInfo> users = lqinfo.getUsers().getUsersList();
  for (UserInfo userInfo : users) {
    tbody.tr().td(userInfo.getUsername())
            .td(userInfo.getUserResourceLimit().toString())
            .td(userInfo.getResourcesUsed().toString())
            .td(lqinfo.getUserAMResourceLimit().toString())
            .td(userInfo.getAMResourcesUsed().toString())
            .td(Integer.toString(userInfo.getNumActiveApplications()))
            .td(Integer.toString(userInfo.getNumPendingApplications()))._();
  }

  html.div().$class("usersinfo").h5("Active Users Info")._();
  tbody._()._();
}
 
Example #11
Source File: JobsBlock.java    From big-c with Apache License 2.0 4 votes vote down vote up
@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()))._(). // for sorting
          a(url("job", job.getId()), job.getId())._().
        td(job.getName()).
        td(job.getState()).
        td().
          span().$title(job.getMapProgressPercent())._(). // for sorting
          div(_PROGRESSBAR).
            $title(join(job.getMapProgressPercent(), '%')). // tooltip
            div(_PROGRESSBAR_VALUE).
              $style(join("width:", job.getMapProgressPercent(), '%'))._()._()._().
        td(String.valueOf(job.getMapsTotal())).
        td(String.valueOf(job.getMapsCompleted())).
        td().
          span().$title(job.getReduceProgressPercent())._(). // for sorting
          div(_PROGRESSBAR).
            $title(join(job.getReduceProgressPercent(), '%')). // tooltip
            div(_PROGRESSBAR_VALUE).
              $style(join("width:", job.getReduceProgressPercent(), '%'))._()._()._().
        td(String.valueOf(job.getReducesTotal())).
        td(String.valueOf(job.getReducesCompleted()))._();
  }
  tbody._()._();
}
 
Example #12
Source File: TaskPage.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
protected void render(Block html) {
  if (!isValidRequest()) {
    html.
      h2($(TITLE));
    return;
  }
  TBODY<TABLE<Hamlet>> tbody = html.
  table("#attempts").
    thead().
      tr().
        th(".id", "Attempt").
        th(".progress", "Progress").
        th(".state", "State").
        th(".status", "Status").
        th(".node", "Node").
        th(".logs", "Logs").
        th(".tsh", "Started").
        th(".tsh", "Finished").
        th(".tsh", "Elapsed").
        th(".note", "Note")._()._().
  tbody();
  // Write all the data into a JavaScript array of arrays for JQuery
  // DataTables to display
  StringBuilder attemptsTableData = new StringBuilder("[\n");

  for (TaskAttempt attempt : getTaskAttempts()) {
    TaskAttemptInfo ta = new TaskAttemptInfo(attempt, true);
    String progress = percent(ta.getProgress() / 100);

    String nodeHttpAddr = ta.getNode();
    String diag = ta.getNote() == null ? "" : ta.getNote();
    attemptsTableData.append("[\"")
    .append(ta.getId()).append("\",\"")
    .append(progress).append("\",\"")
    .append(ta.getState().toString()).append("\",\"")
    .append(StringEscapeUtils.escapeJavaScript(
          StringEscapeUtils.escapeHtml(ta.getStatus()))).append("\",\"")

    .append(nodeHttpAddr == null ? "N/A" :
      "<a class='nodelink' href='" + MRWebAppUtil.getYARNWebappScheme() + nodeHttpAddr + "'>"
      + nodeHttpAddr + "</a>")
    .append("\",\"")

    .append(ta.getAssignedContainerId() == null ? "N/A" :
      "<a class='logslink' href='" + url(MRWebAppUtil.getYARNWebappScheme(), nodeHttpAddr, "node"
        , "containerlogs", ta.getAssignedContainerIdStr(), app.getJob()
        .getUserName()) + "'>logs</a>")
      .append("\",\"")

    .append(ta.getStartTime()).append("\",\"")
    .append(ta.getFinishTime()).append("\",\"")
    .append(ta.getElapsedTime()).append("\",\"")
    .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(
      diag))).append("\"],\n");
  }
  //Remove the last comma and close off the array of arrays
  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._()._();

}
 
Example #13
Source File: TasksBlock.java    From big-c with Apache License 2.0 4 votes vote down vote up
@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);
  }
  TBODY<TABLE<Hamlet>> tbody = html.
    table("#tasks").
      thead().
        tr().
          th("Task").
          th("Progress").
          th("Status").
          th("State").
          th("Start Time").
          th("Finish Time").
          th("Elapsed Time")._()._().
      tbody();
  StringBuilder tasksTableData = new StringBuilder("[\n");

  for (Task task : app.getJob().getTasks().values()) {
    if (type != null && task.getType() != type) {
      continue;
    }
    String taskStateStr = $(TASK_STATE);
    if (taskStateStr == null || taskStateStr.trim().equals("")) {
      taskStateStr = "ALL";
    }

    if (!taskStateStr.equalsIgnoreCase("ALL"))
    {
      try {
        // get stateUI enum
        MRApps.TaskStateUI stateUI = MRApps.taskState(taskStateStr);
        if (!stateUI.correspondsTo(task.getState()))
        {
          continue;
        }
      } catch (IllegalArgumentException e) {
        continue; // not supported state, ignore
      }
    }

    TaskInfo info = new TaskInfo(task);
    String tid = info.getId();
    String pct = percent(info.getProgress() / 100);
    tasksTableData.append("[\"<a href='").append(url("task", tid))
    .append("'>").append(tid).append("</a>\",\"")
    //Progress bar
    .append("<br title='").append(pct)
    .append("'> <div class='").append(C_PROGRESSBAR).append("' title='")
    .append(join(pct, '%')).append("'> ").append("<div class='")
    .append(C_PROGRESSBAR_VALUE).append("' style='")
    .append(join("width:", pct, '%')).append("'> </div> </div>\",\"")
    .append(StringEscapeUtils.escapeJavaScript(
            StringEscapeUtils.escapeHtml(info.getStatus()))).append("\",\"")

    .append(info.getState()).append("\",\"")
    .append(info.getStartTime()).append("\",\"")
    .append(info.getFinishTime()).append("\",\"")
    .append(info.getElapsedTime()).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)._();

  tbody._()._();
}
 
Example #14
Source File: CountersBlock.java    From big-c with Apache License 2.0 4 votes vote down vote up
@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._()._()._();
}
 
Example #15
Source File: ConfBlock.java    From big-c with Apache License 2.0 4 votes vote down vote up
@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().h3(confPath.toString())._();
    TBODY<TABLE<Hamlet>> tbody = html.
      // Tasks table
    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) {
          // \u2B05 is an arrow <--
          buffer.append(" \u2B05 ");
        }
        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);
  }
}
 
Example #16
Source File: RMAppBlock.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
protected void createApplicationAttemptTable(Block html,
    Collection<ApplicationAttemptReport> attempts) {
  TBODY<TABLE<Hamlet>> tbody =
      html.table("#attempts").thead().tr().th(".id", "Attempt ID")
        .th(".started", "Started").th(".node", "Node").th(".logs", "Logs")
        ._()._().tbody();
  RMApp rmApp = this.rm.getRMContext().getRMApps().get(this.appID);
  if (rmApp == null) {
    return;
  }
  StringBuilder attemptsTableData = new StringBuilder("[\n");
  for (final ApplicationAttemptReport appAttemptReport : attempts) {
    RMAppAttempt rmAppAttempt =
        rmApp.getRMAppAttempt(appAttemptReport.getApplicationAttemptId());
    if (rmAppAttempt == null) {
      continue;
    }
    AppAttemptInfo attemptInfo =
        new AppAttemptInfo(rmAppAttempt, rmApp.getUser());
    String nodeLink = attemptInfo.getNodeHttpAddress();
    if (nodeLink != null) {
      nodeLink = WebAppUtils.getHttpSchemePrefix(conf) + nodeLink;
    }
    String logsLink = attemptInfo.getLogsLink();
    attemptsTableData
      .append("[\"<a href='")
      .append(url("appattempt", rmAppAttempt.getAppAttemptId().toString()))
      .append("'>")
      .append(String.valueOf(rmAppAttempt.getAppAttemptId()))
      .append("</a>\",\"")
      .append(attemptInfo.getStartTime())
      .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._()._();
}
 
Example #17
Source File: FairSchedulerAppsBlock.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override public void render(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(".fairshare", "Fair Share").
          th(".starttime", "StartTime").
          th(".finishtime", "FinishTime").
          th(".state", "State").
          th(".finalstatus", "FinalStatus").
          th(".progress", "Progress").
          th(".ui", "Tracking UI")._()._().
      tbody();
  Collection<YarnApplicationState> reqAppStates = null;
  String reqStateString = $(APP_STATE);
  if (reqStateString != null && !reqStateString.isEmpty()) {
    String[] appStateStrings = reqStateString.split(",");
    reqAppStates = new HashSet<YarnApplicationState>(appStateStrings.length);
    for(String stateString : appStateStrings) {
      reqAppStates.add(YarnApplicationState.valueOf(stateString));
    }
  }
  StringBuilder appsTableData = new StringBuilder("[\n");
  for (RMApp app : apps.values()) {
    if (reqAppStates != null && !reqAppStates.contains(app.createApplicationState())) {
      continue;
    }
    AppInfo appInfo = new AppInfo(rm, app, true, WebAppUtils.getHttpSchemePrefix(conf));
    String percent = String.format("%.1f", appInfo.getProgress());
    ApplicationAttemptId attemptId = app.getCurrentAppAttempt().getAppAttemptId();
    int fairShare = fsinfo.getAppFairShare(attemptId);
    if (fairShare == FairSchedulerInfo.INVALID_FAIR_SHARE) {
      // FairScheduler#applications don't have the entry. Skip it.
      continue;
    }
    appsTableData.append("[\"<a href='")
    .append(url("app", appInfo.getAppId())).append("'>")
    .append(appInfo.getAppId()).append("</a>\",\"")
    .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(
      appInfo.getUser()))).append("\",\"")
    .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(
      appInfo.getName()))).append("\",\"")
    .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(
      appInfo.getApplicationType()))).append("\",\"")
    .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(
      appInfo.getQueue()))).append("\",\"")
    .append(fairShare).append("\",\"")
    .append(appInfo.getStartTime()).append("\",\"")
    .append(appInfo.getFinishTime()).append("\",\"")
    .append(appInfo.getState()).append("\",\"")
    .append(appInfo.getFinalStatus()).append("\",\"")
    // Progress bar
    .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 href='");

    String trackingURL =
      !appInfo.isTrackingUrlReady()? "#" : appInfo.getTrackingUrlPretty();
    
    appsTableData.append(trackingURL).append("'>")
    .append(appInfo.getTrackingUI()).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._()._();
}
 
Example #18
Source File: AppBlock.java    From hadoop with Apache License 2.0 4 votes vote down vote up
protected void createApplicationAttemptTable(Block html,
    Collection<ApplicationAttemptReport> attempts) {
  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 = null;
    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;
            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._()._();
}
 
Example #19
Source File: HsJobsBlock.java    From big-c with Apache License 2.0 4 votes vote down vote up
@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")._()._().
      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(dateFormat.format(new Date(job.getStartTime()))).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("\"],\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("start_time").$value("Job ID")._()._().
      th().input("search_init").$type(InputType.text).$name("start_time").$value("Name")._()._().
      th().input("search_init").$type(InputType.text).$name("start_time").$value("User")._()._().
      th().input("search_init").$type(InputType.text).$name("start_time").$value("Queue")._()._().
      th().input("search_init").$type(InputType.text).$name("start_time").$value("State")._()._().
      th().input("search_init").$type(InputType.text).$name("start_time").$value("Maps Total")._()._().
      th().input("search_init").$type(InputType.text).$name("start_time").$value("Maps Completed")._()._().
      th().input("search_init").$type(InputType.text).$name("start_time").$value("Reduces Total")._()._().
      th().input("search_init").$type(InputType.text).$name("start_time").$value("Reduces Completed")._()._().
      _().
    _().
  _();
}
 
Example #20
Source File: NodesPage.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
protected void render(Block html) {
  html._(MetricsOverviewTable.class);

  ResourceScheduler sched = rm.getResourceScheduler();
  String type = $(NODE_STATE);
  String labelFilter = $(NODE_LABEL, CommonNodeLabelsManager.ANY).trim();
  TBODY<TABLE<Hamlet>> tbody =
      html.table("#nodes").thead().tr()
          .th(".nodelabels", "Node Labels")
          .th(".rack", "Rack")
          .th(".state", "Node State")
          .th(".nodeaddress", "Node Address")
          .th(".nodehttpaddress", "Node HTTP Address")
          .th(".lastHealthUpdate", "Last health-update")
          .th(".healthReport", "Health-report")
          .th(".containers", "Containers")
          .th(".mem", "Mem Used")
          .th(".mem", "Mem Avail")
          .th(".vcores", "VCores Used")
          .th(".vcores", "VCores Avail")
          .th(".nodeManagerVersion", "Version")._()._().tbody();
  NodeState stateFilter = null;
  if (type != null && !type.isEmpty()) {
    stateFilter = NodeState.valueOf(StringUtils.toUpperCase(type));
  }
  Collection<RMNode> rmNodes = this.rm.getRMContext().getRMNodes().values();
  boolean isInactive = false;
  if (stateFilter != null) {
    switch (stateFilter) {
    case DECOMMISSIONED:
    case LOST:
    case REBOOTED:
      rmNodes = this.rm.getRMContext().getInactiveRMNodes().values();
      isInactive = true;
      break;
    default:
      LOG.debug("Unexpected state filter for inactive RM node");
    }
  }
  for (RMNode ni : rmNodes) {
    if (stateFilter != null) {
      NodeState state = ni.getState();
      if (!stateFilter.equals(state)) {
        continue;
      }
    } else {
      // No filter. User is asking for all nodes. Make sure you skip the
      // unhealthy nodes.
      if (ni.getState() == NodeState.UNHEALTHY) {
        continue;
      }
    }
    // Besides state, we need to filter label as well.
    if (!labelFilter.equals(RMNodeLabelsManager.ANY)) {
      if (labelFilter.isEmpty()) {
        // Empty label filter means only shows nodes without label
        if (!ni.getNodeLabels().isEmpty()) {
          continue;
        }
      } else if (!ni.getNodeLabels().contains(labelFilter)) {
        // Only nodes have given label can show on web page.
        continue;
      }
    }
    NodeInfo info = new NodeInfo(ni, sched);
    int usedMemory = (int) info.getUsedMemory();
    int availableMemory = (int) info.getAvailableMemory();
    TR<TBODY<TABLE<Hamlet>>> row =
        tbody.tr().td(StringUtils.join(",", info.getNodeLabels()))
            .td(info.getRack()).td(info.getState()).td(info.getNodeId());
    if (isInactive) {
      row.td()._("N/A")._();
    } else {
      String httpAddress = info.getNodeHTTPAddress();
      row.td().a("//" + httpAddress, httpAddress)._();
    }
    row.td().br().$title(String.valueOf(info.getLastHealthUpdate()))._()
        ._(Times.format(info.getLastHealthUpdate()))._()
        .td(info.getHealthReport())
        .td(String.valueOf(info.getNumContainers())).td().br()
        .$title(String.valueOf(usedMemory))._()
        ._(StringUtils.byteDesc(usedMemory * BYTES_IN_MB))._().td().br()
        .$title(String.valueOf(availableMemory))._()
        ._(StringUtils.byteDesc(availableMemory * BYTES_IN_MB))._()
        .td(String.valueOf(info.getUsedVirtualCores()))
        .td(String.valueOf(info.getAvailableVirtualCores()))
        .td(ni.getNodeManagerVersion())._();
  }
  tbody._()._();
}
 
Example #21
Source File: AppBlock.java    From big-c with Apache License 2.0 4 votes vote down vote up
protected void createApplicationAttemptTable(Block html,
    Collection<ApplicationAttemptReport> attempts) {
  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 = null;
    try {
      // AM container is always the first container of the attempt
      final GetContainerReportRequest request =
          GetContainerReportRequest.newInstance(ContainerId.newContainerId(
            appAttemptReport.getApplicationAttemptId(), 1));
      if (callerUGI == null) {
        containerReport =
            appBaseProt.getContainerReport(request).getContainerReport();
      } else {
        containerReport = callerUGI.doAs(
            new PrivilegedExceptionAction<ContainerReport> () {
          @Override
          public ContainerReport run() throws Exception {
            ContainerReport report = 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._()._();
}
 
Example #22
Source File: HsJobsBlock.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@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")._()._().
      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(dateFormat.format(new Date(job.getStartTime()))).append("\",\"")
    .append(dateFormat.format(new Date(job.getFinishTime()))).append("\",\"")
    .append("<a target='_blank' 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("\"],\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("start_time").$value("Job ID")._()._().
      th().input("search_init").$type(InputType.text).$name("start_time").$value("Name")._()._().
      th().input("search_init").$type(InputType.text).$name("start_time").$value("User")._()._().
      th().input("search_init").$type(InputType.text).$name("start_time").$value("Queue")._()._().
      th().input("search_init").$type(InputType.text).$name("start_time").$value("State")._()._().
      th().input("search_init").$type(InputType.text).$name("start_time").$value("Maps Total")._()._().
      th().input("search_init").$type(InputType.text).$name("start_time").$value("Maps Completed")._()._().
      th().input("search_init").$type(InputType.text).$name("start_time").$value("Reduces Total")._()._().
      th().input("search_init").$type(InputType.text).$name("start_time").$value("Reduces Completed")._()._().
      _().
    _().
  _();
}
 
Example #23
Source File: ConfBlock.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@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().h3(confPath.toString())._();
    TBODY<TABLE<Hamlet>> tbody = html.
      // Tasks table
    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) {
          // \u2B05 is an arrow <--
          buffer.append(" \u2B05 ");
        }
        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);
  }
}
 
Example #24
Source File: CountersBlock.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@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._()._()._();
}
 
Example #25
Source File: JobsBlock.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@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()))._(). // for sorting
          a(url("job", job.getId()), job.getId())._().
        td(job.getName()).
        td(job.getState()).
        td().
          span().$title(job.getMapProgressPercent())._(). // for sorting
          div(_PROGRESSBAR).
            $title(join(job.getMapProgressPercent(), '%')). // tooltip
            div(_PROGRESSBAR_VALUE).
              $style(join("width:", job.getMapProgressPercent(), '%'))._()._()._().
        td(String.valueOf(job.getMapsTotal())).
        td(String.valueOf(job.getMapsCompleted())).
        td().
          span().$title(job.getReduceProgressPercent())._(). // for sorting
          div(_PROGRESSBAR).
            $title(join(job.getReduceProgressPercent(), '%')). // tooltip
            div(_PROGRESSBAR_VALUE).
              $style(join("width:", job.getReduceProgressPercent(), '%'))._()._()._().
        td(String.valueOf(job.getReducesTotal())).
        td(String.valueOf(job.getReducesCompleted()))._();
  }
  tbody._()._();
}
 
Example #26
Source File: TaskPage.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
protected void render(Block html) {
  if (!isValidRequest()) {
    html.
      h2($(TITLE));
    return;
  }
  TBODY<TABLE<Hamlet>> tbody = html.
  table("#attempts").
    thead().
      tr().
        th(".id", "Attempt").
        th(".progress", "Progress").
        th(".state", "State").
        th(".status", "Status").
        th(".node", "Node").
        th(".logs", "Logs").
        th(".tsh", "Started").
        th(".tsh", "Finished").
        th(".tsh", "Elapsed").
        th(".note", "Note")._()._().
  tbody();
  // Write all the data into a JavaScript array of arrays for JQuery
  // DataTables to display
  StringBuilder attemptsTableData = new StringBuilder("[\n");

  for (TaskAttempt attempt : getTaskAttempts()) {
    TaskAttemptInfo ta = new TaskAttemptInfo(attempt, true);
    String progress = percent(ta.getProgress() / 100);

    String nodeHttpAddr = ta.getNode();
    String diag = ta.getNote() == null ? "" : ta.getNote();
    attemptsTableData.append("[\"")
    .append(ta.getId()).append("\",\"")
    .append(progress).append("\",\"")
    .append(ta.getState().toString()).append("\",\"")
    .append(StringEscapeUtils.escapeJavaScript(
          StringEscapeUtils.escapeHtml(ta.getStatus()))).append("\",\"")

    .append(nodeHttpAddr == null ? "N/A" :
      "<a class='nodelink' href='" + MRWebAppUtil.getYARNWebappScheme() + nodeHttpAddr + "'>"
      + nodeHttpAddr + "</a>")
    .append("\",\"")

    .append(ta.getAssignedContainerId() == null ? "N/A" :
      "<a class='logslink' href='" + url(MRWebAppUtil.getYARNWebappScheme(), nodeHttpAddr, "node"
        , "containerlogs", ta.getAssignedContainerIdStr(), app.getJob()
        .getUserName()) + "'>logs</a>")
      .append("\",\"")

    .append(ta.getStartTime()).append("\",\"")
    .append(ta.getFinishTime()).append("\",\"")
    .append(ta.getElapsedTime()).append("\",\"")
    .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(
      diag))).append("\"],\n");
  }
  //Remove the last comma and close off the array of arrays
  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._()._();

}
 
Example #27
Source File: TasksBlock.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@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);
  }
  TBODY<TABLE<Hamlet>> tbody = html.
    table("#tasks").
      thead().
        tr().
          th("Task").
          th("Progress").
          th("Status").
          th("State").
          th("Start Time").
          th("Finish Time").
          th("Elapsed Time")._()._().
      tbody();
  StringBuilder tasksTableData = new StringBuilder("[\n");

  for (Task task : app.getJob().getTasks().values()) {
    if (type != null && task.getType() != type) {
      continue;
    }
    String taskStateStr = $(TASK_STATE);
    if (taskStateStr == null || taskStateStr.trim().equals("")) {
      taskStateStr = "ALL";
    }

    if (!taskStateStr.equalsIgnoreCase("ALL"))
    {
      try {
        // get stateUI enum
        MRApps.TaskStateUI stateUI = MRApps.taskState(taskStateStr);
        if (!stateUI.correspondsTo(task.getState()))
        {
          continue;
        }
      } catch (IllegalArgumentException e) {
        continue; // not supported state, ignore
      }
    }

    TaskInfo info = new TaskInfo(task);
    String tid = info.getId();
    String pct = percent(info.getProgress() / 100);
    tasksTableData.append("[\"<a href='").append(url("task", tid))
    .append("'>").append(tid).append("</a>\",\"")
    //Progress bar
    .append("<br title='").append(pct)
    .append("'> <div class='").append(C_PROGRESSBAR).append("' title='")
    .append(join(pct, '%')).append("'> ").append("<div class='")
    .append(C_PROGRESSBAR_VALUE).append("' style='")
    .append(join("width:", pct, '%')).append("'> </div> </div>\",\"")
    .append(StringEscapeUtils.escapeJavaScript(
            StringEscapeUtils.escapeHtml(info.getStatus()))).append("\",\"")

    .append(info.getState()).append("\",\"")
    .append(info.getStartTime()).append("\",\"")
    .append(info.getFinishTime()).append("\",\"")
    .append(info.getElapsedTime()).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)._();

  tbody._()._();
}
 
Example #28
Source File: RMAppBlock.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
protected void createApplicationAttemptTable(Block html,
    Collection<ApplicationAttemptReport> attempts) {
  TBODY<TABLE<Hamlet>> tbody =
      html.table("#attempts").thead().tr().th(".id", "Attempt ID")
        .th(".started", "Started").th(".node", "Node").th(".logs", "Logs")
        ._()._().tbody();
  RMApp rmApp = this.rm.getRMContext().getRMApps().get(this.appID);
  if (rmApp == null) {
    return;
  }
  StringBuilder attemptsTableData = new StringBuilder("[\n");
  for (final ApplicationAttemptReport appAttemptReport : attempts) {
    RMAppAttempt rmAppAttempt =
        rmApp.getRMAppAttempt(appAttemptReport.getApplicationAttemptId());
    if (rmAppAttempt == null) {
      continue;
    }
    AppAttemptInfo attemptInfo =
        new AppAttemptInfo(rmAppAttempt, rmApp.getUser());
    String nodeLink = attemptInfo.getNodeHttpAddress();
    if (nodeLink != null) {
      nodeLink = WebAppUtils.getHttpSchemePrefix(conf) + nodeLink;
    }
    String logsLink = attemptInfo.getLogsLink();
    attemptsTableData
      .append("[\"<a href='")
      .append(url("appattempt", rmAppAttempt.getAppAttemptId().toString()))
      .append("'>")
      .append(String.valueOf(rmAppAttempt.getAppAttemptId()))
      .append("</a>\",\"")
      .append(attemptInfo.getStartTime())
      .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._()._();
}
 
Example #29
Source File: FairSchedulerAppsBlock.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override public void render(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(".fairshare", "Fair Share").
          th(".starttime", "StartTime").
          th(".finishtime", "FinishTime").
          th(".state", "State").
          th(".finalstatus", "FinalStatus").
          th(".progress", "Progress").
          th(".ui", "Tracking UI")._()._().
      tbody();
  Collection<YarnApplicationState> reqAppStates = null;
  String reqStateString = $(APP_STATE);
  if (reqStateString != null && !reqStateString.isEmpty()) {
    String[] appStateStrings = reqStateString.split(",");
    reqAppStates = new HashSet<YarnApplicationState>(appStateStrings.length);
    for(String stateString : appStateStrings) {
      reqAppStates.add(YarnApplicationState.valueOf(stateString));
    }
  }
  StringBuilder appsTableData = new StringBuilder("[\n");
  for (RMApp app : apps.values()) {
    if (reqAppStates != null && !reqAppStates.contains(app.createApplicationState())) {
      continue;
    }
    AppInfo appInfo = new AppInfo(rm, app, true, WebAppUtils.getHttpSchemePrefix(conf));
    String percent = String.format("%.1f", appInfo.getProgress());
    ApplicationAttemptId attemptId = app.getCurrentAppAttempt().getAppAttemptId();
    int fairShare = fsinfo.getAppFairShare(attemptId);
    if (fairShare == FairSchedulerInfo.INVALID_FAIR_SHARE) {
      // FairScheduler#applications don't have the entry. Skip it.
      continue;
    }
    appsTableData.append("[\"<a href='")
    .append(url("app", appInfo.getAppId())).append("'>")
    .append(appInfo.getAppId()).append("</a>\",\"")
    .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(
      appInfo.getUser()))).append("\",\"")
    .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(
      appInfo.getName()))).append("\",\"")
    .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(
      appInfo.getApplicationType()))).append("\",\"")
    .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(
      appInfo.getQueue()))).append("\",\"")
    .append(fairShare).append("\",\"")
    .append(appInfo.getStartTime()).append("\",\"")
    .append(appInfo.getFinishTime()).append("\",\"")
    .append(appInfo.getState()).append("\",\"")
    .append(appInfo.getFinalStatus()).append("\",\"")
    // Progress bar
    .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 href='");

    String trackingURL =
      !appInfo.isTrackingUrlReady()? "#" : appInfo.getTrackingUrlPretty();
    
    appsTableData.append(trackingURL).append("'>")
    .append(appInfo.getTrackingUI()).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._()._();
}
 
Example #30
Source File: NodesPage.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
protected void render(Block html) {
  html._(MetricsOverviewTable.class);

  ResourceScheduler sched = rm.getResourceScheduler();
  String type = $(NODE_STATE);
  String labelFilter = $(NODE_LABEL, CommonNodeLabelsManager.ANY).trim();
  TBODY<TABLE<Hamlet>> tbody =
      html.table("#nodes").thead().tr()
          .th(".nodelabels", "Node Labels")
          .th(".rack", "Rack")
          .th(".state", "Node State")
          .th(".nodeaddress", "Node Address")
          .th(".nodehttpaddress", "Node HTTP Address")
          .th(".lastHealthUpdate", "Last health-update")
          .th(".healthReport", "Health-report")
          .th(".containers", "Containers")
          .th(".mem", "Mem Used")
          .th(".mem", "Mem Avail")
          .th(".vcores", "VCores Used")
          .th(".vcores", "VCores Avail")
          .th(".gcores", "GCores Used")
          .th(".gcores", "GCores Avail")
          .th(".nodeManagerVersion", "Version")._()._().tbody();
  NodeState stateFilter = null;
  if (type != null && !type.isEmpty()) {
    stateFilter = NodeState.valueOf(StringUtils.toUpperCase(type));
  }
  Collection<RMNode> rmNodes = this.rm.getRMContext().getRMNodes().values();
  boolean isInactive = false;
  if (stateFilter != null) {
    switch (stateFilter) {
    case DECOMMISSIONED:
    case LOST:
    case REBOOTED:
      rmNodes = this.rm.getRMContext().getInactiveRMNodes().values();
      isInactive = true;
      break;
    default:
      LOG.debug("Unexpected state filter for inactive RM node");
    }
  }
  for (RMNode ni : rmNodes) {
    if (stateFilter != null) {
      NodeState state = ni.getState();
      if (!stateFilter.equals(state)) {
        continue;
      }
    } else {
      // No filter. User is asking for all nodes. Make sure you skip the
      // unhealthy nodes.
      if (ni.getState() == NodeState.UNHEALTHY) {
        continue;
      }
    }
    // Besides state, we need to filter label as well.
    if (!labelFilter.equals(RMNodeLabelsManager.ANY)) {
      if (labelFilter.isEmpty()) {
        // Empty label filter means only shows nodes without label
        if (!ni.getNodeLabels().isEmpty()) {
          continue;
        }
      } else if (!ni.getNodeLabels().contains(labelFilter)) {
        // Only nodes have given label can show on web page.
        continue;
      }
    }
    NodeInfo info = new NodeInfo(ni, sched);
    int usedMemory = (int) info.getUsedMemory();
    int availableMemory = (int) info.getAvailableMemory();
    TR<TBODY<TABLE<Hamlet>>> row =
        tbody.tr().td(StringUtils.join(",", info.getNodeLabels()))
            .td(info.getRack()).td(info.getState()).td(info.getNodeId());
    if (isInactive) {
      row.td()._("N/A")._();
    } else {
      String httpAddress = info.getNodeHTTPAddress();
      row.td().a("//" + httpAddress, httpAddress)._();
    }
    row.td().br().$title(String.valueOf(info.getLastHealthUpdate()))._()
        ._(Times.format(info.getLastHealthUpdate()))._()
        .td(info.getHealthReport())
        .td(String.valueOf(info.getNumContainers())).td().br()
        .$title(String.valueOf(usedMemory))._()
        ._(StringUtils.byteDesc(usedMemory * BYTES_IN_MB))._().td().br()
        .$title(String.valueOf(availableMemory))._()
        ._(StringUtils.byteDesc(availableMemory * BYTES_IN_MB))._()
        .td(String.valueOf(info.getUsedVirtualCores()))
        .td(String.valueOf(info.getAvailableVirtualCores()))
        .td(String.valueOf(info.getUsedGpuCores()))
        .td(String.valueOf(info.getAvailableGpuCores()))
        .td(ni.getNodeManagerVersion())._();
  }
  tbody._()._();
}