Repository: ambari
Updated Branches:
  refs/heads/trunk 0fc46d029 -> 041d89f2e


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


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

Branch: refs/heads/trunk
Commit: 041d89f2ee000d83f58df2addd1fae79145e217c
Parents: 0fc46d0
Author: Vitaly Brodetskyi <[email protected]>
Authored: Thu Jun 2 23:09:42 2016 +0300
Committer: Vitaly Brodetskyi <[email protected]>
Committed: Thu Jun 2 23:09:42 2016 +0300

----------------------------------------------------------------------
 .../0.12.0.2.0/package/scripts/hive_service.py  | 57 +++++++++++++-------
 .../package/scripts/hive_service_interactive.py |  4 +-
 .../0.12.0.2.0/package/scripts/params_linux.py  |  2 +-
 .../4.0.0.2.0/package/scripts/oozie_service.py  |  4 +-
 .../4.0.0.2.0/package/scripts/params_linux.py   |  2 +-
 .../RANGER_KMS/0.5.0.2.3/package/scripts/kms.py |  4 +-
 6 files changed, 45 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/041d89f2/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py
 
b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py
index bd8c33b..0a3d921 100644
--- 
a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py
+++ 
b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py
@@ -98,26 +98,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}")
@@ -147,6 +140,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
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/041d89f2/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service_interactive.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service_interactive.py
 
b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service_interactive.py
index 053b5e5..1edcdca 100644
--- 
a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service_interactive.py
+++ 
b/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(

http://git-wip-us.apache.org/repos/asf/ambari/blob/041d89f2/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/params_linux.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/params_linux.py
 
b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/params_linux.py
index 7657dbc..fea0635 100644
--- 
a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/params_linux.py
+++ 
b/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}/*")
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/041d89f2/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_service.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_service.py
 
b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_service.py
index 0c8557e..d5164fe 100644
--- 
a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_service.py
+++ 
b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_service.py
@@ -73,12 +73,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}")

http://git-wip-us.apache.org/repos/asf/ambari/blob/041d89f2/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_linux.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_linux.py
 
b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_linux.py
index 542be3f..08b10b6 100644
--- 
a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_linux.py
+++ 
b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_linux.py
@@ -252,7 +252,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]

http://git-wip-us.apache.org/repos/asf/ambari/blob/041d89f2/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms.py
 
b/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms.py
index eaa6e4c..cbe2a31 100755
--- 
a/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms.py
+++ 
b/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

Reply via email to