Repository: ambari Updated Branches: refs/heads/trunk da3a88f2c -> 04f54294e
AMBARI-9505 Hive service with HDPWIN 2.2 fails to start Copying the SQL Server JDBC driver into the hadoop shared lib directory. Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/04f54294 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/04f54294 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/04f54294 Branch: refs/heads/trunk Commit: 04f54294eb182c719c2998c67b9865d3e0b3fc9c Parents: da3a88f Author: Florian Barca <fba...@hortonworks.com> Authored: Wed Mar 11 16:09:45 2015 -0700 Committer: Florian Barca <fba...@hortonworks.com> Committed: Wed Mar 11 16:09:45 2015 -0700 ---------------------------------------------------------------------- .../libraries/functions/__init__.py | 1 + .../libraries/functions/install_jdbc_driver.py | 48 ++++++++++++++++++++ .../2.1/hooks/after-INSTALL/scripts/hook.py | 11 ++++- 3 files changed, 58 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/04f54294/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py ---------------------------------------------------------------------- diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py b/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py index f6db722..e55a2cf 100644 --- a/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py +++ b/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py @@ -43,4 +43,5 @@ IS_WINDOWS = platform.system() == "Windows" if IS_WINDOWS: from resource_management.libraries.functions.windows_service_utils import * from resource_management.libraries.functions.install_hdp_msi import * + from resource_management.libraries.functions.install_jdbc_driver import * from resource_management.libraries.functions.reload_windows_env import * http://git-wip-us.apache.org/repos/asf/ambari/blob/04f54294/ambari-common/src/main/python/resource_management/libraries/functions/install_jdbc_driver.py ---------------------------------------------------------------------- diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/install_jdbc_driver.py b/ambari-common/src/main/python/resource_management/libraries/functions/install_jdbc_driver.py new file mode 100644 index 0000000..be77cfd --- /dev/null +++ b/ambari-common/src/main/python/resource_management/libraries/functions/install_jdbc_driver.py @@ -0,0 +1,48 @@ +""" +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. + +Ambari Agent + +""" + +import os + +from ambari_commons.inet_utils import download_file +from ambari_commons.os_utils import copy_file, search_file +from resource_management.core.logger import Logger + + +__all__ = ["ensure_jdbc_driver_is_in_classpath"] + + +def ensure_jdbc_driver_is_in_classpath(dest_dir, cache_location, driver_url, driver_files): + #Attempt to find the JDBC driver installed locally + #If not, attempt to download it from the server resources URL + for driver_file in driver_files: + dest_path = os.path.join(dest_dir, driver_file) + Logger.info("JDBC driver file(s) {0}: Attempting to copy from {1} or download from {2} to {3}".format( + str(driver_files), cache_location, driver_url, dest_dir)) + if not os.path.exists(dest_path): + search_path = os.environ["PATH"] + if cache_location: + search_path += os.pathsep + cache_location #The locally installed version takes precedence over the cache + + local_path = search_file(driver_file, search_path) + if not local_path: + download_file(driver_url + "/" + driver_file, dest_path) + else: + copy_file(local_path, dest_path) http://git-wip-us.apache.org/repos/asf/ambari/blob/04f54294/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/after-INSTALL/scripts/hook.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/after-INSTALL/scripts/hook.py b/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/after-INSTALL/scripts/hook.py index 31df28d..91ae05d 100644 --- a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/after-INSTALL/scripts/hook.py +++ b/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/after-INSTALL/scripts/hook.py @@ -19,18 +19,25 @@ limitations under the License. import sys -from ambari_commons.inet_utils import download_file from resource_management import * from resource_management.libraries import Hook #Hook for hosts with only client without other components class AfterInstallHook(Hook): - def hook(self, env): import params env.set_params(params) + #The SQL Server JDBC driver needs to end up in HADOOP_COMMOON_DIR\share\hadoop\common\lib + try: + ensure_jdbc_driver_is_in_classpath(params.hadoop_common_dir, + params.config["hostLevelParams"]["agentCacheDir"], + params.config['hostLevelParams']['jdk_location'], + ["sqljdbc4.jar", "sqljdbc_auth.dll"]) + except Exception, e: + raise Fail("Unable to deploy the required JDBC driver in the class path. Error info: {0}".format(e.message)) + XmlConfig("core-site.xml", conf_dir=params.hadoop_conf_dir, configurations=params.config['configurations']['core-site'],