Java源码示例:org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo

示例1
@GET
@Path("/apps/{appid}/appattempts/{appattemptid}/containers/{containerid}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Override
public ContainerInfo getContainer(@Context HttpServletRequest req,
    @Context HttpServletResponse res, @PathParam("appid") String appId,
    @PathParam("appattemptid") String appAttemptId,
    @PathParam("containerid") String containerId) {
  init(res);
  return super.getContainer(req, res, appId, appAttemptId, containerId);
}
 
示例2
@GET
@Path("/apps/{appid}/appattempts/{appattemptid}/containers/{containerid}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Override
public ContainerInfo getContainer(@Context HttpServletRequest req,
    @Context HttpServletResponse res, @PathParam("appid") String appId,
    @PathParam("appattemptid") String appAttemptId,
    @PathParam("containerid") String containerId) {
  init(res);
  return super.getContainer(req, res, appId, appAttemptId, containerId);
}
 
示例3
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._()._();
}
 
示例4
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._()._();
}