Java Code Examples for org.apache.hadoop.yarn.webapp.util.WebAppUtils#getHttpSchemePrefix()

The following examples show how to use org.apache.hadoop.yarn.webapp.util.WebAppUtils#getHttpSchemePrefix() . 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: RMAppAttemptImpl.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private String generateProxyUriWithScheme() {
  this.readLock.lock();
  try {
    final String scheme = WebAppUtils.getHttpSchemePrefix(conf);
    String proxy = WebAppUtils.getProxyHostAndPort(conf);
    URI proxyUri = ProxyUriUtils.getUriFromAMUrl(scheme, proxy);
    URI result = ProxyUriUtils.getProxyUri(null, proxyUri,
        applicationAttemptId.getApplicationId());
    return result.toASCIIString();
  } catch (URISyntaxException e) {
    LOG.warn("Could not proxify the uri for "
        + applicationAttemptId.getApplicationId(), e);
    return null;
  } finally {
    this.readLock.unlock();
  }
}
 
Example 2
Source File: RMAppAttemptImpl.java    From big-c with Apache License 2.0 6 votes vote down vote up
private String generateProxyUriWithScheme() {
  this.readLock.lock();
  try {
    final String scheme = WebAppUtils.getHttpSchemePrefix(conf);
    String proxy = WebAppUtils.getProxyHostAndPort(conf);
    URI proxyUri = ProxyUriUtils.getUriFromAMUrl(scheme, proxy);
    URI result = ProxyUriUtils.getProxyUri(null, proxyUri,
        applicationAttemptId.getApplicationId());
    return result.toASCIIString();
  } catch (URISyntaxException e) {
    LOG.warn("Could not proxify the uri for "
        + applicationAttemptId.getApplicationId(), e);
    return null;
  } finally {
    this.readLock.unlock();
  }
}
 
Example 3
Source File: RMAppImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private String getDefaultProxyTrackingUrl() {
  try {
    final String scheme = WebAppUtils.getHttpSchemePrefix(conf);
    String proxy = WebAppUtils.getProxyHostAndPort(conf);
    URI proxyUri = ProxyUriUtils.getUriFromAMUrl(scheme, proxy);
    URI result = ProxyUriUtils.getProxyUri(null, proxyUri, applicationId);
    return result.toASCIIString();
  } catch (URISyntaxException e) {
    LOG.warn("Could not generate default proxy tracking URL for "
        + applicationId);
    return UNAVAILABLE;
  }
}
 
Example 4
Source File: TestRMAppAttemptTransitions.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private String getProxyUrl(RMAppAttempt appAttempt) {
  String url = null;
  final String scheme = WebAppUtils.getHttpSchemePrefix(conf);
  try {
    String proxy = WebAppUtils.getProxyHostAndPort(conf);
    URI proxyUri = ProxyUriUtils.getUriFromAMUrl(scheme, proxy);
    URI result = ProxyUriUtils.getProxyUri(null, proxyUri, appAttempt
        .getAppAttemptId().getApplicationId());
    url = result.toASCIIString();
  } catch (URISyntaxException ex) {
    Assert.fail();
  }
  return url;
}
 
Example 5
Source File: ApplicationHistoryManagerImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
protected void serviceInit(Configuration conf) throws Exception {
  LOG.info("ApplicationHistory Init");
  historyStore = createApplicationHistoryStore(conf);
  historyStore.init(conf);
  serverHttpAddress = WebAppUtils.getHttpSchemePrefix(conf) +
      WebAppUtils.getAHSWebAppURLWithoutScheme(conf);
  super.serviceInit(conf);
}
 
Example 6
Source File: RMAppImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
private String getDefaultProxyTrackingUrl() {
  try {
    final String scheme = WebAppUtils.getHttpSchemePrefix(conf);
    String proxy = WebAppUtils.getProxyHostAndPort(conf);
    URI proxyUri = ProxyUriUtils.getUriFromAMUrl(scheme, proxy);
    URI result = ProxyUriUtils.getProxyUri(null, proxyUri, applicationId);
    return result.toASCIIString();
  } catch (URISyntaxException e) {
    LOG.warn("Could not generate default proxy tracking URL for "
        + applicationId);
    return UNAVAILABLE;
  }
}
 
Example 7
Source File: TestRMAppAttemptTransitions.java    From big-c with Apache License 2.0 5 votes vote down vote up
private String getProxyUrl(RMAppAttempt appAttempt) {
  String url = null;
  final String scheme = WebAppUtils.getHttpSchemePrefix(conf);
  try {
    String proxy = WebAppUtils.getProxyHostAndPort(conf);
    URI proxyUri = ProxyUriUtils.getUriFromAMUrl(scheme, proxy);
    URI result = ProxyUriUtils.getProxyUri(null, proxyUri, appAttempt
        .getAppAttemptId().getApplicationId());
    url = result.toASCIIString();
  } catch (URISyntaxException ex) {
    Assert.fail();
  }
  return url;
}
 
