فهرست منبع

AMBARI-17007. Check new jdbc functionality for SQLA and provide additional testing.(vbrodetskyi)

Vitaly Brodetskyi 9 سال پیش
والد
کامیت
d8355e62fa

+ 37 - 20
ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py

@@ -99,26 +99,19 @@ def hive_service(name, action='start', upgrade_type=None):
        params.hive_jdbc_driver == "org.postgresql.Driver" or \
        params.hive_jdbc_driver == "oracle.jdbc.driver.OracleDriver":
 
-      path_to_jdbc = params.target_hive
-      if not params.jdbc_jar_name:
-        path_to_jdbc = format("{hive_lib}/") + params.default_connectors_map[params.hive_jdbc_driver]
-        if not os.path.isfile(path_to_jdbc):
-          path_to_jdbc = format("{hive_lib}/") + "*"
-          error_message = "Error! Sorry, but we can't find jdbc driver with default name " + params.default_connectors_map[params.hive_jdbc_driver] + \
-                          " in hive lib dir. So, db connection check can fail. Please run 'ambari-server setup --jdbc-db={db_name} --jdbc-driver={path_to_jdbc} on server host.'"
-          print error_message
-          Logger.error(error_message)
-
-      db_connection_check_command = format(
-        "{java64_home}/bin/java -cp {check_db_connection_jar}:{path_to_jdbc} org.apache.ambari.server.DBConnectionVerification '{hive_jdbc_connection_url}' {hive_metastore_user_name} {hive_metastore_user_passwd!p} {hive_jdbc_driver}")
-      
-      try:
-        Execute(db_connection_check_command,
-              path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin', tries=5, try_sleep=10)
-      except:
-        show_logs(params.hive_log_dir, params.hive_user)
-        raise
-        
+      validation_called = False
+
+      if params.target_hive is not None:
+        validation_called = True
+        validate_connection(params.target_hive, params.hive_lib)
+      if params.target_hive2 is not None:
+        validation_called = True
+        validate_connection(params.target_hive2, params.hive_lib2)
+
+      if not validation_called:
+        emessage = "ERROR! DB connection check should be executed at least one time!"
+        Logger.error(emessage)
+
   elif action == 'stop':
 
     daemon_kill_cmd = format("{sudo} kill {pid}")
@@ -148,6 +141,30 @@ def hive_service(name, action='start', upgrade_type=None):
          action = "delete"
     )
 
