ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbhowm...@apache.org
Subject ambari git commit: AMBARI-17191 Zeppelin Views are not working with Custom and Remote cluster view configuration. (Renjith Kamath via dipayanb)
Date Wed, 15 Jun 2016 13:14:43 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 91be58862 -> b18ce3aef


AMBARI-17191 Zeppelin Views are not working with Custom and Remote cluster view configuration.
(Renjith Kamath via dipayanb)


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

Branch: refs/heads/trunk
Commit: b18ce3aefebdc96cbdd6e09270a75a7c2b54497a
Parents: 91be588
Author: Dipayan Bhowmick <dipayan.bhowmick@gmail.com>
Authored: Wed Jun 15 18:44:31 2016 +0530
Committer: Dipayan Bhowmick <dipayan.bhowmick@gmail.com>
Committed: Wed Jun 15 18:44:31 2016 +0530

----------------------------------------------------------------------
 contrib/views/zeppelin/pom.xml                  |  4 +-
 .../view/zeppelin/ZeppelinServiceCheck.java     | 19 ++-----
 .../ambari/view/zeppelin/ZeppelinServlet.java   | 19 +++++--
 .../src/main/resources/WEB-INF/index.jsp        | 56 +++++++-------------
 .../zeppelin/src/main/resources/WEB-INF/web.xml |  9 ----
 .../views/zeppelin/src/main/resources/view.xml  |  2 +-
 6 files changed, 42 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b18ce3ae/contrib/views/zeppelin/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/views/zeppelin/pom.xml b/contrib/views/zeppelin/pom.xml
index 6dd17f3..6b592a7 100644
--- a/contrib/views/zeppelin/pom.xml
+++ b/contrib/views/zeppelin/pom.xml
@@ -44,7 +44,7 @@
     <dependency>
       <groupId>org.apache.ambari</groupId>
       <artifactId>ambari-views</artifactId>
-      <version>[1.7.0.0,)</version>
+      <version>${ambari.version}</version>
     </dependency>
     <dependency>
       <groupId>com.sun.jersey</groupId>
@@ -104,7 +104,7 @@
   <properties>
     <ambari.dir>${project.parent.parent.parent.basedir}</ambari.dir>
     <hive-version>1.0.0</hive-version>
-    <ambari.version>1.3.0.0-SNAPSHOT</ambari.version>
+    <ambari.version>2.0.0.0-SNAPSHOT</ambari.version>
   </properties>
   <build>
     <plugins>

http://git-wip-us.apache.org/repos/asf/ambari/blob/b18ce3ae/contrib/views/zeppelin/src/main/java/org/apache/ambari/view/zeppelin/ZeppelinServiceCheck.java
----------------------------------------------------------------------
diff --git a/contrib/views/zeppelin/src/main/java/org/apache/ambari/view/zeppelin/ZeppelinServiceCheck.java
b/contrib/views/zeppelin/src/main/java/org/apache/ambari/view/zeppelin/ZeppelinServiceCheck.java
index e80f884..8f94260 100644
--- a/contrib/views/zeppelin/src/main/java/org/apache/ambari/view/zeppelin/ZeppelinServiceCheck.java
+++ b/contrib/views/zeppelin/src/main/java/org/apache/ambari/view/zeppelin/ZeppelinServiceCheck.java
@@ -33,20 +33,11 @@ import java.io.IOException;
 import java.io.PrintWriter;
 
 
