You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ss...@apache.org on 2016/04/08 23:39:27 UTC
[3/3] hive git commit: HIVE-13437. httpserver getPort does not return
the actual port when attempting to use a dynamic port. (Siddharth Seth,
reviewed by Prasanth Jayachandran and Sergey Shelukhin)
HIVE-13437. httpserver getPort does not return the actual port when attempting to use a dynamic port. (Siddharth Seth, reviewed by Prasanth Jayachandran and Sergey Shelukhin)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/9a00b2f4
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/9a00b2f4
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/9a00b2f4
Branch: refs/heads/master
Commit: 9a00b2f4c430e6c85c824ac8f4e7a128c551df1a
Parents: 2390823
Author: Siddharth Seth <ss...@apache.org>
Authored: Fri Apr 8 14:38:34 2016 -0700
Committer: Siddharth Seth <ss...@apache.org>
Committed: Fri Apr 8 14:38:34 2016 -0700
----------------------------------------------------------------------
.../java/org/apache/hive/http/HttpServer.java | 25 +++++++++++++-------
.../daemon/services/impl/LlapWebServices.java | 2 +-
.../apache/hive/service/server/HiveServer2.java | 4 ++--
3 files changed, 19 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/9a00b2f4/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 0aa9c89..32956b1 100644
--- a/common/src/java/org/apache/hive/http/HttpServer.java
+++ b/common/src/java/org/apache/hive/http/HttpServer.java
@@ -30,6 +30,7 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import com.google.common.base.Preconditions;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys;
import org.apache.hadoop.hive.conf.HiveConf;
@@ -66,16 +67,20 @@ import org.eclipse.jetty.webapp.WebAppContext;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.Sets;
+import org.slf4j.LoggerFactory;
/**
* A simple embedded Jetty server to serve as HS2/HMS web UI.
*/
public class HttpServer {
+
+ private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(HttpServer.class);
+
public static final String CONF_CONTEXT_ATTRIBUTE = "hive.conf";
public static final String ADMINS_ACL = "admins.acl";
+ private final String name;
private final String appDir;
- private final int port;
private final WebAppContext webAppContext;
private final Server webServer;
@@ -83,7 +88,7 @@ public class HttpServer {
* Create a status server on the given port.
*/
private HttpServer(final Builder b) throws IOException {
- this.port = b.port;
+ this.name = b.name;
webServer = new Server();
appDir = getWebAppsPath(b.name);
@@ -98,7 +103,7 @@ public class HttpServer {
}
public static class Builder {
- private String name;
+ private final String name;
private String host;
private int port;
private int maxThreads;
@@ -111,6 +116,11 @@ public class HttpServer {
private boolean useSPNEGO;
private boolean useSSL;
+ public Builder(String name) {
+ Preconditions.checkArgument(name != null && !name.isEmpty(), "Name must be specified");
+ this.name = name;
+ }
+
public HttpServer build() throws IOException {
return new HttpServer(this);
}
@@ -121,10 +131,6 @@ public class HttpServer {
return this;
}
- public Builder setName(String name) {
- this.name = name;
- return this;
- }
public Builder setHost(String host) {
this.host = host;
@@ -186,6 +192,7 @@ public class HttpServer {
public void start() throws Exception {
webServer.start();
+ LOG.info("Started HttpServer[{}] on port {}", name, getPort());
}
public void stop() throws Exception {
@@ -193,7 +200,7 @@ public class HttpServer {
}
public int getPort() {
- return port;
+ return webServer.getConnectors()[0].getLocalPort();
}
/**
@@ -364,7 +371,7 @@ public class HttpServer {
// Create the channel connector for the web server
Connector connector = createChannelConnector(threadPool.getMaxThreads(), b);
connector.setHost(b.host);
- connector.setPort(port);
+ connector.setPort(b.port);
webServer.addConnector(connector);
// Configure web application contexts for the web server
http://git-wip-us.apache.org/repos/asf/hive/blob/9a00b2f4/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/services/impl/LlapWebServices.java
----------------------------------------------------------------------
diff --git a/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/services/impl/LlapWebServices.java b/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/services/impl/LlapWebServices.java
index d0be9a7..f85bbf2 100644
--- a/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/services/impl/LlapWebServices.java
+++ b/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/services/impl/LlapWebServices.java
@@ -80,7 +80,7 @@ public class LlapWebServices extends AbstractService {
this.useSPNEGO = HiveConf.getBoolVar(conf, ConfVars.LLAP_WEB_AUTO_AUTH);
String bindAddress = "0.0.0.0";
HttpServer.Builder builder =
- new HttpServer.Builder().setName("llap").setPort(this.port).setHost(bindAddress);
+ new HttpServer.Builder("llap").setPort(this.port).setHost(bindAddress);
builder.setConf(new HiveConf(conf, HiveConf.class));
if (UserGroupInformation.isSecurityEnabled()) {
LOG.info("LLAP UI useSSL=" + this.useSSL + ", auto-auth/SPNEGO="
http://git-wip-us.apache.org/repos/asf/hive/blob/9a00b2f4/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 d95f78f..882f4ae 100644
--- a/service/src/java/org/apache/hive/service/server/HiveServer2.java
+++ b/service/src/java/org/apache/hive/service/server/HiveServer2.java
@@ -142,8 +142,8 @@ public class HiveServer2 extends CompositeService {
if (webUIPort <= 0) {
LOG.info("Web UI is disabled since port is set to " + webUIPort);
} else {
- HttpServer.Builder builder = new HttpServer.Builder();
- builder.setName("hiveserver2").setPort(webUIPort).setConf(hiveConf);
+ HttpServer.Builder builder = new HttpServer.Builder("hiveserver2");
+ builder.setPort(webUIPort).setConf(hiveConf);
builder.setHost(hiveConf.getVar(ConfVars.HIVE_SERVER2_WEBUI_BIND_HOST));
builder.setMaxThreads(
hiveConf.getIntVar(ConfVars.HIVE_SERVER2_WEBUI_MAX_THREADS));