You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2015/12/18 22:36:59 UTC

ambari git commit: AMBARI-14437 - Unable To Restart HCat Client When Not Colocated With WebHCat Server (jonathanhurley)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 ea9339f24 -> 1c88d47c0


AMBARI-14437 - Unable To Restart HCat Client When Not Colocated With WebHCat Server (jonathanhurley)


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

Branch: refs/heads/branch-2.2
Commit: 1c88d47c0fb7cdba2d5626f7714dca467355d9ed
Parents: ea9339f
Author: Jonathan Hurley <jh...@hortonworks.com>
Authored: Fri Dec 18 14:35:46 2015 -0500
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Fri Dec 18 16:36:50 2015 -0500

----------------------------------------------------------------------
 .../0.12.0.2.0/package/scripts/hcat_client.py   | 37 +++++++++++++++++---
 .../stacks/2.0.6/HIVE/test_hcat_client.py       | 24 +++++++++++++
 2 files changed, 57 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1c88d47c/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hcat_client.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hcat_client.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hcat_client.py
index 75a37f1..b372085 100644
--- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hcat_client.py
+++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hcat_client.py
@@ -18,12 +18,14 @@ limitations under the License.
 
 """
 
-import sys
-from resource_management import *
 from hcat import hcat
-from setup_atlas_hive import setup_atlas_hive
 from ambari_commons import OSConst
 from ambari_commons.os_family_impl import OsFamilyImpl
+from resource_management.core.logger import Logger
+from resource_management.core.exceptions import ClientComponentHasNoStatus
+from resource_management.libraries.functions import hdp_select
+from resource_management.libraries.functions.version import compare_versions
+from resource_management.libraries.script.script import Script
 
 
 class HCatClient(Script):
@@ -49,7 +51,34 @@ class HCatClientWindows(HCatClient):
 @OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT)
 class HCatClientDefault(HCatClient):
   def get_stack_to_component(self):
-    return {"HDP": "hadoop-client"}
+    # HCat client doesn't have a first-class entry in hdp-select. Since clients always
+    # update after daemons, this ensures that the hcat directories are correct on hosts
+    # which do not include the WebHCat daemon
+    return {"HDP": "hive-webhcat"}
+
+
+  def pre_upgrade_restart(self, env, upgrade_type=None):
+    """
+    Execute hdp-select before reconfiguring this client to the new HDP version.
+
+    :param env:
+    :param upgrade_type:
+    :return:
+    """
+    Logger.info("Executing Hive HCat Client Stack Upgrade pre-restart")
+
+    import params
+    env.set_params(params)
+
+    # this function should not execute if the version can't be determined or
+    # is not at least HDP 2.2.0.0
+    if not params.version or compare_versions(params.version, "2.2", format=True) < 0:
+      return
+
+    # HCat client doesn't have a first-class entry in hdp-select. Since clients always
+    # update after daemons, this ensures that the hcat directories are correct on hosts
+    # which do not include the WebHCat daemon
+    hdp_select.select("hive-webhcat", params.version)
 
 
 if __name__ == "__main__":

http://git-wip-us.apache.org/repos/asf/ambari/blob/1c88d47c/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hcat_client.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hcat_client.py b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hcat_client.py
index e709693..bd791c7 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hcat_client.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hcat_client.py
@@ -17,6 +17,7 @@ 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.
 '''
+import json
 from mock.mock import MagicMock, call, patch
 from stacks.utils.RMFTestCase import *
 
@@ -100,3 +101,26 @@ class TestHcatClient(RMFTestCase):
                               )
 
     self.assertNoMoreResources()
+
+
+  @patch("resource_management.core.shell.call")
+  def test_pre_upgrade_restart(self, call_mock):
+    config_file = self.get_src_folder()+"/test/python/stacks/2.0.6/configs/default.json"
+    with open(config_file, "r") as f:
+      json_content = json.load(f)
+
+    version = '2.3.0.0-1234'
+    json_content['commandParams']['version'] = version
+
+    mocks_dict = {}
+    self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hcat_client.py",
+      classname = "HCatClient",
+      command = "pre_upgrade_restart",
+      config_dict = json_content,
+      hdp_stack_version = self.STACK_VERSION,
+      target = RMFTestCase.TARGET_COMMON_SERVICES,
+      call_mocks = [(0, None, ''), (0, None, ''), (0, None, ''), (0, None, '')],
+      mocks_dict = mocks_dict)
+
+    self.assertResourceCalled('Execute',('ambari-python-wrap', '/usr/bin/hdp-select', 'set', 'hive-webhcat', version), sudo=True,)
+    self.assertNoMoreResources()
\ No newline at end of file