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

The following examples show how to use org.apache.hadoop.yarn.webapp.hamlet.Hamlet. 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: 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 #2
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 #3
Source File: NavBlock.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override public void render(Block html) {
  UL<DIV<Hamlet>> mainList = html.
    div("#nav").
      h3("Cluster").
      ul().
        li().a(url("cluster"), "About")._().
        li().a(url("nodes"), "Nodes")._().
        li().a(url("nodelabels"), "Node Labels")._();
  UL<LI<UL<DIV<Hamlet>>>> subAppsList = mainList.
        li().a(url("apps"), "Applications").
          ul();
  subAppsList.li()._();
  for (YarnApplicationState state : YarnApplicationState.values()) {
    subAppsList.
            li().a(url("apps", state.toString()), state.toString())._();
  }
  subAppsList._()._();
  mainList.
        li().a(url("scheduler"), "Scheduler")._()._().
      h3("Tools").
      ul().
        li().a("/conf", "Configuration")._().
        li().a("/logs", "Local logs")._().
        li().a("/stacks", "Server stacks")._().
        li().a("/jmx?qry=Hadoop:*", "Server metrics")._()._()._();
}
 
Example #4
Source File: ApplicationPage.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Override
protected void render(Block html) {
  ApplicationId applicationID =
      ConverterUtils.toApplicationId(this.recordFactory,
          $(APPLICATION_ID));
  Application app = this.nmContext.getApplications().get(applicationID);
  AppInfo info = new AppInfo(app);
  info("Application's information")
        ._("ApplicationId", info.getId())
        ._("ApplicationState", info.getState())
        ._("User", info.getUser());
  TABLE<Hamlet> containersListBody = html._(InfoBlock.class)
      .table("#containers");
  for (String containerIdStr : info.getContainers()) {
    containersListBody
           .tr().td()
             .a(url("container", containerIdStr), containerIdStr)
             ._()._();
  }
  containersListBody._();
}
 
Example #5
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 #6
Source File: RMAppAttemptBlock.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override
protected void createAttemptHeadRoomTable(Block html) {
  RMAppAttempt attempt = getRMAppAttempt();
  if (attempt != null) {
    if (!isApplicationInFinalState(YarnApplicationAttemptState
        .valueOf(attempt.getAppAttemptState().toString()))) {
      RMAppAttemptMetrics metrics = attempt.getRMAppAttemptMetrics();
      DIV<Hamlet> pdiv = html._(InfoBlock.class).div(_INFO_WRAP);
      info("Application Attempt Overview").clear();
      info("Application Attempt Metrics")._(
        "Application Attempt Headroom : ", metrics == null ? "N/A" :
          metrics.getApplicationAttemptHeadroom());
      pdiv._();
    }
  }
}
 
Example #7
Source File: TestHamlet.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test public void testEnumAttrs() {
  Hamlet h = newHamlet().
      meta_http("Content-type", "text/html; charset=utf-8").
      title("test enum attrs").
      link().$rel("stylesheet").
        $media(EnumSet.of(Media.screen, Media.print)).
        $type("text/css").$href("style.css")._().
      link().$rel(EnumSet.of(LinkType.index, LinkType.start)).
        $href("index.html")._();

  h.div("#content")._("content")._();

  PrintWriter out = h.getWriter();
  out.flush();
  assertEquals(0, h.nestLevel);
  verify(out).print(" media=\"screen, print\"");
  verify(out).print(" rel=\"start index\"");
}
 
Example #8
Source File: NavBlock.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Override public void render(Block html) {
  UL<DIV<Hamlet>> mainList = html.
    div("#nav").
      h3("Cluster").
      ul().
        li().a(url("cluster"), "About")._().
        li().a(url("nodes"), "Nodes")._().
        li().a(url("nodelabels"), "Node Labels")._();
  UL<LI<UL<DIV<Hamlet>>>> subAppsList = mainList.
        li().a(url("apps"), "Applications").
          ul();
  subAppsList.li()._();
  for (YarnApplicationState state : YarnApplicationState.values()) {
    subAppsList.
            li().a(url("apps", state.toString()), state.toString())._();
  }
  subAppsList._()._();
  mainList.
        li().a(url("scheduler"), "Scheduler")._()._().
      h3("Tools").
      ul().
        li().a("/conf", "Configuration")._().
        li().a("/logs", "Local logs")._().
        li().a("/stacks", "Server stacks")._().
        li().a("/jmx?qry=Hadoop:*", "Server metrics")._()._()._();
}
 
