ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [2/4] ambari git commit: AMBARI-18437. Hive view not working on LLAP enabled cluster. (dipayanb)
Date Fri, 07 Oct 2016 19:58:19 GMT
AMBARI-18437. Hive view not working on LLAP enabled cluster. (dipayanb)


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

Branch: refs/heads/branch-feature-AMBARI-18456
Commit: e7074ecab2960ea3b8ab9396156413529cff3085
Parents: e0d4a87
Author: Dipayan Bhowmick <dipayan.bhowmick@gmail.com>
Authored: Sat Oct 8 01:05:04 2016 +0530
Committer: Dipayan Bhowmick <dipayan.bhowmick@gmail.com>
Committed: Sat Oct 8 01:07:32 2016 +0530

----------------------------------------------------------------------
 .../ambari/view/hive2/ConnectionFactory.java    | 37 +++++++++++++-------
 .../ambari/view/hive2/PropertyValidator.java    |  8 +++++
 .../views/hive-next/src/main/resources/view.xml |  9 +++++
 3 files changed, 42 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e7074eca/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/ConnectionFactory.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/ConnectionFactory.java
b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/ConnectionFactory.java
index 7295f3a..8fefe15 100644
--- a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/ConnectionFactory.java
+++ b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/ConnectionFactory.java
@@ -33,7 +33,7 @@ public class ConnectionFactory {
   private static final String ZK_HIVE_NAMESPACE_KEY = "hive.server2.zookeeper.namespace";
   private static final String ZK_HIVE_QUORUM = "hive.zookeeper.quorum";
 
-  private static final  String AMBARI_HIVE_SERVICE_NAME = "HIVE";
+  private static final String AMBARI_HIVE_SERVICE_NAME = "HIVE";
   private static final String AMBARI_HIVESERVER_COMPONENT_NAME = "HIVE_SERVER";
 
   private static final String HIVE_SITE = "hive-site";
@@ -47,6 +47,7 @@ public class ConnectionFactory {
   private static final String HIVE_TRANSPORT_MODE_KEY = "hive.server2.transport.mode";
   private static final String HTTP_PATH_KEY = "hive.server2.thrift.http.path";
   private static final String HS2_PROXY_USER = "hive.server2.proxy.user";
+  private static final String USE_HIVE_INTERACTIVE_MODE = "use.hive.interactive.mode";
 
 
   public static ConnectionConfig create(ViewContext context) {
@@ -66,9 +67,16 @@ public class ConnectionFactory {
   }
 
   private static String getFromHiveConfiguration(ViewContext context) {
+    boolean useLLAP = Boolean.valueOf(context.getProperties().get(USE_HIVE_INTERACTIVE_MODE));
     String transportMode = context.getCluster().getConfigurationValue(HIVE_SITE, HIVE_TRANSPORT_MODE_KEY);
     String binaryPort = context.getCluster().getConfigurationValue(HIVE_SITE, BINARY_PORT_KEY);
     String httpPort = context.getCluster().getConfigurationValue(HIVE_SITE, HTTP_PORT_KEY);
+    if (useLLAP) {
+      binaryPort = context.getCluster().getConfigurationValue(HIVE_INTERACTIVE_SITE, BINARY_PORT_KEY);
+      httpPort = context.getCluster().getConfigurationValue(HIVE_INTERACTIVE_SITE, HTTP_PORT_KEY);
+    }
+
+
     String pathKey = context.getCluster().getConfigurationValue(HIVE_SITE, HTTP_PATH_KEY);
     List<String> hiveHosts = context.getCluster().getHostsForServiceComponent(AMBARI_HIVE_SERVICE_NAME,
AMBARI_HIVESERVER_COMPONENT_NAME);
     String sessionParams = context.getProperties().get(HIVE_SESSION_PARAMS);
@@ -87,9 +95,10 @@ public class ConnectionFactory {
 
     StringBuilder builder = new StringBuilder();
     builder.append("jdbc:hive2://")
-      .append(concatHostPorts)
-      .append(";")
-      .append(sessionParams);
+        .append(concatHostPorts);
+    if(!Strings.isNullOrEmpty(sessionParams)) {
+      builder.append(";").append(sessionParams);
+    }
 
     if (!isBinary) {
       builder.append(";").append("transportMode=http;httpPath=").append(pathKey);
@@ -99,27 +108,31 @@ public class ConnectionFactory {
   }
 
   private static String getFromClusterZookeeperConfig(ViewContext context) {
+    boolean useLLAP = Boolean.valueOf(context.getProperties().get(USE_HIVE_INTERACTIVE_MODE));
     String quorum = context.getCluster().getConfigurationValue(HIVE_SITE, ZK_HIVE_QUORUM);
-    if (quorum == null) {
-      quorum = context.getCluster().getConfigurationValue(HIVE_INTERACTIVE_SITE, ZK_HIVE_QUORUM);
-    }
 
     String namespace = context.getCluster().getConfigurationValue(HIVE_SITE, ZK_HIVE_NAMESPACE_KEY);
-    if (namespace == null) {
+    if (useLLAP) {
       namespace = context.getCluster().getConfigurationValue(HIVE_INTERACTIVE_SITE, ZK_HIVE_NAMESPACE_KEY);
     }
 
     String sessionParams = context.getProperties().get(HIVE_SESSION_PARAMS);
 
     String formatted = String.format("jdbc:hive2://%s/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=%s",
quorum, namespace);
-    if(Strings.isNullOrEmpty(sessionParams)){
+    if (Strings.isNullOrEmpty(sessionParams)) {
       sessionParams = "";
     }
 
-    if(!sessionParams.contains(HS2_PROXY_USER)) {
-      sessionParams = sessionParams + ";" + HS2_PROXY_USER + "=" + context.getUsername();
+    if (!sessionParams.contains(HS2_PROXY_USER)) {
+      if (!sessionParams.isEmpty()) {
+        sessionParams += ";";
+      }
+      sessionParams = sessionParams + HS2_PROXY_USER + "=" + context.getUsername();
+    }
+
+    if (sessionParams.isEmpty()) {
+      return formatted;
     }
-    
     return formatted + ";" + sessionParams;
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/e7074eca/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/PropertyValidator.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/PropertyValidator.java
b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/PropertyValidator.java
index 779e950..ad59e34 100644
--- a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/PropertyValidator.java
+++ b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/PropertyValidator.java
@@ -30,6 +30,7 @@ public class PropertyValidator implements Validator {
   public static final String HIVE_PORT = "hive.port";
   public static final String YARN_ATS_URL = "yarn.ats.url";
   public static final String HIVE_SESSION_PARAMS = "hive.session.params";
+  public static final String USE_HIVE_INTERACTIVE_MODE = "use.hive.interactive.mode";
 
   @Override
   public ValidationResult validateInstance(ViewInstanceDefinition viewInstanceDefinition,
ValidationContext validationContext) {
@@ -52,6 +53,13 @@ public class PropertyValidator implements Validator {
       }
     }
 
+    if (property.equals(USE_HIVE_INTERACTIVE_MODE)) {
+      String value = viewInstanceDefinition.getPropertyMap().get(USE_HIVE_INTERACTIVE_MODE);
+      if (!("true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value))) {
+        return new InvalidPropertyValidationResult(false, "Must be 'true' or 'false'");
+      }
+    }
+
     // if associated with cluster(local or remote), no need to validate associated properties
     ClusterType clusterType = viewInstanceDefinition.getClusterType();
     if (clusterType == ClusterType.LOCAL_AMBARI || clusterType == ClusterType.REMOTE_AMBARI)
{

http://git-wip-us.apache.org/repos/asf/ambari/blob/e7074eca/contrib/views/hive-next/src/main/resources/view.xml
----------------------------------------------------------------------
diff --git a/contrib/views/hive-next/src/main/resources/view.xml b/contrib/views/hive-next/src/main/resources/view.xml
index 1754686..671591a 100644
--- a/contrib/views/hive-next/src/main/resources/view.xml
+++ b/contrib/views/hive-next/src/main/resources/view.xml
@@ -207,6 +207,15 @@
         <required>true</required>
     </parameter>
 
+
+    <parameter>
+        <name>use.hive.interactive.mode</name>
+        <description>Connects to the hive interactive server if set true</description>
+        <label>Use Interactive Mode(Tech Preview)</label>
+        <default-value>false</default-value>
+        <required>true</required>
+    </parameter>
+
     <parameter>
         <name>yarn.ats.url</name>
         <description>The URL to the YARN Application Timeline Server, used to provide
Jobs information, typically, this is the yarn.timeline-service.webapp.address property in
the yarn-site.xml configuration.</description>


Mime
View raw message