ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From swa...@apache.org
Subject [23/23] ambari git commit: AMBARI-18918: Zeppelin view doesn't work with JDK 1.8_91+ (Prabhjyot Singh)
Date Mon, 21 Nov 2016 20:02:17 GMT
AMBARI-18918: Zeppelin view doesn't work with JDK 1.8_91+ (Prabhjyot Singh)


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

Branch: refs/heads/branch-feature-AMBARI-18901
Commit: 0c5850a2e569897f3b4878fd04ccc165cfd6a161
Parents: 795dd1f
Author: Renjith Kamath <renjith.kamath@gmail.com>
Authored: Mon Nov 21 17:22:06 2016 +0530
Committer: Renjith Kamath <renjith.kamath@gmail.com>
Committed: Mon Nov 21 17:22:06 2016 +0530

----------------------------------------------------------------------
 .../ambari/view/zeppelin/ZeppelinServlet.java   | 103 +++++++++++++------
 .../src/main/resources/WEB-INF/index.jsp        |  63 ------------
 2 files changed, 73 insertions(+), 93 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0c5850a2/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 5b329be..ab61a3d 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,42 +29,85 @@ import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.io.PrintWriter;
 import java.util.List;
 
 
 public class ZeppelinServlet extends HttpServlet {
-    private ViewContext viewContext;
-    private final static Logger LOG = LoggerFactory.getLogger(ZeppelinServlet.class);
+  private ViewContext viewContext;
+  private final static Logger LOG = LoggerFactory.getLogger(ZeppelinServlet.class);
 
-    @Override
-    public void init(ServletConfig config) throws ServletException {
-        super.init(config);
+  @Override
+  public void init(ServletConfig config) throws ServletException {
+    super.init(config);
 
-        ServletContext context = config.getServletContext();
-        viewContext = (ViewContext) context.getAttribute(ViewContext.CONTEXT_ATTRIBUTE);
-    }
-
-    @Override
-    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);
-        }
+    ServletContext context = config.getServletContext();
+    viewContext = (ViewContext) context.getAttribute(ViewContext.CONTEXT_ATTRIBUTE);
+  }
 
-        String serviceCheckResponse = ZeppelinServiceCheck.check(publicName, port);
-        request.setAttribute("serviceCheckResponse", serviceCheckResponse);
-
-        request.getRequestDispatcher("WEB-INF/index.jsp").forward(request, response);
+  public void service(HttpServletRequest req,
+                      HttpServletResponse res) throws IOException {
+    res.setContentType("text/html");
+    PrintWriter out = res.getWriter();
+    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);
     }
+    out.println("<html lang=\"en\">" +
+        "<head>" +
+        "    <meta charset=\"utf-8\"/>" +
+        "    <link rel=\"stylesheet\" href=\"/stylesheets/vendor.css\">" +
+        "</head>" +
+        "<body>" +
+        "" +
+        "<div class=\"container-fluid\" id=\"messageContainer\" style=\"display:none;\">"
+
+        "    <h1>Welcome to the Zeppelin View</h1>" +
+        "    <h3>Service check failed</h3>" +
+        "" +
+        "    <table class=\"table\">" +
+        "        <tbody>" +
+        "        <tr>" +
+        "            <td>zeppelin service is not running</td>" +
+        "        </tr>" +
+        "        </tbody>" +
+        "    </table>" +
+        "" +
+        "</div>" +
+        "" +
+        "<iframe id='zeppelinIFrame' width=\"100%\" seamless=\"seamless\" style=\"border:
0px;\"></iframe>" +
+        "<script>" +
+        "var $ = jQuery = parent.jQuery;" +
+        "var iframe = document.querySelector('#zeppelinIFrame');" +
+        "var messageContainer = document.querySelector('#messageContainer');" +
+        "" +
+        "var serviceCheckResponse = $.parseJSON(' " + ZeppelinServiceCheck.check(publicName,
port) + "');" +
+        "" +
+        "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;" +
+        "});" +
+        "</script>" +
+        "</body>" +
+        "</html>");
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/0c5850a2/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
deleted file mode 100644
index cce6bc5..0000000
--- a/contrib/views/zeppelin/src/main/resources/WEB-INF/index.jsp
+++ /dev/null
@@ -1,63 +0,0 @@
-<!DOCTYPE html>
-<%--
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements.  See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership.  The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
---%>
-<html lang="en">
-<head>
-    <meta charset="utf-8"/>
-    <link rel="stylesheet" href="/stylesheets/vendor.css">
-</head>
-<body>
-
-<div class="container-fluid" id="messageContainer" style="display:none;">
-    <h1>Welcome to the Zeppelin View</h1>
-    <h3>Service check failed</h3>
-
-    <table class="table">
-        <tbody>
-        <tr>
-            <td>zeppelin service is not running</td>
-        </tr>
-        </tbody>
-    </table>
-
-</div>
-
-<iframe id='zeppelinIFrame' width="100%" seamless="seamless" style="border: 0px;"></iframe>
-<script>
-var $ = jQuery = parent.jQuery;
-var iframe = document.querySelector('#zeppelinIFrame');
-var messageContainer = document.querySelector('#messageContainer');
-
-var serviceCheckResponse = $.parseJSON('<%= request.getAttribute("serviceCheckResponse")
%>');
-
-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;
-});
-</script>
-</body>
-</html>


Mime
View raw message