Example #9
Source File: ApplicationPage.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override
protected void render(Block html) {
  ApplicationId applicationID =
      ConverterUtils.toApplicationId(this.recordFactory,
          $(APPLICATION_ID));
  Application app = this.nmContext.getApplications().get(applicationID);
  AppInfo info = new AppInfo(app);
  info("Application's information")
        ._("ApplicationId", info.getId())
        ._("ApplicationState", info.getState())
        ._("User", info.getUser());
  TABLE<Hamlet> containersListBody = html._(InfoBlock.class)
      .table("#containers");
  for (String containerIdStr : info.getContainers()) {
    containersListBody
           .tr().td()
             .a(url("container", containerIdStr), containerIdStr)
             ._()._();
  }
  containersListBody._();
}
 
Example #10
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 #11
Source File: TestHamlet.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test public void testTable() {
  Hamlet h = newHamlet().
      title("test table").
      link("style.css");

  TABLE t = h.table("#id");

  for (int i = 0; i < 3; ++i) {
    t.tr().td("1").td("2")._();
  }
  t._();

  PrintWriter out = h.getWriter();
  out.flush();
  assertEquals(0, h.nestLevel);
  verify(out).print("<table");
  verify(out).print("</table>");
  verify(out, atLeast(1)).print("</td>");
  verify(out, atLeast(1)).print("</tr>");
}
 
Example #12
Source File: RMAppAttemptBlock.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Override
protected void createAttemptHeadRoomTable(Block html) {
  RMAppAttempt attempt = getRMAppAttempt();
  if (attempt != null) {
    if (!isApplicationInFinalState(YarnApplicationAttemptState
        .valueOf(attempt.getAppAttemptState().toString()))) {
      RMAppAttemptMetrics metrics = attempt.getRMAppAttemptMetrics();
      DIV<Hamlet> pdiv = html._(InfoBlock.class).div(_INFO_WRAP);
      info("Application Attempt Overview").clear();
      info("Application Attempt Metrics")._(
        "Application Attempt Headroom : ", metrics == null ? "N/A" :
          metrics.getApplicationAttemptHeadroom());
      pdiv._();
    }
  }
}
 
Example #13
Source File: TestHamlet.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test public void testEnumAttrs() {
  Hamlet h = newHamlet().
      meta_http("Content-type", "text/html; charset=utf-8").
      title("test enum attrs").
      link().$rel("stylesheet").
        $media(EnumSet.of(Media.screen, Media.print)).
        $type("text/css").$href("style.css")._().
      link().$rel(EnumSet.of(LinkType.index, LinkType.start)).
        $href("index.html")._();

  h.div("#content")._("content")._();

  PrintWriter out = h.getWriter();
  out.flush();
  assertEquals(0, h.nestLevel);
  verify(out).print(" media=\"screen, print\"");
  verify(out).print(" rel=\"start index\"");
}
 
Example #14
Source File: TestHamlet.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test public void testTable() {
  Hamlet h = newHamlet().
      title("test table").
      link("style.css");

  TABLE t = h.table("#id");

  for (int i = 0; i < 3; ++i) {
    t.tr().td("1").td("2")._();
  }
  t._();

  PrintWriter out = h.getWriter();
  out.flush();
  assertEquals(0, h.nestLevel);
  verify(out).print("<table");
  verify(out).print("</table>");
  verify(out, atLeast(1)).print("</td>");
  verify(out, atLeast(1)).print("</tr>");
}
 
