You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by go...@apache.org on 2016/11/23 10:39:09 UTC
hive git commit: HIVE-15196: LLAP UI: HIVE-14984 broke LLAP UI (Barna
Zsombor Klara via Gopal V)
Repository: hive
Updated Branches:
refs/heads/master 76f1f41f0 -> e1c1b062a
HIVE-15196: LLAP UI: HIVE-14984 broke LLAP UI (Barna Zsombor Klara via Gopal V)
Signed-off-by: Gopal V <go...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/e1c1b062
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/e1c1b062
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/e1c1b062
Branch: refs/heads/master
Commit: e1c1b062ac766acad990c7e44d8fcf5d6af35f86
Parents: 76f1f41
Author: Barna Zsombor Klara <zs...@cloudera.com>
Authored: Wed Nov 23 02:38:02 2016 -0800
Committer: Gopal V <go...@apache.org>
Committed: Wed Nov 23 02:38:44 2016 -0800
----------------------------------------------------------------------
.../java/org/apache/hive/http/HttpServer.java | 8 ++-
.../services/impl/TestLlapWebServices.java | 69 ++++++++++++++++++++
.../apache/hive/service/server/HiveServer2.java | 1 +
.../hive/service/server/TestHS2HttpServer.java | 24 +++----
4 files changed, 89 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/e1c1b062/common/src/java/org/apache/hive/http/HttpServer.java
----------------------------------------------------------------------
diff --git a/common/src/java/org/apache/hive/http/HttpServer.java b/common/src/java/org/apache/hive/http/HttpServer.java
index 42d2959..f99f18a 100644
--- a/common/src/java/org/apache/hive/http/HttpServer.java
+++ b/common/src/java/org/apache/hive/http/HttpServer.java
@@ -120,6 +120,7 @@ public class HttpServer {
private String spnegoKeytab;
private boolean useSPNEGO;
private boolean useSSL;
+ private String contextRootRewriteTarget = "/index.html";
private final List<Pair<String, Class<? extends HttpServlet>>> servlets =
new LinkedList<Pair<String, Class<? extends HttpServlet>>>();
@@ -197,6 +198,11 @@ public class HttpServer {
return this;
}
+ public Builder setContextRootRewriteTarget(String contextRootRewriteTarget) {
+ this.contextRootRewriteTarget = contextRootRewriteTarget;
+ return this;
+ }
+
public Builder addServlet(String endpoint, Class<? extends HttpServlet> servlet) {
servlets.add(new Pair<String, Class<? extends HttpServlet>>(endpoint, servlet));
return this;
@@ -394,7 +400,7 @@ public class HttpServer {
RewriteRegexRule rootRule = new RewriteRegexRule();
rootRule.setRegex("^/$");
- rootRule.setReplacement("/hiveserver2.jsp");
+ rootRule.setReplacement(b.contextRootRewriteTarget);
rootRule.setTerminating(true);
rwHandler.addRule(rootRule);
http://git-wip-us.apache.org/repos/asf/hive/blob/e1c1b062/llap-server/src/test/org/apache/hadoop/hive/llap/daemon/services/impl/TestLlapWebServices.java
----------------------------------------------------------------------
diff --git a/llap-server/src/test/org/apache/hadoop/hive/llap/daemon/services/impl/TestLlapWebServices.java b/llap-server/src/test/org/apache/hadoop/hive/llap/daemon/services/impl/TestLlapWebServices.java
new file mode 100644
index 0000000..833a8f5
--- /dev/null
+++ b/llap-server/src/test/org/apache/hadoop/hive/llap/daemon/services/impl/TestLlapWebServices.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed 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.
+ */
+
+package org.apache.hadoop.hive.llap.daemon.services.impl;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.MetaStoreUtils;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+public class TestLlapWebServices {
+
+ private static LlapWebServices llapWS = null;
+ private static int llapWSPort;
+
+ @BeforeClass
+ public static void beforeTests() throws Exception {
+ llapWSPort = MetaStoreUtils.findFreePortExcepting(
+ Integer.valueOf(HiveConf.ConfVars.LLAP_DAEMON_WEB_PORT.getDefaultValue()));
+ llapWS = new LlapWebServices(llapWSPort, null, null);
+ llapWS.init(new HiveConf());
+ llapWS.start();
+ Thread.sleep(5000);
+ }
+
+ @Test
+ public void testContextRootUrlRewrite() throws Exception {
+ String contextRootURL = "http://localhost:" + llapWSPort + "/";
+ String contextRootContent = getURLResponseAsString(contextRootURL);
+
+ String indexHtmlUrl = "http://localhost:" + llapWSPort + "/index.html";
+ String indexHtmlContent = getURLResponseAsString(indexHtmlUrl);
+
+ Assert.assertEquals(contextRootContent, indexHtmlContent);
+ }
+
+ private String getURLResponseAsString(String baseURL) throws IOException {
+ URL url = new URL(baseURL);
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ Assert.assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());
+ StringWriter writer = new StringWriter();
+ IOUtils.copy(conn.getInputStream(), writer, "UTF-8");
+ return writer.toString();
+ }
+
+ @AfterClass
+ public static void afterTests() throws Exception {
+ llapWS.stop();
+ }
+}
http://git-wip-us.apache.org/repos/asf/hive/blob/e1c1b062/service/src/java/org/apache/hive/service/server/HiveServer2.java
----------------------------------------------------------------------
diff --git a/service/src/java/org/apache/hive/service/server/HiveServer2.java b/service/src/java/org/apache/hive/service/server/HiveServer2.java
index 9c94611..70cb126 100644
--- a/service/src/java/org/apache/hive/service/server/HiveServer2.java
+++ b/service/src/java/org/apache/hive/service/server/HiveServer2.java
@@ -204,6 +204,7 @@ public class HiveServer2 extends CompositeService {
builder.setUseSPNEGO(true);
}
builder.addServlet("llap", LlapServlet.class);
+ builder.setContextRootRewriteTarget("/hiveserver2.jsp");
webServer = builder.build();
webServer.addServlet("query_page", "/query_page", QueryProfileServlet.class);
}
http://git-wip-us.apache.org/repos/asf/hive/blob/e1c1b062/service/src/test/org/apache/hive/service/server/TestHS2HttpServer.java
----------------------------------------------------------------------
diff --git a/service/src/test/org/apache/hive/service/server/TestHS2HttpServer.java b/service/src/test/org/apache/hive/service/server/TestHS2HttpServer.java
index d918c64..351cfc1 100644
--- a/service/src/test/org/apache/hive/service/server/TestHS2HttpServer.java
+++ b/service/src/test/org/apache/hive/service/server/TestHS2HttpServer.java
@@ -19,6 +19,7 @@
package org.apache.hive.service.server;
import java.io.BufferedReader;
+import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.net.HttpURLConnection;
@@ -90,20 +91,10 @@ public class TestHS2HttpServer {
@Test
public void testContextRootUrlRewrite() throws Exception {
String baseURL = "http://localhost:" + webUIPort + "/";
- URL url = new URL(baseURL);
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- Assert.assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());
- StringWriter writer = new StringWriter();
- IOUtils.copy(conn.getInputStream(), writer, "UTF-8");
- String contextRootContent = writer.toString();
+ String contextRootContent = getURLResponseAsString(baseURL);
String jspUrl = "http://localhost:" + webUIPort + "/hiveserver2.jsp";
- url = new URL(jspUrl);
- conn = (HttpURLConnection) url.openConnection();
- Assert.assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());
- writer = new StringWriter();
- IOUtils.copy(conn.getInputStream(), writer, "UTF-8");
- String jspContent = writer.toString();
+ String jspContent = getURLResponseAsString(jspUrl);
Assert.assertEquals(contextRootContent, jspContent);
}
@@ -145,6 +136,15 @@ public class TestHS2HttpServer {
assertNull(pwdValFound);
}
+ private String getURLResponseAsString(String baseURL) throws IOException {
+ URL url = new URL(baseURL);
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ Assert.assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());
+ StringWriter writer = new StringWriter();
+ IOUtils.copy(conn.getInputStream(), writer, "UTF-8");
+ return writer.toString();
+ }
+
@AfterClass
public static void afterTests() throws Exception {