You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2016/02/29 20:22:00 UTC

ambari git commit: AMBARI-14951. Tez Ambari View: Add protocol configuration for YARN. (Sreenath Somarajapuram via yusaku)

Repository: ambari
Updated Branches:
  refs/heads/trunk 042345c1b -> 4cd5ad4e6


AMBARI-14951. Tez Ambari View: Add protocol configuration for YARN. (Sreenath Somarajapuram via yusaku)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4cd5ad4e
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4cd5ad4e
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4cd5ad4e

Branch: refs/heads/trunk
Commit: 4cd5ad4e61c2a9a3cfc7e22233b484e8fc88e8b2
Parents: 042345c
Author: Yusaku Sako <yu...@hortonworks.com>
Authored: Mon Feb 29 11:21:28 2016 -0800
Committer: Yusaku Sako <yu...@hortonworks.com>
Committed: Mon Feb 29 11:21:28 2016 -0800

----------------------------------------------------------------------
 contrib/views/capacity-scheduler/pom.xml        |  2 +-
 contrib/views/files/pom.xml                     |  2 +-
 contrib/views/hive/pom.xml                      |  2 +-
 contrib/views/pig/pom.xml                       |  2 +-
 contrib/views/pom.xml                           |  2 +-
 contrib/views/slider/pom.xml                    |  2 +-
 contrib/views/tez/pom.xml                       |  2 +-
 .../apache/ambari/view/tez/ViewController.java  |  6 +++
 .../ambari/view/tez/ViewControllerImpl.java     |  6 +++
 .../resources/ui/scripts/init-ambari-view.js    | 40 +++++++++++++++++++-
 contrib/views/utils/pom.xml                     |  2 +-
 .../ambari/view/utils/ambari/Services.java      | 15 ++++++++
 .../ambari/view/utils/ambari/ServicesTest.java  | 16 ++++++++
 13 files changed, 89 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4cd5ad4e/contrib/views/capacity-scheduler/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/views/capacity-scheduler/pom.xml b/contrib/views/capacity-scheduler/pom.xml
index 24a8ca2..393dccb 100644
--- a/contrib/views/capacity-scheduler/pom.xml
+++ b/contrib/views/capacity-scheduler/pom.xml
@@ -81,7 +81,7 @@
         <dependency>
             <groupId>org.apache.ambari.contrib.views</groupId>
             <artifactId>ambari-views-utils</artifactId>
-            <version>0.0.1.0-SNAPSHOT</version>
+            <version>2.0.0.0-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.easymock</groupId>

http://git-wip-us.apache.org/repos/asf/ambari/blob/4cd5ad4e/contrib/views/files/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/views/files/pom.xml b/contrib/views/files/pom.xml
index ccdd281..961889e 100644
--- a/contrib/views/files/pom.xml
+++ b/contrib/views/files/pom.xml
@@ -94,7 +94,7 @@
     <dependency>
       <groupId>org.apache.ambari.contrib.views</groupId>
       <artifactId>ambari-views-utils</artifactId>
-      <version>0.0.1.0-SNAPSHOT</version>
+      <version>2.0.0.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>com.google.code.gson</groupId>

http://git-wip-us.apache.org/repos/asf/ambari/blob/4cd5ad4e/contrib/views/hive/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/views/hive/pom.xml b/contrib/views/hive/pom.xml
index b82a413..34ec7d1 100644
--- a/contrib/views/hive/pom.xml
+++ b/contrib/views/hive/pom.xml
@@ -199,7 +199,7 @@
     <dependency>
       <groupId>org.apache.ambari.contrib.views</groupId>
       <artifactId>ambari-views-utils</artifactId>
-      <version>0.0.1.0-SNAPSHOT</version>
+      <version>2.0.0.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>commons-validator</groupId>

http://git-wip-us.apache.org/repos/asf/ambari/blob/4cd5ad4e/contrib/views/pig/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/views/pig/pom.xml b/contrib/views/pig/pom.xml
index a88be2a..5679f1f 100644
--- a/contrib/views/pig/pom.xml
+++ b/contrib/views/pig/pom.xml
@@ -138,7 +138,7 @@
     <dependency>
       <groupId>org.apache.ambari.contrib.views</groupId>
       <artifactId>ambari-views-utils</artifactId>
-      <version>0.0.1.0-SNAPSHOT</version>
+      <version>2.0.0.0-SNAPSHOT</version>
     </dependency>
   </dependencies>
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/4cd5ad4e/contrib/views/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/views/pom.xml b/contrib/views/pom.xml
index 627552a..eb1972c 100644
--- a/contrib/views/pom.xml
+++ b/contrib/views/pom.xml
@@ -34,13 +34,13 @@
     <hadoop.version>2.7.1</hadoop.version>
   </properties>
   <modules>