Example #15
Source File: RMAppAttemptBlock.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void createContainerLocalityTable(Block html) {
  RMAppAttemptMetrics attemptMetrics = null;
  RMAppAttempt attempt = getRMAppAttempt();
  if (attempt != null) {
    attemptMetrics = attempt.getRMAppAttemptMetrics();
  }
  
  if (attemptMetrics == null) {
    return;
  }

  DIV<Hamlet> div = html.div(_INFO_WRAP);
  TABLE<DIV<Hamlet>> table =
      div.h3(
        "Total Allocated Containers: "
            + attemptMetrics.getTotalAllocatedContainers()).h3("Each table cell"
          + " represents the number of NodeLocal/RackLocal/OffSwitch containers"
          + " satisfied by NodeLocal/RackLocal/OffSwitch resource requests.").table(
        "#containerLocality");
  table.
    tr().
      th(_TH, "").
      th(_TH, "Node Local Request").
      th(_TH, "Rack Local Request").
      th(_TH, "Off Switch Request").
    _();

  String[] containersType =
      { "Num Node Local Containers (satisfied by)", "Num Rack Local Containers (satisfied by)",
          "Num Off Switch Containers (satisfied by)" };
  boolean odd = false;
  for (int i = 0; i < attemptMetrics.getLocalityStatistics().length; i++) {
    table.tr((odd = !odd) ? _ODD : _EVEN).td(containersType[i])
      .td(String.valueOf(attemptMetrics.getLocalityStatistics()[i][0]))
      .td(i == 0 ? "" : String.valueOf(attemptMetrics.getLocalityStatistics()[i][1]))
      .td(i <= 1 ? "" : String.valueOf(attemptMetrics.getLocalityStatistics()[i][2]))._();
  }
  table._();
  div._();
}
 
Example #16
Source File: TestHamlet.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test public void testScriptStyle() {
  Hamlet h = newHamlet().
      script("a.js").script("b.js").
      style("h1 { font-size: 1.2em }");

  PrintWriter out = h.getWriter();
  out.flush();
  assertEquals(0, h.nestLevel);
  verify(out, times(2)).print(" type=\"text/javascript\"");
  verify(out).print(" type=\"text/css\"");
}
 
Example #17
Source File: TestHamlet.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test public void testPreformatted() {
  Hamlet h = newHamlet().
      div().
        i("inline before pre").
        pre().
          _("pre text1\npre text2").
          i("inline in pre").
          _("pre text after inline")._().
        i("inline after pre")._();

  PrintWriter out = h.getWriter();
  out.flush();
  assertEquals(5, h.indents);
}
 
Example #18
Source File: TestHamlet.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test public void testHamlet() {
  Hamlet h = newHamlet().
      title("test").
      h1("heading 1").
      p("#id.class").
        b("hello").
        em("world!")._().
      div("#footer").
        _("Brought to you by").
        a("http://hostname/", "Somebody")._();

  PrintWriter out = h.getWriter();
  out.flush();
  assertEquals(0, h.nestLevel);
  verify(out).print("<title");
  verify(out).print("test");
  verify(out).print("</title>");
  verify(out).print("<h1");
  verify(out).print("heading 1");
  verify(out).print("</h1>");
  verify(out).print("<p");
  verify(out).print(" id=\"id\"");
  verify(out).print(" class=\"class\"");
  verify(out).print("<b");
  verify(out).print("hello");
  verify(out).print("</b>");
  verify(out).print("<em");
  verify(out).print("world!");
  verify(out).print("</em>");
  verify(out).print("<div");
  verify(out).print(" id=\"footer\"");
  verify(out).print("Brought to you by");
  verify(out).print("<a");
  verify(out).print(" href=\"http://hostname/\"");
  verify(out).print("Somebody");
  verify(out).print("</a>");
  verify(out).print("</div>");
  verify(out, never()).print("</p>");
}
 
