ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lavj...@apache.org
Subject ambari git commit: AMBARI-17937:Ambari install/init should create a new gpadmin database (lavjain)
Date Wed, 03 Aug 2016 20:48:17 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 773b128b8 -> 8138a9dbe


AMBARI-17937:Ambari install/init should create a new gpadmin database (lavjain)


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

Branch: refs/heads/branch-2.4
Commit: 8138a9dbee872e1a5309fa929a678fb7ff806b98
Parents: 773b128
Author: ljainpivotalio <ljain@pivotal.io>
Authored: Wed Aug 3 13:48:07 2016 -0700
Committer: ljainpivotalio <ljain@pivotal.io>
Committed: Wed Aug 3 13:48:07 2016 -0700

----------------------------------------------------------------------
 .../HAWQ/2.0.0/package/scripts/common.py              | 14 ++++++++------
 .../HAWQ/2.0.0/package/scripts/utils.py               |  5 +++--
 2 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8138a9db/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/common.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/common.py
b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/common.py
index 8c43555..298513c 100644
--- a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/common.py
+++ b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/common.py
@@ -31,7 +31,6 @@ import xml.etree.ElementTree as ET
 import utils
 import hawq_constants
 import custom_params
-import hawqstatus
 
 def setup_user():
   """
@@ -291,15 +290,18 @@ def start_component(component_name, port, data_dir):
                         mode=0755)
     params.HdfsResource(None, action="execute")
 
+  options_str = "{0} -a -v".format(component_name)
   if os.path.exists(os.path.join(data_dir, hawq_constants.postmaster_opts_filename)):
-    return utils.exec_hawq_operation(hawq_constants.START,
-                                     "{0} -a -v".format(component_name),
+    return utils.exec_hawq_operation(hawq_constants.START, options_str,
                                      not_if=utils.generate_hawq_process_status_cmd(component_name,
port))
 
-  options_str = "{0} -a -v".format(component_name)
+  # Initialize HAWQ
   if component_name == hawq_constants.MASTER:
-    options_str+=" --ignore-bad-hosts"
-  utils.exec_hawq_operation(hawq_constants.INIT, options_str)
+    utils.exec_hawq_operation(hawq_constants.INIT, options_str + " --ignore-bad-hosts")
+    utils.exec_psql_cmd('create database {0};'.format(hawq_constants.hawq_user),
+                        params.hawqmaster_host, params.hawq_master_address_port, ignore_error=True)
+  else:
+    utils.exec_hawq_operation(hawq_constants.INIT, options_str)
 
 def stop_component(component_name, mode):
   """

http://git-wip-us.apache.org/repos/asf/ambari/blob/8138a9db/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 55a5982..95c3dcc 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
@@ -88,7 +88,7 @@ def exec_ssh_cmd(hostname, cmd):
   return process.returncode, stdout, stderr
 
 
-def exec_psql_cmd(command, host, port, db=hawq_constants.POSTGRES, tuples_only=True):
+def exec_psql_cmd(command, host, port, db=hawq_constants.POSTGRES, tuples_only=True, ignore_error=False):
   """
   Sets up execution environment and runs the HAWQ queries
   """
@@ -100,7 +100,8 @@ def exec_psql_cmd(command, host, port, db=hawq_constants.POSTGRES, tuples_only=T
   retcode, out, err = exec_ssh_cmd(host, cmd)
   if retcode:
     Logger.error("SQL command executed failed: {0}\nReturncode: {1}\nStdout: {2}\nStderr:
{3}".format(cmd, retcode, out, err))
-    raise Fail("SQL command executed failed.")
+    if not ignore_error:
+      raise Fail("SQL command executed failed.")
 
   Logger.info("Output:\n{0}".format(out))
   return retcode, out, err


Mime
View raw message