+    <module>utils</module>
     <module>files</module>
     <module>jobs</module>
     <module>pig</module>
     <module>slider</module>
     <module>capacity-scheduler</module>
     <module>tez</module>
-    <module>utils</module>
     <module>storm</module>
   </modules>
   <build>

http://git-wip-us.apache.org/repos/asf/ambari/blob/4cd5ad4e/contrib/views/slider/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/views/slider/pom.xml b/contrib/views/slider/pom.xml
index c449413..94115f0 100644
--- a/contrib/views/slider/pom.xml
+++ b/contrib/views/slider/pom.xml
@@ -129,7 +129,7 @@
     <dependency>
       <groupId>org.apache.ambari.contrib.views</groupId>
       <artifactId>ambari-views-utils</artifactId>
-      <version>0.0.1.0-SNAPSHOT</version>
+      <version>2.0.0.0-SNAPSHOT</version>
     </dependency>
   </dependencies>
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/4cd5ad4e/contrib/views/tez/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/views/tez/pom.xml b/contrib/views/tez/pom.xml
index 65400fb..cdda4dc 100644
--- a/contrib/views/tez/pom.xml
+++ b/contrib/views/tez/pom.xml
@@ -210,7 +210,7 @@
     <dependency>
       <groupId>org.apache.ambari.contrib.views</groupId>
       <artifactId>ambari-views-utils</artifactId>
-      <version>0.0.1.0-SNAPSHOT</version>
+      <version>2.0.0.0-SNAPSHOT</version>
     </dependency>
 
   </dependencies>

http://git-wip-us.apache.org/repos/asf/ambari/blob/4cd5ad4e/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewController.java
----------------------------------------------------------------------
diff --git a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewController.java b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewController.java
index 16b470a..440ac65 100644
--- a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewController.java
+++ b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewController.java
@@ -28,6 +28,7 @@ public interface ViewController {
 
   public static final String PARAM_YARN_ATS_URL = "yarn.timeline-server.url";
   public static final String PARAM_YARN_RESOURCEMANAGER_URL = "yarn.resourcemanager.url";
+  public static final String PARAM_YARN_PROTOCOL = "yarn.protocol";
 
   /**
    * @return Get the properties that any user is allowed to see, even non-admin users.
@@ -45,4 +46,9 @@ public interface ViewController {
    * @return The active resource manager URL.
    */
   String getActiveRMUrl();
+
+  /**
+   * @return The protocol used by YARN daemons.
+   */
+  String getYARNProtocol();
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/4cd5ad4e/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewControllerImpl.java
----------------------------------------------------------------------
diff --git a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewControllerImpl.java b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewControllerImpl.java
index c1456bc..981353b 100644
--- a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewControllerImpl.java
+++ b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewControllerImpl.java
@@ -61,6 +61,7 @@ public class ViewControllerImpl implements ViewController {
     Map<String, String> parameters = new HashMap<String, String>();
     parameters.put(ViewController.PARAM_YARN_ATS_URL, getActiveATSUrl());
     parameters.put(ViewController.PARAM_YARN_RESOURCEMANAGER_URL, getActiveRMUrl());
+    parameters.put(ViewController.PARAM_YARN_PROTOCOL, getYARNProtocol());
     status.setParameters(parameters);
     return status;
   }
@@ -82,5 +83,10 @@ public class ViewControllerImpl implements ViewController {
       throw new ActiveRMFetchException(ex);
     }
   }
+
+  @Override
+  public String getYARNProtocol() {
+    return ambariApi.getServices().getYARNProtocol();
+  }
 }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/4cd5ad4e/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js