Example #19
Source File: TestHamlet.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test public void testSubViews() {
  Hamlet h = newHamlet().
      title("test sub-views").
      div("#view1")._(TestView1.class)._().
      div("#view2")._(TestView2.class)._();

  PrintWriter out = h.getWriter();
  out.flush();
  assertEquals(0, h.nestLevel);
  verify(out).print("["+ TestView1.class.getName() +"]");
  verify(out).print("["+ TestView2.class.getName() +"]");
}
 
Example #20
Source File: HsNavBlock.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override protected void render(Block html) {
  DIV<Hamlet> nav = html.
    div("#nav").
    h3("Application").
      ul().
        li().a(url("about"), "About")._().
        li().a(url("app"), "Jobs")._()._();
  if (app.getJob() != null) {
    String jobid = MRApps.toString(app.getJob().getID());
    nav.
      h3("Job").
      ul().
        li().a(url("job", jobid), "Overview")._().
        li().a(url("jobcounters", jobid), "Counters")._().
        li().a(url("conf", jobid), "Configuration")._().
        li().a(url("tasks", jobid, "m"), "Map tasks")._().
        li().a(url("tasks", jobid, "r"), "Reduce tasks")._()._();
    if (app.getTask() != null) {
      String taskid = MRApps.toString(app.getTask().getID());
      nav.
        h3("Task").
        ul().
          li().a(url("task", taskid), "Task Overview")._().
          li().a(url("taskcounters", taskid), "Counters")._()._();
    }
  }
  nav.
    h3("Tools").
      ul().
        li().a("/conf", "Configuration")._().
        li().a("/logs", "Local logs")._().
        li().a("/stacks", "Server stacks")._().
        li().a("/jmx?qry=Hadoop:*", "Server metrics")._()._()._();
}
 
Example #21
Source File: TestHamlet.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test public void testHamlet() {
  Hamlet h = newHamlet().
      title("test").
      h1("heading 1").
      p("#id.class").
        b("hello").
        em("world!")._().
      div("#footer").
        _("Brought to you by").
        a("http://hostname/", "Somebody")._();

  PrintWriter out = h.getWriter();
  out.flush();
  assertEquals(0, h.nestLevel);
  verify(out).print("<title");
  verify(out).print("test");
  verify(out).print("</title>");
  verify(out).print("<h1");
  verify(out).print("heading 1");
  verify(out).print("</h1>");
  verify(out).print("<p");
  verify(out).print(" id=\"id\"");
  verify(out).print(" class=\"class\"");
  verify(out).print("<b");
  verify(out).print("hello");
  verify(out).print("</b>");
  verify(out).print("<em");
  verify(out).print("world!");
  verify(out).print("</em>");
  verify(out).print("<div");
  verify(out).print(" id=\"footer\"");
  verify(out).print("Brought to you by");
  verify(out).print("<a");
  verify(out).print(" href=\"http://hostname/\"");
  verify(out).print("Somebody");
  verify(out).print("</a>");
  verify(out).print("</div>");
  verify(out, never()).print("</p>");
}
 
Example #22
Source File: ContainerPage.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
protected void render(Block html) {
  ContainerId containerID;
  try {
    containerID = ConverterUtils.toContainerId($(CONTAINER_ID));
  } catch (IllegalArgumentException e) {
    html.p()._("Invalid containerId " + $(CONTAINER_ID))._();
    return;
  }

  DIV<Hamlet> div = html.div("#content");
  Container container = this.nmContext.getContainers().get(containerID);
  if (container == null) {
    div.h1("Unknown Container. Container might have completed, "
            + "please go back to the previous page and retry.")._();
    return;
  }
  ContainerInfo info = new ContainerInfo(this.nmContext, container);

  info("Container information")
    ._("ContainerID", info.getId())
    ._("ContainerState", info.getState())
    ._("ExitStatus", info.getExitStatus())
    ._("Diagnostics", info.getDiagnostics())
    ._("User", info.getUser())
    ._("TotalMemoryNeeded", info.getMemoryNeeded())
    ._("TotalVCoresNeeded", info.getVCoresNeeded())
    ._("logs", info.getShortLogLink(), "Link to logs");
  html._(InfoBlock.class);
}
 