-public class ZeppelinServiceCheck extends HttpServlet {
-    @Override
-    public void init(ServletConfig config) throws ServletException {
-        super.init(config);
-    }
-
-    @Override
-    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException {
-        String url = "http:" + request.getParameter("url");
-        PrintWriter printwriter = response.getWriter();
+public class ZeppelinServiceCheck {
+    static String check(String host, String port) {
+        String url = "http://" + host + ":" + port;
         JSONObject json = new JSONObject();
-        response.setContentType("application/json");
-        response.setStatus(HttpServletResponse.SC_OK);
-
+        json.put("url", url);
         try {
             HttpClient httpclient = HttpClientBuilder.create().build();
             HttpGet httpget = new HttpGet(url);
@@ -59,6 +50,6 @@ public class ZeppelinServiceCheck extends HttpServlet {
             json.put("status", "ERROR");
             json.put("message", "Zeppelin is not running");
         }
-        printwriter.print(json.toString());
+        return json.toString();
     }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/b18ce3ae/contrib/views/zeppelin/src/main/java/org/apache/ambari/view/zeppelin/ZeppelinServlet.java
----------------------------------------------------------------------
diff --git a/contrib/views/zeppelin/src/main/java/org/apache/ambari/view/zeppelin/ZeppelinServlet.java
b/contrib/views/zeppelin/src/main/java/org/apache/ambari/view/zeppelin/ZeppelinServlet.java
index f497599..5b329be 100644
--- a/contrib/views/zeppelin/src/main/java/org/apache/ambari/view/zeppelin/ZeppelinServlet.java
+++ b/contrib/views/zeppelin/src/main/java/org/apache/ambari/view/zeppelin/ZeppelinServlet.java
@@ -29,6 +29,7 @@ import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.util.List;
 
 
 public class ZeppelinServlet extends HttpServlet {
@@ -47,10 +48,22 @@ public class ZeppelinServlet extends HttpServlet {
     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException {
         response.setContentType("text/html");
         response.setStatus(HttpServletResponse.SC_OK);
+        String publicName = "";
+        String port = "";
+        try {
+            port = viewContext.getProperties().get("zeppelin.server.port");
+            if (viewContext.getCluster() != null) {
+                List<String> hostsForServiceComponents = viewContext.getCluster().getHostsForServiceComponent("ZEPPELIN",
"ZEPPELIN_MASTER");
+                publicName = hostsForServiceComponents.get(0);
+            } else {
+                publicName = viewContext.getProperties().get("zeppelin.host.publicname");
+            }
+        } catch (Exception e) {
+            LOG.error("Zeppelin view servlet failed", e);
+        }
 
-        String port = viewContext.getProperties().get("zeppelin.server.port");
-        String publicName = viewContext.getProperties().get("zeppelin.host.publicname");
-        request.setAttribute("port", port);
+        String serviceCheckResponse = ZeppelinServiceCheck.check(publicName, port);
+        request.setAttribute("serviceCheckResponse", serviceCheckResponse);
 
         request.getRequestDispatcher("WEB-INF/index.jsp").forward(request, response);
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/b18ce3ae/contrib/views/zeppelin/src/main/resources/WEB-INF/index.jsp
----------------------------------------------------------------------
diff --git a/contrib/views/zeppelin/src/main/resources/WEB-INF/index.jsp b/contrib/views/zeppelin/src/main/resources/WEB-INF/index.jsp
index 493473e..460ccbe 100644
--- a/contrib/views/zeppelin/src/main/resources/WEB-INF/index.jsp
+++ b/contrib/views/zeppelin/src/main/resources/WEB-INF/index.jsp
@@ -39,46 +39,26 @@
 
 <iframe id='zeppelinIFrame' width="100%" seamless="seamless" style="border: 0px;"></iframe>
 <script>
-    var $ = jQuery = parent.jQuery;
-    var iframe = document.querySelector('#zeppelinIFrame');
-    var port = "${port}";
+var $ = jQuery = parent.jQuery;
+var iframe = document.querySelector('#zeppelinIFrame');
+var messageContainer = document.querySelector('#messageContainer');
+var port = "${port}";
+var publicName = "${publicName}";
+var serviceCheckResponse = $.parseJSON('${serviceCheckResponse}');
 
-    $.getJSON('/api/v1/clusters', function (data) {
-        $.getJSON('/api/v1/clusters/' +
-                data['items'][0]['Clusters']['cluster_name'] +
-                '/hosts?fields=Hosts%2Fpublic_host_name%2Chost_components%2FHostRoles%2Fcomponent_name',
-                function (data) {
-                    for (var i = 0; i < data['items'].length; i++) {
-                        for (var j = 0; j < data['items'][i]['host_components'].length;
j++) {
-                            if (data['items'][i]['host_components'][j]['HostRoles']['component_name']
== 'ZEPPELIN_MASTER') {
-                                var url = '//' + data['items'][i]['host_components'][j]['HostRoles']['host_name']
+ ':' + port;
-                                validateAndLoadZeppelinUI(iframe, url);
-                                return;
-                            }
-                        }
-                    }
-                });
-    });
+if (serviceCheckResponse.status === "SUCCESS") {
+    messageContainer.style.display = "none";
+    iframe.style.display = "block";
+    iframe.src = serviceCheckResponse.url;
+    iframe.height = window.innerHeight;
+} else {
+    messageContainer.style.display = "block";
+    iframe.style.display = "none";
+}
 
-    $(window).resize(function () {
-        iframe.height = window.innerHeight;
-    });
-
-    function validateAndLoadZeppelinUI(iframe, url) {
-        $.get(location.href + "zeppelin-service-check?url=" + url, function (response) {
-            if (response.status === "SUCCESS") {
-                messageContainer.style.display = "none";
-                iframe.style.display = "block";
-                iframe.src = url;
-                iframe.height = window.innerHeight;
-            } else {
-                messageContainer.style.display = "block";
-                iframe.style.display = "none";
-            }
-        });
-
-
-    }
+$(window).resize(function () {
+    iframe.height = window.innerHeight;
+});
 </script>
 </body>
 </html>

http://git-wip-us.apache.org/repos/asf/ambari/blob/b18ce3ae/contrib/views/zeppelin/src/main/resources/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/contrib/views/zeppelin/src/main/resources/WEB-INF/web.xml b/contrib/views/zeppelin/src/main/resources/WEB-INF/web.xml
index 2ca5664..6b2d156 100644
--- a/contrib/views/zeppelin/src/main/resources/WEB-INF/web.xml
+++ b/contrib/views/zeppelin/src/main/resources/WEB-INF/web.xml
@@ -26,15 +26,6 @@ limitations under the License. Kerberos, LDAP, Custom. Binary/Htt
   <description>
     This is the Zeppelin view servlet application.
   </description>
-  <servlet>
-    <servlet-name>ZeppelinServiceCheck</servlet-name>
-    <servlet-class>org.apache.ambari.view.zeppelin.ZeppelinServiceCheck</servlet-class>
-  </servlet>
-
-  <servlet-mapping>
-    <servlet-name>ZeppelinServiceCheck</servlet-name>
-    <url-pattern>/zeppelin-service-check</url-pattern>
-  </servlet-mapping>
 
   <servlet>
     <servlet-name>ZeppelinServlet</servlet-name>

http://git-wip-us.apache.org/repos/asf/ambari/blob/b18ce3ae/contrib/views/zeppelin/src/main/resources/view.xml
----------------------------------------------------------------------
diff --git a/contrib/views/zeppelin/src/main/resources/view.xml b/contrib/views/zeppelin/src/main/resources/view.xml
index 3c5c5cf..197c397 100644
--- a/contrib/views/zeppelin/src/main/resources/view.xml
+++ b/contrib/views/zeppelin/src/main/resources/view.xml
@@ -32,7 +32,7 @@ limitations under the License. Kerberos, LDAP, Custom. Binary/Htt
     <name>zeppelin.host.publicname</name>
     <description>Zeppelin host name</description>
     <label>Zeppelin host name</label>
-    <cluster-config>zeppelin-ambari-config/zeppelin.host.publicname</cluster-config>
+    <cluster-config>fake</cluster-config>
     <required>true</required>
   </parameter>
 


Mime
View raw message