tez-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeag...@apache.org
Subject tez git commit: TEZ-2189. Tez UI live AM tracking url only works for localhost addresses (jeagles)
Date Fri, 13 Mar 2015 17:31:33 GMT
Repository: tez
Updated Branches:
  refs/heads/branch-0.6 b649dda68 -> 0dde9325e


TEZ-2189. Tez UI live AM tracking url only works for localhost addresses (jeagles)

(cherry picked from commit a809f96c6e6c7bfe8f683980713bff5bfe373419)


Project: http://git-wip-us.apache.org/repos/asf/tez/repo
Commit: http://git-wip-us.apache.org/repos/asf/tez/commit/0dde9325
Tree: http://git-wip-us.apache.org/repos/asf/tez/tree/0dde9325
Diff: http://git-wip-us.apache.org/repos/asf/tez/diff/0dde9325

Branch: refs/heads/branch-0.6
Commit: 0dde9325e5e5e9361690b865ee05794bc835d3cb
Parents: b649dda
Author: Jonathan Eagles <jeagles@gmail.com>
Authored: Fri Mar 13 12:29:59 2015 -0500
Committer: Jonathan Eagles <jeagles@gmail.com>
Committed: Fri Mar 13 12:30:39 2015 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../dag/app/rm/TaskSchedulerEventHandler.java   |  9 +++++-
 .../apache/tez/dag/app/web/AMWebController.java |  2 +-
 .../apache/tez/dag/app/web/WebUIService.java    | 30 ++++++++------------
 .../app/rm/TestTaskSchedulerEventHandler.java   |  5 ++++
 5 files changed, 27 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tez/blob/0dde9325/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index aebdb36..537dafe 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -6,6 +6,7 @@ Release 0.6.1: Unreleased
 INCOMPATIBLE CHANGES
 
 ALL CHANGES:
+  TEZ-2189. Tez UI live AM tracking url only works for localhost addresses
   TEZ-2179. Timeline relatedentries missing cause exaggerated warning.
   TEZ-2168. Fix application dependencies on mutually exclusive artifacts: tez-yarn-timeline-history
     and tez-yarn-timeline-history-with-acls.

http://git-wip-us.apache.org/repos/asf/tez/blob/0dde9325/tez-dag/src/main/java/org/apache/tez/dag/app/rm/TaskSchedulerEventHandler.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/main/java/org/apache/tez/dag/app/rm/TaskSchedulerEventHandler.java
b/tez-dag/src/main/java/org/apache/tez/dag/app/rm/TaskSchedulerEventHandler.java
index 05cbc66..9ea3462 100644
--- a/tez-dag/src/main/java/org/apache/tez/dag/app/rm/TaskSchedulerEventHandler.java
+++ b/tez-dag/src/main/java/org/apache/tez/dag/app/rm/TaskSchedulerEventHandler.java
@@ -19,6 +19,8 @@
 package org.apache.tez.dag.app.rm;
 
 import java.net.InetSocketAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.nio.ByteBuffer;
 import java.util.List;
 import java.util.Map;
@@ -346,7 +348,7 @@ public class TaskSchedulerEventHandler extends AbstractService
     // the actual url set on the rm web ui will be the proxy url set by WebAppProxyServlet,
which
     // always try to connect to AM and proxy the response. hence it wont work if the webUIService
     // is not enabled.
-    String trackingUrl = (webUI != null) ? webUI.getURL() : "";
+    String trackingUrl = (webUI != null) ? webUI.getTrackingURL() : "";
     taskScheduler = createTaskScheduler(serviceAddr.getHostName(),
         serviceAddr.getPort(), trackingUrl, appContext);
     taskScheduler.init(getConfig());
@@ -606,6 +608,11 @@ public class TaskSchedulerEventHandler extends AbstractService
           .replaceAll(APPLICATION_ID_PLACEHOLDER, appContext.getApplicationID().toString())
           .replaceAll(HISTORY_URL_BASE, historyUrlBase)
           .replaceAll("([^:])/{2,}", "$1/");
+
+      // make sure we have a valid scheme
+      if (!historyUrl.startsWith("http")) {
+        historyUrl = "http://" + historyUrl;
+      }
     }
 
     return historyUrl;