Example #23
Source File: DefaultSchedulerPage.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void render(Block html) {
  html._(MetricsOverviewTable.class);
  UL<DIV<DIV<Hamlet>>> ul = html.
    div("#cs-wrapper.ui-widget").
      div(".ui-widget-header.ui-corner-top").
        _("FifoScheduler Queue")._().
      div("#cs.ui-widget-content.ui-corner-bottom").
        ul();

  if (fs == null) {
    ul.
      li().
        a(_Q).$style(width(WIDTH_F)).
          span().$style(Q_END)._("100% ")._().
          span(".q", "default")._()._();
  } else {
    float used = sinfo.getUsedCapacity();
    float set = sinfo.getCapacity();
    float delta = Math.abs(set - used) + 0.001f;
    ul.
      li().
        a(_Q).$style(width(WIDTH_F)).
          $title(join("used:", percent(used))).
          span().$style(Q_END)._("100%")._().
          span().$style(join(width(delta), ';', used > set ? OVER : UNDER,
            ';', used > set ? left(set) : left(used)))._(".")._().
          span(".q", sinfo.getQueueName())._().
        _(QueueInfoBlock.class)._();
  }

  ul._()._().
  script().$type("text/javascript").
      _("$('#cs').hide();")._()._().
  _(AppsBlock.class);
}
 
Example #24
Source File: FairSchedulerPage.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void render(Block html) {
  Collection<FairSchedulerQueueInfo> subQueues = fsqinfo.qinfo.getChildQueues();
  UL<Hamlet> ul = html.ul("#pq");
  for (FairSchedulerQueueInfo info : subQueues) {
    float capacity = info.getMaxResourcesFraction();
    float steadyFairShare = info.getSteadyFairShareMemoryFraction();
    float instantaneousFairShare = info.getFairShareMemoryFraction();
    float used = info.getUsedMemoryFraction();
    LI<UL<Hamlet>> li = ul.
      li().
        a(_Q).$style(width(capacity * Q_MAX_WIDTH)).
          $title(join(join(STEADY_FAIR_SHARE + ":", percent(steadyFairShare)),
              join(" " + INSTANTANEOUS_FAIR_SHARE + ":", percent(instantaneousFairShare)))).
          span().$style(join(Q_GIVEN, ";font-size:1px;", width(steadyFairShare / capacity))).
            _('.')._().
          span().$style(join(Q_INSTANTANEOUS_FS, ";font-size:1px;",
              width(instantaneousFairShare/capacity))).
            _('.')._().
          span().$style(join(width(used/capacity),
            ";font-size:1px;left:0%;", used > instantaneousFairShare ? Q_OVER : Q_UNDER)).
            _('.')._().
          span(".q", info.getQueueName())._().
        span().$class("qstats").$style(left(Q_STATS_POS)).
          _(join(percent(used), " used"))._();

    fsqinfo.qinfo = info;
    if (info instanceof FairSchedulerLeafQueueInfo) {
      li.ul("#lq").li()._(LeafQueueBlock.class)._()._();
    } else {
      li._(QueueBlock.class);
    }
    li._();
  }

  ul._();
}
 
