Repository: ambari Updated Branches: refs/heads/branch-2.4 c9792fc3e -> 2ad0be28a
AMBARI-17207: Export PGHOST before any HAWQ Master or Standby custom command is executed (mithmatt) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/2ad0be28 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/2ad0be28 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/2ad0be28 Branch: refs/heads/branch-2.4 Commit: 2ad0be28a844fb3d7b8de4ce3bc31288f6549031 Parents: c9792fc Author: Matt <[email protected]> Authored: Mon Jun 13 20:55:38 2016 -0700 Committer: Matt <[email protected]> Committed: Mon Jun 13 20:55:38 2016 -0700 ---------------------------------------------------------------------- .../2.0.0/package/scripts/hawq_constants.py | 1 + .../HAWQ/2.0.0/package/scripts/hawqmaster.py | 24 ++++++++++++-------- .../HAWQ/2.0.0/package/scripts/hawqstandby.py | 4 +++- .../HAWQ/2.0.0/package/scripts/utils.py | 5 ++-- .../python/stacks/2.3/HAWQ/test_hawqmaster.py | 11 +++++---- .../python/stacks/2.3/HAWQ/test_hawqstandby.py | 2 +- 6 files changed, 30 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/2ad0be28/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawq_constants.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawq_constants.py b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawq_constants.py index 1804f11..3ced8d1 100644 --- a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawq_constants.py +++ b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawq_constants.py @@ -22,6 +22,7 @@ STANDBY = "standby" SEGMENT = "segment" START = "start" INIT = "init" +CHECK = "check" STOP = "stop" YARN = "yarn" CLUSTER = "cluster" http://git-wip-us.apache.org/repos/asf/ambari/blob/2ad0be28/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqmaster.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqmaster.py b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqmaster.py index dc9bb12..a8be8e9 100644 --- a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqmaster.py +++ b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqmaster.py @@ -97,23 +97,29 @@ class HawqMaster(Script): if str(params.security_enabled).lower() == "true": additional_flags.append("--kerberos") - Execute("source {0} && hawq check -f {1} --hadoop {2} --config {3} {4}".format(hawq_constants.hawq_greenplum_path_file, - hawq_constants.hawq_hosts_file, - stack_select.get_hadoop_dir('home'), - hawq_constants.hawq_check_file, - " ".join(additional_flags)), - user=hawq_constants.hawq_user, - timeout=hawq_constants.default_exec_timeout) + utils.exec_hawq_operation(hawq_constants.CHECK, + "-f {1} --hadoop {2} --config {3} {4}".format(hawq_constants.hawq_greenplum_path_file, + hawq_constants.hawq_hosts_file, + stack_select.get_hadoop_dir('home'), + hawq_constants.hawq_check_file, + " ".join(additional_flags)), + host_name=params.hawqmaster_host) def resync_hawq_standby(self,env): + import params Logger.info("HAWQ Standby Master Re-Sync started in fast mode...") - utils.exec_hawq_operation(hawq_constants.INIT, "{0} -n -a -v -M {1}".format(hawq_constants.STANDBY, hawq_constants.FAST)) + utils.exec_hawq_operation(hawq_constants.INIT, + "{0} -n -a -v -M {1}".format(hawq_constants.STANDBY, hawq_constants.FAST), + host_name=params.hawqmaster_host) def remove_hawq_standby(self, env): + import params Logger.info("Removing HAWQ Standby Master ...") - utils.exec_hawq_operation(hawq_constants.INIT, "{0} -a -v -r --ignore-bad-hosts".format(hawq_constants.STANDBY)) + utils.exec_hawq_operation(hawq_constants.INIT, + "{0} -a -v -r --ignore-bad-hosts".format(hawq_constants.STANDBY), + host_name=params.hawqmaster_host) if __name__ == "__main__": http://git-wip-us.apache.org/repos/asf/ambari/blob/2ad0be28/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqstandby.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqstandby.py b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqstandby.py index 119f2c7..eb7ae4b 100644 --- a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqstandby.py +++ b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqstandby.py @@ -60,7 +60,9 @@ class HawqStandby(Script): params.XmlConfig("hawq-site.xml", configurations=params.hawq_site, configuration_attributes=params.config_attrs['hawq-site']) - utils.exec_hawq_operation(hawq_constants.ACTIVATE, "{0} -a -M {1} -v --ignore-bad-hosts".format(hawq_constants.STANDBY, hawq_constants.FAST)) + utils.exec_hawq_operation(hawq_constants.ACTIVATE, + "{0} -a -M {1} -v --ignore-bad-hosts".format(hawq_constants.STANDBY, hawq_constants.FAST), + host_name=params.hawqstandby_host) # Stop the new HAWQMASTER as the process might be running at an old port, # which might cause a failure in Start HAWQ Service step in the Activate HAWQ Standby Master Wizard http://git-wip-us.apache.org/repos/asf/ambari/blob/2ad0be28/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/utils.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/utils.py b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/utils.py index 12d3511..55a5982 100644 --- a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/utils.py +++ b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/utils.py @@ -38,11 +38,12 @@ def create_dir_as_hawq_user(directory): Directory(directory, create_parents = True, owner=hawq_constants.hawq_user, group=hawq_constants.hawq_group) -def exec_hawq_operation(operation, option, not_if=None, only_if=None, logoutput=True): +def exec_hawq_operation(operation, option, not_if=None, only_if=None, logoutput=True, host_name=None): """ Sets up execution environment and runs a given command as HAWQ user """ - hawq_cmd = "source {0} && hawq {1} {2}".format(hawq_constants.hawq_greenplum_path_file, operation, option) + export_host = " && export PGHOST=\"{0}\"".format(host_name) if host_name is not None else "" + hawq_cmd = "source {0}{1} && hawq {2} {3}".format(hawq_constants.hawq_greenplum_path_file, export_host, operation, option) Execute( hawq_cmd, user=hawq_constants.hawq_user, http://git-wip-us.apache.org/repos/asf/ambari/blob/2ad0be28/ambari-server/src/test/python/stacks/2.3/HAWQ/test_hawqmaster.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.3/HAWQ/test_hawqmaster.py b/ambari-server/src/test/python/stacks/2.3/HAWQ/test_hawqmaster.py index aa63004..88fb008 100644 --- a/ambari-server/src/test/python/stacks/2.3/HAWQ/test_hawqmaster.py +++ b/ambari-server/src/test/python/stacks/2.3/HAWQ/test_hawqmaster.py @@ -32,7 +32,7 @@ class TestHawqMaster(RMFTestCase): POSTGRES = 'postgres' DEFAULT_IMMUTABLE_PATHS = ['/apps/hive/warehouse', '/apps/falcon', '/mr-history/done', '/app-logs', '/tmp'] CONFIG_FILE = os.path.join(os.path.dirname(__file__), '../configs/hawq_default.json') - HAWQ_CHECK_COMMAND = 'source /usr/local/hawq/greenplum_path.sh && hawq check -f /usr/local/hawq/etc/hawq_hosts --hadoop /usr/phd/current/hadoop-client --config /usr/local/hawq/etc/hawq_check.cnf ' + HAWQ_CHECK_COMMAND = 'source /usr/local/hawq/greenplum_path.sh && export PGHOST="c6403.ambari.apache.org" && hawq check -f /usr/local/hawq/etc/hawq_hosts --hadoop /usr/phd/current/hadoop-client --config /usr/local/hawq/etc/hawq_check.cnf ' def setUp(self): try: @@ -267,8 +267,11 @@ class TestHawqMaster(RMFTestCase): ) self.assertResourceCalled('Execute', expectedCommand, + logoutput = True, + not_if = None, + only_if = None, user=self.GPADMIN, - timeout=600 + timeout=900 ) self.assertNoMoreResources() @@ -393,7 +396,7 @@ class TestHawqMaster(RMFTestCase): target = RMFTestCase.TARGET_COMMON_SERVICES ) - self.assertResourceCalled('Execute', 'source /usr/local/hawq/greenplum_path.sh && hawq init standby -n -a -v -M fast', + self.assertResourceCalled('Execute', 'source /usr/local/hawq/greenplum_path.sh && export PGHOST="c6403.ambari.apache.org" && hawq init standby -n -a -v -M fast', user = self.GPADMIN, timeout = 900, not_if = None, @@ -415,7 +418,7 @@ class TestHawqMaster(RMFTestCase): target = RMFTestCase.TARGET_COMMON_SERVICES ) - self.assertResourceCalled('Execute', 'source /usr/local/hawq/greenplum_path.sh && hawq init standby -a -v -r --ignore-bad-hosts', + self.assertResourceCalled('Execute', 'source /usr/local/hawq/greenplum_path.sh && export PGHOST="c6403.ambari.apache.org" && hawq init standby -a -v -r --ignore-bad-hosts', user = self.GPADMIN, timeout = 900, not_if = None, http://git-wip-us.apache.org/repos/asf/ambari/blob/2ad0be28/ambari-server/src/test/python/stacks/2.3/HAWQ/test_hawqstandby.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.3/HAWQ/test_hawqstandby.py b/ambari-server/src/test/python/stacks/2.3/HAWQ/test_hawqstandby.py index 185bde8..b406723 100644 --- a/ambari-server/src/test/python/stacks/2.3/HAWQ/test_hawqstandby.py +++ b/ambari-server/src/test/python/stacks/2.3/HAWQ/test_hawqstandby.py @@ -216,7 +216,7 @@ class TestHawqStandby(RMFTestCase): mode = 0644 ) - self.assertResourceCalled('Execute', 'source /usr/local/hawq/greenplum_path.sh && hawq activate standby -a -M fast -v --ignore-bad-hosts', + self.assertResourceCalled('Execute', 'source /usr/local/hawq/greenplum_path.sh && export PGHOST=\"c6402.ambari.apache.org\" && hawq activate standby -a -M fast -v --ignore-bad-hosts', logoutput = True, not_if = None, only_if = None,