Example 8
Source File: ApplicationHistoryManagerImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
protected void serviceInit(Configuration conf) throws Exception {
  LOG.info("ApplicationHistory Init");
  historyStore = createApplicationHistoryStore(conf);
  historyStore.init(conf);
  serverHttpAddress = WebAppUtils.getHttpSchemePrefix(conf) +
      WebAppUtils.getAHSWebAppURLWithoutScheme(conf);
  super.serviceInit(conf);
}
 
Example 9
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 10
Source File: RMAppAttemptBlock.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private void createResourceRequestsTable(Block html) {
  AppInfo app =
      new AppInfo(rm, rm.getRMContext().getRMApps()
        .get(this.appAttemptId.getApplicationId()), true,
        WebAppUtils.getHttpSchemePrefix(conf));

  List<ResourceRequest> resourceRequests = app.getResourceRequests();
  if (resourceRequests == null || resourceRequests.isEmpty()) {
    return;
  }

  DIV<Hamlet> div = html.div(_INFO_WRAP);
  TABLE<DIV<Hamlet>> table =
      div.h3("Total Outstanding Resource Requests: "
        + getTotalResource(resourceRequests)).table(
            "#ResourceRequests");

  table.tr().
    th(_TH, "Priority").
    th(_TH, "ResourceName").
    th(_TH, "Capability").
    th(_TH, "NumContainers").
    th(_TH, "RelaxLocality").
    th(_TH, "NodeLabelExpression").
  _();

  boolean odd = false;
  for (ResourceRequest request : resourceRequests) {
    if (request.getNumContainers() == 0) {
      continue;
    }
    table.tr((odd = !odd) ? _ODD : _EVEN)
      .td(String.valueOf(request.getPriority()))
      .td(request.getResourceName())
      .td(String.valueOf(request.getCapability()))
      .td(String.valueOf(request.getNumContainers()))
      .td(String.valueOf(request.getRelaxLocality()))
      .td(request.getNodeLabelExpression() == null ? "N/A" : request
          .getNodeLabelExpression())._();
  }
  table._();
  div._();
}
 
Example 11
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 12
Source File: ApplicationHistoryManagerOnTimelineStore.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
protected void serviceInit(Configuration conf) throws Exception {
  serverHttpAddress = WebAppUtils.getHttpSchemePrefix(conf) +
      WebAppUtils.getAHSWebAppURLWithoutScheme(conf);
  super.serviceInit(conf);
}
 
Example 13
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 14
Source File: RMAppAttemptBlock.java    From big-c with Apache License 2.0 4 votes vote down vote up
private void createResourceRequestsTable(Block html) {
  AppInfo app =
      new AppInfo(rm, rm.getRMContext().getRMApps()
        .get(this.appAttemptId.getApplicationId()), true,
        WebAppUtils.getHttpSchemePrefix(conf));

  List<ResourceRequest> resourceRequests = app.getResourceRequests();
  if (resourceRequests == null || resourceRequests.isEmpty()) {
    return;
  }

  DIV<Hamlet> div = html.div(_INFO_WRAP);
  TABLE<DIV<Hamlet>> table =
      div.h3("Total Outstanding Resource Requests: "
        + getTotalResource(resourceRequests)).table(
            "#ResourceRequests");

  table.tr().
    th(_TH, "Priority").
    th(_TH, "ResourceName").
    th(_TH, "Capability").
    th(_TH, "NumContainers").
    th(_TH, "RelaxLocality").
    th(_TH, "NodeLabelExpression").
  _();

  boolean odd = false;
  for (ResourceRequest request : resourceRequests) {
    if (request.getNumContainers() == 0) {
      continue;
    }
    table.tr((odd = !odd) ? _ODD : _EVEN)
      .td(String.valueOf(request.getPriority()))
      .td(request.getResourceName())
      .td(String.valueOf(request.getCapability()))
      .td(String.valueOf(request.getNumContainers()))
      .td(String.valueOf(request.getRelaxLocality()))
      .td(request.getNodeLabelExpression() == null ? "N/A" : request
          .getNodeLabelExpression())._();
  }
  table._();
  div._();
}
 
Example 15
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 16
Source File: ApplicationHistoryManagerOnTimelineStore.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
protected void serviceInit(Configuration conf) throws Exception {
  serverHttpAddress = WebAppUtils.getHttpSchemePrefix(conf) +
      WebAppUtils.getAHSWebAppURLWithoutScheme(conf);
  super.serviceInit(conf);
}