ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [15/51] [abbrv] ambari git commit: AMBARI-14437 - Unable To Restart HCat Client When Not Colocated With WebHCat Server (jonathanhurley)
Date Wed, 23 Dec 2015 15:06:54 GMT
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/b61f6eaf
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b61f6eaf
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b61f6eaf

Branch: refs/heads/branch-dev-patch-upgrade
Commit: b61f6eafab1e2eb6ef7ae8dacce87baa742933eb
Parents: 3b693ea
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Fri Dec 18 14:35:46 2015 -0500
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Fri Dec 18 16:36:20 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/b61f6eaf/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/b61f6eaf/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 396e6a1..4dfa688 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


Mime
View raw message