http://git-wip-us.apache.org/repos/asf/tez/blob/0dde9325/tez-dag/src/main/java/org/apache/tez/dag/app/web/AMWebController.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/main/java/org/apache/tez/dag/app/web/AMWebController.java b/tez-dag/src/main/java/org/apache/tez/dag/app/web/AMWebController.java
index 2e4fb49..440d745 100644
--- a/tez-dag/src/main/java/org/apache/tez/dag/app/web/AMWebController.java
+++ b/tez-dag/src/main/java/org/apache/tez/dag/app/web/AMWebController.java
@@ -323,7 +323,7 @@ public class AMWebController extends Controller {
             "<p>To enable tracking url pointing to Tez UI, set the config <b>"
+
             TezConfiguration.TEZ_HISTORY_URL_BASE + "</b> in the tez-site.xml.</p>");
       } else {
-        pw.write("<h1>Redirecting to Tez UI</h1>. <p>If you are not redirected
shortly, click" +
+        pw.write("<h1>Redirecting to Tez UI</h1>. <p>If you are not redirected
shortly, click " +
             "<a href='" + historyUrl + "'><b>here</b></a></p>"
         );
         pw.write("<script type='text/javascript'>setTimeout(function() { " +

http://git-wip-us.apache.org/repos/asf/tez/blob/0dde9325/tez-dag/src/main/java/org/apache/tez/dag/app/web/WebUIService.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/main/java/org/apache/tez/dag/app/web/WebUIService.java b/tez-dag/src/main/java/org/apache/tez/dag/app/web/WebUIService.java
index 44f99c8..4524e60 100644
--- a/tez-dag/src/main/java/org/apache/tez/dag/app/web/WebUIService.java
+++ b/tez-dag/src/main/java/org/apache/tez/dag/app/web/WebUIService.java
@@ -24,10 +24,12 @@ import java.net.InetSocketAddress;
 
 import com.google.common.base.Preconditions;
 import com.google.inject.name.Names;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.http.HttpConfig;
+import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.service.AbstractService;
 import org.apache.hadoop.yarn.webapp.WebApp;
 import org.apache.hadoop.yarn.webapp.WebApps;
@@ -45,7 +47,7 @@ public class WebUIService extends AbstractService {
   private final AppContext context;
   private TezAMWebApp tezAMWebApp;
   private WebApp webApp;
-  private int port;
+  private String trackingUrl = "";
   private String historyUrl = "";
 
   public WebUIService(AppContext context) {
@@ -84,7 +86,12 @@ public class WebUIService extends AbstractService {
             .with(conf)
             .withHttpPolicy(conf, HttpConfig.Policy.HTTP_ONLY)
             .start(this.tezAMWebApp);
-        this.port = this.webApp.httpServer().getConnectorAddress(0).getPort();
+        InetSocketAddress address = webApp.getListenerAddress();
+        if (address != null) {
+          InetSocketAddress bindAddress = NetUtils.createSocketAddrForHost(context.getAppMaster().getAppNMHost(),
address.getPort());
+          trackingUrl = "http://" + bindAddress.getAddress().getCanonicalHostName() + ":"
+ bindAddress.getPort() + "/ui/";
+          LOG.info("Instantiated WebUIService at " + trackingUrl);
+        }
       } catch (Exception e) {
         LOG.error("Tez UI WebService failed to start.", e);
         throw new TezUncheckedException(e);
@@ -104,21 +111,8 @@ public class WebUIService extends AbstractService {
     super.serviceStop();
   }
 
-  public int getPort() {
-    return this.port;
-  }
-
-  public String getURL() {
-    String url = "";
-    InetSocketAddress address = webApp.getListenerAddress();
-
-    if (address != null) {
-      final String hostName = address.getAddress().getCanonicalHostName();
-      final int port = address.getPort();
-      url = "http://" + hostName + ":" + port + "/ui/";
-    }
-
-    return url;
+  public String getTrackingURL() {
+    return trackingUrl;
   }
 
   public String getHistoryUrl() {
@@ -158,4 +152,4 @@ public class WebUIService extends AbstractService {
           "getVertexProgresses");
     }
   }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/tez/blob/0dde9325/tez-dag/src/test/java/org/apache/tez/dag/app/rm/TestTaskSchedulerEventHandler.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/app/rm/TestTaskSchedulerEventHandler.java
b/tez-dag/src/test/java/org/apache/tez/dag/app/rm/TestTaskSchedulerEventHandler.java
index 7bb9d9b..691be1c 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/app/rm/TestTaskSchedulerEventHandler.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/app/rm/TestTaskSchedulerEventHandler.java
@@ -275,6 +275,11 @@ public class TestTaskSchedulerEventHandler {
     Assert.assertTrue("http://ui-host:9998/#/tez-app/TEST_APP_ID"
         .equals(schedulerHandler.getHistoryUrl()));
 
+    // ensure missing scheme in history url is handled
+    conf.set(TezConfiguration.TEZ_HISTORY_URL_BASE, "ui-host:9998/");
+    Assert.assertTrue("http://ui-host:9998/#/tez-app/TEST_APP_ID"
+        .equals(schedulerHandler.getHistoryUrl()));
+
     // handle bad template ex without begining /
     conf.set(TezConfiguration.TEZ_AM_TEZ_UI_HISTORY_URL_TEMPLATE,
         "__HISTORY_URL_BASE__#/somepath");


Mime
View raw message