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

The following examples show how to use org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TR. 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: 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 #2
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 #3
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 #4
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 #5
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._()._();
}
 
Example #6
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 #7
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 #8
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._()._()._();
}