FAQ
Repository: hive
Updated Branches:
   refs/heads/master 26268deb4 -> 16fb16d52


HIVE-12958: Make embedded Jetty server more configurable (Aihua Xu, reviewed by Yongzhi Chen)


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

Branch: refs/heads/master
Commit: 16fb16d524096bfead386ab50d772659ead773d5
Parents: 26268de
Author: Aihua Xu <aihuaxu@apache.org>
Authored: Thu Jan 28 16:00:24 2016 -0500
Committer: Aihua Xu <aihuaxu@apache.org>
Committed: Thu Feb 4 10:58:58 2016 -0500

----------------------------------------------------------------------
  .../svr/src/main/config/webhcat-default.xml | 6 ++++++
  .../hive/hcatalog/templeton/AppConfig.java | 2 ++
  .../apache/hive/hcatalog/templeton/Main.java | 20 ++++++++++++++++++--
  3 files changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/16fb16d5/hcatalog/webhcat/svr/src/main/config/webhcat-default.xml
----------------------------------------------------------------------
diff --git a/hcatalog/webhcat/svr/src/main/config/webhcat-default.xml b/hcatalog/webhcat/svr/src/main/config/webhcat-default.xml
index 801f3a5..e33cf8c 100644
--- a/hcatalog/webhcat/svr/src/main/config/webhcat-default.xml
+++ b/hcatalog/webhcat/svr/src/main/config/webhcat-default.xml
@@ -32,6 +32,12 @@
    </property>

    <property>
+ <name>templeton.jetty.configuration</name>
+ <value></value>
+ <description>The embedded jetty configuration file.</description>
+ </property>
+
+ <property>
      <name>templeton.hadoop.conf.dir</name>
      <value>${env.HADOOP_CONF_DIR}</value>
      <description>The path to the Hadoop configuration.</description>

http://git-wip-us.apache.org/repos/asf/hive/blob/16fb16d5/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/AppConfig.java
----------------------------------------------------------------------
diff --git a/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/AppConfig.java b/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/AppConfig.java
index 992aa38..161ab3b 100644
--- a/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/AppConfig.java
+++ b/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/AppConfig.java
@@ -95,6 +95,7 @@ public class AppConfig extends Configuration {
    }

    public static final String PORT = "templeton.port";
+ public static final String JETTY_CONFIGURATION = "templeton.jetty.configuration";
    public static final String EXEC_ENCODING_NAME = "templeton.exec.encoding";
    public static final String EXEC_ENVS_NAME = "templeton.exec.envs";
    public static final String EXEC_MAX_BYTES_NAME = "templeton.exec.max-output-bytes";
@@ -340,6 +341,7 @@ public class AppConfig extends Configuration {
      return false;
    }

+ public String jettyConfiguration() { return get(JETTY_CONFIGURATION); }
    public String libJars() { return get(LIB_JARS_NAME); }
    public String hadoopQueueName() { return get(HADOOP_QUEUE_NAME); }
    public String enableJobReconnectDefault() { return get(ENABLE_JOB_RECONNECT_DEFAULT); }

http://git-wip-us.apache.org/repos/asf/hive/blob/16fb16d5/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Main.java
----------------------------------------------------------------------
diff --git a/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Main.java b/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Main.java
index 8aca9da..d5fea1e 100644
--- a/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Main.java
+++ b/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Main.java
@@ -22,12 +22,15 @@ import com.sun.jersey.api.core.PackagesResourceConfig;
  import com.sun.jersey.spi.container.servlet.ServletContainer;

  import java.io.File;
+import java.io.FileInputStream;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.HashMap;

  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.ArrayUtils;
  import org.apache.hadoop.hive.common.classification.InterfaceAudience;
  import org.apache.hadoop.hive.common.classification.InterfaceStability;
  import org.apache.hadoop.hdfs.web.AuthFilter;
@@ -44,6 +47,7 @@ import org.eclipse.jetty.servlet.FilterHolder;
  import org.eclipse.jetty.servlet.FilterMapping;
  import org.eclipse.jetty.servlet.ServletContextHandler;
  import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.xml.XmlConfiguration;
  import org.slf4j.bridge.SLF4JBridgeHandler;

  import javax.servlet.http.HttpServletRequest;
@@ -116,6 +120,9 @@ public class Main {
      try {
        checkEnv();
        runServer(port);
+ // Currently only print the first port to be consistent with old behavior
+ port = ArrayUtils.isEmpty(server.getConnectors()) ? -1 : server.getConnectors()[0].getPort();
+
        System.out.println("templeton: listening on port " + port);
        LOG.info("Templeton listening on port " + port);
      } catch (Exception e) {
@@ -162,8 +169,17 @@ public class Main {
          conf.kerberosKeytab());
      }

- // Create the Jetty server
- Server server = new Server(port);
+ // Create the Jetty server. If jetty conf file exists, use that to create server
+ // to have more control.
+ Server server = null;
+ if (StringUtils.isEmpty(conf.jettyConfiguration())) {
+ server = new Server(port);
+ } else {
+ FileInputStream jettyConf = new FileInputStream(conf.jettyConfiguration());
+ XmlConfiguration configuration = new XmlConfiguration(jettyConf);
+ server = (Server)configuration.configure();
+ }
+
      ServletContextHandler root = new ServletContextHandler(server, "/");

      // Add the Auth filter

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommits @
categorieshive, hadoop
postedFeb 4, '16 at 4:01p
activeFeb 4, '16 at 4:01p
posts1
users1
websitehive.apache.org

1 user in discussion

Aihuaxu: 1 post

People

Translate

site design / logo © 2021 Grokbase