+def validate_connection(target_path_to_jdbc, hive_lib_path):
+  import params
+
+  path_to_jdbc = target_path_to_jdbc
+  if not params.jdbc_jar_name:
+    path_to_jdbc = format("{hive_lib_path}/") + \
+                   params.default_connectors_map[params.hive_jdbc_driver] if params.hive_jdbc_driver in params.default_connectors_map else None
+    if not os.path.isfile(path_to_jdbc):
+      path_to_jdbc = format("{hive_lib_path}/") + "*"
+      error_message = "Error! Sorry, but we can't find jdbc driver with default name " + params.default_connectors_map[params.hive_jdbc_driver] + \
+                      " in hive lib dir. So, db connection check can fail. Please run 'ambari-server setup --jdbc-db={db_name} --jdbc-driver={path_to_jdbc} on server host.'"
+      Logger.error(error_message)
+
+  db_connection_check_command = format(
+    "{java64_home}/bin/java -cp {check_db_connection_jar}:{path_to_jdbc} org.apache.ambari.server.DBConnectionVerification '{hive_jdbc_connection_url}' {hive_metastore_user_name} {hive_metastore_user_passwd!p} {hive_jdbc_driver}")
+
+  try:
+    Execute(db_connection_check_command,
+            path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin', tries=5, try_sleep=10)
+  except:
+    show_logs(params.hive_log_dir, params.hive_user)
+    raise
+
+
 def check_fs_root(conf_dir, execution_path):
   import params
 

+ 2 - 2
ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service_interactive.py

@@ -66,12 +66,12 @@ def hive_service_interactive(name, action='start', upgrade_type=None):
 
       path_to_jdbc = params.target_hive_interactive
       if not params.jdbc_jar_name:
-        path_to_jdbc = format("{hive_interactive_lib}/") + params.default_connectors_map[params.hive_jdbc_driver]
+        path_to_jdbc = format("{hive_interactive_lib}/") + \
+                       params.default_connectors_map[params.hive_jdbc_driver] if params.hive_jdbc_driver in params.default_connectors_map else None
         if not os.path.isfile(path_to_jdbc):
           path_to_jdbc = format("{hive_interactive_lib}/") + "*"
           error_message = "Error! Sorry, but we can't find jdbc driver with default name " + params.default_connectors_map[params.hive_jdbc_driver] + \
                 " in hive lib dir. So, db connection check can fail. Please run 'ambari-server setup --jdbc-db={db_name} --jdbc-driver={path_to_jdbc} on server host.'"
-          print error_message
           Logger.error(error_message)
 
       db_connection_check_command = format(

+ 1 - 1
ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/params_linux.py

@@ -285,7 +285,7 @@ lib_dir_available = os.path.exists(jdbc_libs_dir)
 if sqla_db_used:
   jars_path_in_archive = format("{tmp_dir}/sqla-client-jdbc/java/*")
   libs_path_in_archive = format("{tmp_dir}/sqla-client-jdbc/native/lib64/*")
-  downloaded_custom_connector = format("{tmp_dir}/sqla-client-jdbc.tar.gz")
+  downloaded_custom_connector = format("{tmp_dir}/{jdbc_jar_name}")
   libs_in_hive_lib = format("{jdbc_libs_dir}/*")
 
 

+ 2 - 2
ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_service.py

@@ -71,12 +71,12 @@ def oozie_service(action = 'start', upgrade_type=None):
        params.jdbc_driver_name == "oracle.jdbc.driver.OracleDriver":
 
       if not params.jdbc_driver_jar:
-        path_to_jdbc = format("{oozie_libext_dir}/") + params.default_connectors_map[params.jdbc_driver_name]
+        path_to_jdbc = format("{oozie_libext_dir}/") + \
+                       params.default_connectors_map[params.jdbc_driver_name] if params.jdbc_driver_name in params.default_connectors_map else None
         if not os.path.isfile(path_to_jdbc):
           path_to_jdbc = format("{oozie_libext_dir}/") + "*"
           error_message = "Error! Sorry, but we can't find jdbc driver with default name " + params.default_connectors_map[params.jdbc_driver_name] + \
                 " in oozie lib dir. So, db connection check can fail. Please run 'ambari-server setup --jdbc-db={db_name} --jdbc-driver={path_to_jdbc} on server host.'"
-          print error_message
           Logger.error(error_message)
 
       db_connection_check_command = format("{java_home}/bin/java -cp {check_db_connection_jar}:{path_to_jdbc} org.apache.ambari.server.DBConnectionVerification '{oozie_jdbc_connection_url}' {oozie_metastore_user_name} {oozie_metastore_user_passwd!p} {jdbc_driver_name}")

+ 1 - 1
ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_linux.py

@@ -253,7 +253,7 @@ lib_dir_available = os.path.exists(jdbc_libs_dir)
 if sqla_db_used:
   jars_path_in_archive = format("{tmp_dir}/sqla-client-jdbc/java/*")
   libs_path_in_archive = format("{tmp_dir}/sqla-client-jdbc/native/lib64/*")
-  downloaded_custom_connector = format("{tmp_dir}/sqla-client-jdbc.tar.gz")
+  downloaded_custom_connector = format("{tmp_dir}/{jdbc_driver_jar}")
 
 hdfs_share_dir = format("{oozie_hdfs_user_dir}/share")
 ambari_server_hostname = config['clusterHostInfo']['ambari_server_host'][0]

+ 2 - 2
ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms.py

@@ -152,12 +152,12 @@ def kms(upgrade_type=None):
     else:
       path_to_jdbc = format("{kms_home}/ews/webapp/lib/{jdbc_jar_name}")
       if not os.path.isfile(path_to_jdbc):
-        path_to_jdbc = format("{kms_home}/ews/webapp/lib/") + params.default_connectors_map[params.db_flavor.lower()]
+        path_to_jdbc = format("{kms_home}/ews/webapp/lib/") + \
+                       params.default_connectors_map[params.db_flavor.lower()] if params.db_flavor.lower() in params.default_connectors_map else None
         if not os.path.isfile(path_to_jdbc):
           path_to_jdbc = format("{kms_home}/ews/webapp/lib/") + "*"
           error_message = "Error! Sorry, but we can't find jdbc driver with default name " + params.default_connectors_map[params.db_flavor] + \
                 " in ranger kms lib dir. So, db connection check can fail. Please run 'ambari-server setup --jdbc-db={db_name} --jdbc-driver={path_to_jdbc} on server host.'"
-          print error_message
           Logger.error(error_message)
 
       cp = cp + os.pathsep + path_to_jdbc