----------------------------------------------------------------------
diff --git a/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js b/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js
index c246536..25d4da0 100644
--- a/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js
+++ b/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js
@@ -21,6 +21,32 @@ App.deferReadiness();
 var PATH_PARAM_NAME = "viewPath";
 
 /**
+ * Constructs URL for fetching Ambari view instance parameters.
+ * @return {String}
+ */
+function getStatusURL() {
+  var urlParts = location.pathname.split('/');
+
+  return "/api/v1/views/%@/versions/%@/instances/%@/resources/status".fmt(
+    urlParts[2],
+    urlParts[3],
+    urlParts[4]
+  );
+}
+
+function getStatus() {
+  var hashArray = location.pathname.split('/');
+
+  return $.ajax({
+    type: 'GET',
+    dataType: 'json',
+    async: true,
+    context: this,
+    url: getStatusURL(),
+  });
+}
+
+/**
  * Creates an object from query string
  * @param getQueryObject {String}
  * @return {Object}
@@ -142,7 +168,7 @@ function scheduleChangeHandler(arguments) {
   setTimeout(onPathChange, 100);
 }
 
-function setConfigs() {
+function setConfigs(parameters) {
   var host = window.location.protocol +
       "//" +
       window.location.hostname +
@@ -154,11 +180,14 @@ function setConfigs() {
         urlParts[4]
       );
 
+  parameters = parameters || {};
+
   $.extend(true, App.Configs, {
     envDefaults: {
       isStandalone: false,
       timelineBaseUrl: host,
       RMWebUrl: host,
+      yarnProtocol: parameters["yarn.protocol"]
     },
     restNamespace: {
       timeline: '%@atsproxy/ws/v1/timeline'.fmt(resourcesPrefix),
@@ -180,6 +209,13 @@ function setConfigs() {
   App.advanceReadiness();
 }
 
+function loadParams() {
+  getStatus().always(function(status) {
+    status = status || {};
+    setConfigs(status.parameters);
+  });
+}
+
 if(!redirectionCheck()) {
   App.ApplicationRoute.reopen({
     actions: {
@@ -189,5 +225,5 @@ if(!redirectionCheck()) {
   });
 
   allowFullScreen();
-  setConfigs();
+  loadParams();
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/4cd5ad4e/contrib/views/utils/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/views/utils/pom.xml b/contrib/views/utils/pom.xml
index d3cc683..32f38dd 100644
--- a/contrib/views/utils/pom.xml
+++ b/contrib/views/utils/pom.xml
@@ -19,7 +19,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.ambari.contrib.views</groupId>
   <artifactId>ambari-views-utils</artifactId>
-  <version>0.0.1.0-SNAPSHOT</version>
+  <version>2.0.0.0-SNAPSHOT</version>
   <name>Ambari View Utils</name>
 
   <parent>

http://git-wip-us.apache.org/repos/asf/ambari/blob/4cd5ad4e/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/Services.java
----------------------------------------------------------------------
diff --git a/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/Services.java b/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/Services.java
index 8a50012..a8ef43f 100644
--- a/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/Services.java
+++ b/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/Services.java
@@ -267,6 +267,21 @@ public class Services {
     }
   }
 
+  /**
+   * @return Returns the protocol used by YARN daemons, the value is always taken from the
+   * yarn-site.xml.
+   */
+  public String getYARNProtocol() {
+    String httpPolicy = getYarnConfig(YARN_HTTP_POLICY);
+
+    if (!(HTTP_ONLY.equals(httpPolicy) || HTTPS_ONLY.equals(httpPolicy))) {
+      LOG.error(String.format("RA030 Unknown value %s of yarn-site/yarn.http.policy. HTTP_ONLY assumed.", httpPolicy));
+      httpPolicy = HTTP_ONLY;
+    }
+
+    return getProtocol(httpPolicy);
+  }
+
   private String getATSUrlFromCluster() {
     String url;
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/4cd5ad4e/contrib/views/utils/src/test/java/org/apache/ambari/view/utils/ambari/ServicesTest.java
----------------------------------------------------------------------
diff --git a/contrib/views/utils/src/test/java/org/apache/ambari/view/utils/ambari/ServicesTest.java b/contrib/views/utils/src/test/java/org/apache/ambari/view/utils/ambari/ServicesTest.java
index 1cf5747..455ca20 100644
--- a/contrib/views/utils/src/test/java/org/apache/ambari/view/utils/ambari/ServicesTest.java
+++ b/contrib/views/utils/src/test/java/org/apache/ambari/view/utils/ambari/ServicesTest.java
@@ -377,6 +377,22 @@ public class ServicesTest extends EasyMockSupport {
     assertEquals(HTTPS_RM_URL2, services.getRMUrl());
   }
 
+  @Test
+  public void basicGetYARNProtocol() throws Exception {
+    ViewContext viewContext = getViewContext(new HashMap<String, String>());
+    AmbariApi ambariApi = createNiceMock(AmbariApi.class);
+    Cluster cluster = createNiceMock(Cluster.class);
+
+    expect(ambariApi.isClusterAssociated()).andReturn(true).anyTimes();
+    setClusterExpectationWithEmptyWebappConfig(cluster, "HTTP_ONLY");
+    expect(ambariApi.getCluster()).andReturn(cluster).anyTimes();
+
+    Services services = new Services(ambariApi, viewContext);
+
+    replayAll();
+    assertEquals("http", services.getYARNProtocol());
+  }
+
   private void setClusterExpectation(Cluster cluster, String httpPolicy) {
     expect(cluster.getConfigurationValue("yarn-site", "yarn.resourcemanager.ha.enabled")).andReturn("false");
     expect(cluster.getConfigurationValue("yarn-site", "yarn.http.policy")).andReturn(httpPolicy);