From f3cc0938cb1bf60e4eb3a6546e5f00a56d5ba077 Mon Sep 17 00:00:00 2001 From: Gopal V Date: Thu, 11 Feb 2016 12:23:08 -0800 Subject: [PATCH] use http from hive-common add SSL move to hive-webapps real move --- .../hadoop/hive/llap/cli/LlapServiceDriver.java | 3 + .../llap/daemon/services/impl/LlapWebServices.java | 65 ++++++++++------------ .../src/main/resources/hive-webapps/llap/.keep | 0 llap-server/src/main/resources/webapps/llap/.keep | 0 4 files changed, 31 insertions(+), 37 deletions(-) create mode 100644 llap-server/src/main/resources/hive-webapps/llap/.keep delete mode 100644 llap-server/src/main/resources/webapps/llap/.keep diff --git llap-server/src/java/org/apache/hadoop/hive/llap/cli/LlapServiceDriver.java llap-server/src/java/org/apache/hadoop/hive/llap/cli/LlapServiceDriver.java index d01c8ce..42bf419 100644 --- llap-server/src/java/org/apache/hadoop/hive/llap/cli/LlapServiceDriver.java +++ llap-server/src/java/org/apache/hadoop/hive/llap/cli/LlapServiceDriver.java @@ -45,6 +45,7 @@ import org.apache.hadoop.mapred.JobConf; import org.apache.hadoop.mapreduce.Job; import org.apache.hadoop.yarn.conf.YarnConfiguration; +import org.eclipse.jetty.server.ssl.SslSocketConnector; import org.json.JSONObject; import com.google.common.base.Preconditions; @@ -227,6 +228,8 @@ private void run(String[] args) throws Exception { lfs.copyFromLocalFile(new Path(Utilities.jarFinderGetJar(LlapInputFormat.class)), libDir); // hive-exec lfs.copyFromLocalFile(new Path(Utilities.jarFinderGetJar(HiveInputFormat.class)), libDir); + // hive-common (https deps) + lfs.copyFromLocalFile(new Path(Utilities.jarFinderGetJar(SslSocketConnector.class)), libDir); // copy default aux classes (json/hbase) diff --git llap-server/src/java/org/apache/hadoop/hive/llap/daemon/services/impl/LlapWebServices.java llap-server/src/java/org/apache/hadoop/hive/llap/daemon/services/impl/LlapWebServices.java index e233b41..0c6fc3f 100644 --- llap-server/src/java/org/apache/hadoop/hive/llap/daemon/services/impl/LlapWebServices.java +++ llap-server/src/java/org/apache/hadoop/hive/llap/daemon/services/impl/LlapWebServices.java @@ -17,25 +17,23 @@ */ package org.apache.hadoop.hive.llap.daemon.services.impl; +import java.io.IOException; + import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.conf.HiveConf.ConfVars; -import org.apache.hadoop.http.HttpConfig.Policy; -import org.apache.hadoop.security.AuthenticationFilterInitializer; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.service.AbstractService; -import org.apache.hadoop.yarn.conf.YarnConfiguration; -import org.apache.hadoop.yarn.webapp.WebApp; -import org.apache.hadoop.yarn.webapp.WebApps; -import org.apache.hadoop.yarn.webapp.WebApps.Builder; +import org.apache.hive.http.HttpServer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class LlapWebServices extends AbstractService { + private static final Logger LOG = LoggerFactory.getLogger(LlapWebServices.class); private int port; - private Configuration conf; - private WebApp webApp; - private LlapWebApp webAppInstance; + private HttpServer http; public LlapWebServices() { super("LlapWebServices"); @@ -43,44 +41,37 @@ public LlapWebServices() { @Override public void serviceInit(Configuration conf) { - this.conf = new Configuration(conf); - this.conf.addResource(YarnConfiguration.YARN_SITE_CONFIGURATION_FILE); - this.port = HiveConf.getIntVar(conf, ConfVars.LLAP_DAEMON_WEB_PORT); + String bindAddress = "0.0.0.0"; + HttpServer.Builder builder = + new HttpServer.Builder().setName("llap").setPort(this.port).setHost(bindAddress); + builder.setConf(new HiveConf(conf, HiveConf.class)); + if (UserGroupInformation.isSecurityEnabled()) { + builder.setUseSSL(true); + if (HiveConf.getBoolVar(conf, ConfVars.LLAP_WEB_AUTO_AUTH)) { + builder.setUseSPNEGO(true); // this setups auth filtering in build() + builder.setSPNEGOPrincipal(HiveConf.getVar(conf, ConfVars.LLAP_KERBEROS_PRINCIPAL)); + builder.setSPNEGOKeytab(HiveConf.getVar(conf, ConfVars.LLAP_KERBEROS_KEYTAB_FILE)); + } + } - this.webAppInstance = new LlapWebApp(); + try { + this.http = builder.build(); + } catch (IOException e) { + LOG.warn("LLAP web service failed to come up", e); + } } @Override public void serviceStart() throws Exception { - String bindAddress = "0.0.0.0"; - if (UserGroupInformation.isSecurityEnabled() - && HiveConf.getBoolVar(conf, ConfVars.LLAP_WEB_AUTO_AUTH)) { - conf.set("hadoop.http.authentication.type", "kerberos"); - conf.set("hadoop.http.authentication.kerberos.principal", - HiveConf.getVar(conf, ConfVars.LLAP_KERBEROS_PRINCIPAL)); - conf.set("hadoop.http.authentication.kerberos.keytab", - HiveConf.getVar(conf, ConfVars.LLAP_KERBEROS_KEYTAB_FILE)); - String authFilterName = AuthenticationFilterInitializer.class.getName(); - String initializers = conf.getTrimmed("hadoop.http.filter.initializers"); - if (initializers == null || initializers.isEmpty()) { - initializers = authFilterName; - } else if (!initializers.contains(authFilterName)) { - initializers = authFilterName + "," + initializers; - } - conf.set("hadoop.http.filter.initializers", initializers); - } - Builder webAppBuilder = - WebApps.$for("llap").at(bindAddress).at(port).with(conf); - if (UserGroupInformation.isSecurityEnabled()) { - webAppBuilder.withHttpPolicy(conf, Policy.HTTPS_ONLY); + if (this.http != null) { + this.http.start(); } - this.webApp = webAppBuilder.start(); } public void serviceStop() throws Exception { - if (this.webApp != null) { - this.webApp.stop(); + if (this.http != null) { + this.http.stop(); } } } diff --git llap-server/src/main/resources/hive-webapps/llap/.keep llap-server/src/main/resources/hive-webapps/llap/.keep new file mode 100644 index 0000000..e69de29 diff --git llap-server/src/main/resources/webapps/llap/.keep llap-server/src/main/resources/webapps/llap/.keep deleted file mode 100644 index e69de29..0000000 -- 2.4.0