Example #25
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 #26
Source File: CapacitySchedulerPage.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void render(Block html) {
  ArrayList<CapacitySchedulerQueueInfo> subQueues =
      (csqinfo.qinfo == null) ? csqinfo.csinfo.getQueues().getQueueInfoList()
          : csqinfo.qinfo.getQueues().getQueueInfoList();
  UL<Hamlet> ul = html.ul("#pq");
  for (CapacitySchedulerQueueInfo info : subQueues) {
    float used = info.getUsedCapacity() / 100;
    float absCap = info.getAbsoluteCapacity() / 100;
    float absMaxCap = info.getAbsoluteMaxCapacity() / 100;
    float absUsedCap = info.getAbsoluteUsedCapacity() / 100;
    LI<UL<Hamlet>> li = ul.
      li().
        a(_Q).$style(width(absMaxCap * Q_MAX_WIDTH)).
          $title(join("Absolute Capacity:", percent(absCap))).
          span().$style(join(Q_GIVEN, ";font-size:1px;", width(absCap/absMaxCap))).
            _('.')._().
          span().$style(join(width(absUsedCap/absMaxCap),
            ";font-size:1px;left:0%;", absUsedCap > absCap ? Q_OVER : Q_UNDER)).
            _('.')._().
          span(".q", info.getQueuePath().substring(5))._().
        span().$class("qstats").$style(left(Q_STATS_POS)).
          _(join(percent(used), " used"))._();

    csqinfo.qinfo = info;
    if (info.getQueues() == null) {
      li.ul("#lq").li()._(LeafQueueInfoBlock.class)._()._();
      li.ul("#lq").li()._(QueueUsersInfoBlock.class)._()._();
    } else {
      li._(QueueBlock.class);
    }
    li._();
  }

  ul._();
}
 
Example #27
Source File: RMAppAttemptBlock.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void createContainerLocalityTable(Block html) {
  RMAppAttemptMetrics attemptMetrics = null;
  RMAppAttempt attempt = getRMAppAttempt();
  if (attempt != null) {
    attemptMetrics = attempt.getRMAppAttemptMetrics();
  }
  
  if (attemptMetrics == null) {
    return;
  }

  DIV<Hamlet> div = html.div(_INFO_WRAP);
  TABLE<DIV<Hamlet>> table =
      div.h3(
        "Total Allocated Containers: "
            + attemptMetrics.getTotalAllocatedContainers()).h3("Each table cell"
          + " represents the number of NodeLocal/RackLocal/OffSwitch containers"
          + " satisfied by NodeLocal/RackLocal/OffSwitch resource requests.").table(
        "#containerLocality");
  table.
    tr().
      th(_TH, "").
      th(_TH, "Node Local Request").
      th(_TH, "Rack Local Request").
      th(_TH, "Off Switch Request").
    _();

  String[] containersType =
      { "Num Node Local Containers (satisfied by)", "Num Rack Local Containers (satisfied by)",
          "Num Off Switch Containers (satisfied by)" };
  boolean odd = false;
  for (int i = 0; i < attemptMetrics.getLocalityStatistics().length; i++) {
    table.tr((odd = !odd) ? _ODD : _EVEN).td(containersType[i])
      .td(String.valueOf(attemptMetrics.getLocalityStatistics()[i][0]))
      .td(i == 0 ? "" : String.valueOf(attemptMetrics.getLocalityStatistics()[i][1]))
      .td(i <= 1 ? "" : String.valueOf(attemptMetrics.getLocalityStatistics()[i][2]))._();
  }
  table._();
  div._();
}
 
Example #28
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 #29
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 #30
Source File: HsNavBlock.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override protected void render(Block html) {
  DIV<Hamlet> nav = html.
    div("#nav").
    h3("Application").
      ul().
        li().a(url("about"), "About")._().
        li().a(url("app"), "Jobs")._()._();
  if (app.getJob() != null) {
    String jobid = MRApps.toString(app.getJob().getID());
    nav.
      h3("Job").
      ul().
        li().a(url("job", jobid), "Overview")._().
        li().a(url("jobcounters", jobid), "Counters")._().
        li().a(url("conf", jobid), "Configuration")._().
        li().a(url("tasks", jobid, "m"), "Map tasks")._().
        li().a(url("tasks", jobid, "r"), "Reduce tasks")._()._();
    if (app.getTask() != null) {
      String taskid = MRApps.toString(app.getTask().getID());
      nav.
        h3("Task").
        ul().
          li().a(url("task", taskid), "Task Overview")._().
          li().a(url("taskcounters", taskid), "Counters")._()._();
    }
  }
  nav.
    h3("Tools").
      ul().
        li().a("/conf", "Configuration")._().
        li().a("/logs", "Local logs")._().
        li().a("/stacks", "Server stacks")._().
        li().a("/jmx?qry=Hadoop:*", "Server metrics")._()._()._();
}