Browse Source

AMBARI-16805. Fixing the failing Hive Service check for 'Hive Server Interactive' component.

Swapan Shridhar 9 years ago
parent
commit
ef772d235c

+ 0 - 40
ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/files/hiveLlapSmoke.sh

@@ -1,40 +0,0 @@
-#!/usr/bin/env bash
-#
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-#
-#
-
-: '
- Parameters:
- $1 : Stack root
- $2 : Name of table to be created
- $3 : Command name.
-'
-export tableName=$2
-
-case "$3" in
-
-prepare)
-  $1/current/hive-server2-hive2/bin/hive --hiveconf "hiveLlapServiceCheck=$tableName" -f $1/current/hive-server2-hive2/scripts/llap/sql/serviceCheckScript.sql
-;;
-
-cleanup)
-;;
-
-esac

+ 32 - 9
ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/service_check.py

@@ -32,7 +32,6 @@ from resource_management.core import shell
 from resource_management.core.logger import Logger
 from resource_management.libraries.functions import get_unique_id_and_date
 
-
 class HiveServiceCheck(Script):
   pass
 
@@ -83,7 +82,9 @@ class HiveServiceCheckDefault(HiveServiceCheck):
 
       Logger.info("Running LLAP checks")
       Logger.info("-------------------\n")
-      self.check_llap(env, kinit_cmd)
+      self.check_llap(env, kinit_cmd, params.hive_interactive_hosts, int(format("{hive_server_interactive_port}")),
+                      params.hive_server_principal, params.hive_server2_authentication, params.hive_transport_mode,
+                      params.hive_http_endpoint)
 
 
     Logger.info("Running HCAT checks")
@@ -138,27 +139,49 @@ class HiveServiceCheckDefault(HiveServiceCheck):
     Logger.info("Successfully stayed connected to '{0}' on host: {1} and port {2} after {3} seconds"
                 .format(server_component_name, params.hostname, server_port, elapsed_time))
 
-  def check_llap(self, env, kinit_cmd):
+  """
+  Performs Service check for LLAP app
+  """
+  def check_llap(self, env, kinit_cmd, address, port, key, hive_auth="NOSASL", transport_mode="binary", http_endpoint="cliservice"):
     import params
     env.set_params(params)
 
-    File(format("{tmp_dir}/hiveLlapSmoke.sh"),
-         content=StaticFile("hiveLlapSmoke.sh"),
-         mode=0755
-         )
     unique_id = get_unique_id_and_date()
-    llap_cmd = format("{kinit_cmd}env JAVA_HOME={java64_home} {tmp_dir}/hiveLlapSmoke.sh {stack_root} llap_smoke_{unique_id} prepare")
+
+    beeline_url = ['jdbc:hive2://{address}:{port}/', "transportMode={transport_mode}"]
+
+    # Currently, HSI is supported on a single node only. The address list should be of size 1,
+    # thus picking the 1st node value.
+    address = address[0]
+
+    # append url according to used transport
+    if transport_mode == "http":
+      beeline_url.append('httpPath={http_endpoint}')
+
+    # append url according to used auth
+    if hive_auth == "NOSASL":
+      beeline_url.append('auth=noSasl')
+
+    # append url according to principal
+    if kinit_cmd:
+      beeline_url.append('principal={key}')
 
     exec_path = params.execute_path
     if params.version and params.stack_root:
       upgrade_hive_bin = format("{stack_root}/{version}/hive2/bin")
       exec_path =  os.environ['PATH'] + os.pathsep + params.hadoop_bin_dir + os.pathsep + upgrade_hive_bin
 
+    # beeline path
+    llap_cmd = "! beeline -u '%s'" % format(";".join(beeline_url))
+    # Append LLAP SQL script path
+    llap_cmd += format(" --hiveconf \"hiveLlapServiceCheck={unique_id}\" -f {stack_root}/current/hive-server2-hive2/scripts/llap/sql/serviceCheckScript.sql")
+    # Append grep patterns for detecting failure
+    llap_cmd += " -e '' 2>&1| awk '{print}'|grep -i -e 'Invalid status\|Invalid URL\|command not found\|Connection refused'"
+
     Execute(llap_cmd,
             user=params.hive_user,
             path=['/usr/sbin', '/usr/local/bin', '/bin', '/usr/bin', exec_path],
             tries=1,
-            try_sleep=5,
             wait_for_finish=True,
             stderr=subprocess.PIPE,
             logoutput=True)