Repository: incubator-hawq
Updated Branches:
  refs/heads/master df6c3992d -> a46166c2c


HAWQ-1021. Need to log for some local_ssh function calls.


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/a46166c2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/a46166c2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/a46166c2

Branch: refs/heads/master
Commit: a46166c2c665f10f9fd9acb01f4590d48f5b0d8b
Parents: df6c399
Author: Paul Guo <[email protected]>
Authored: Thu Aug 25 17:05:38 2016 +0800
Committer: rlei <[email protected]>
Committed: Mon Aug 29 10:31:46 2016 +0800

----------------------------------------------------------------------
 tools/bin/hawq         | 36 ++++++++++++++++++------------------
 tools/bin/hawq_ctl     |  2 +-
 tools/bin/hawqconfig   |  5 ++---
 tools/bin/hawqregister | 12 ++++++------
 4 files changed, 27 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a46166c2/tools/bin/hawq
----------------------------------------------------------------------
diff --git a/tools/bin/hawq b/tools/bin/hawq
index 0bebf1e..97079b8 100755
--- a/tools/bin/hawq
+++ b/tools/bin/hawq
@@ -35,7 +35,7 @@ def print_version():
     sys.exit(0)
 
 
-def local_ssh(cmd):
+def local_run(cmd):
     '''Execute shell command on local machine.'''
     result = subprocess.Popen(cmd, shell=True).wait()
     return result
@@ -115,69 +115,69 @@ def main():
             print START_HELP
             sys.exit(1)
         cmd = "%s; hawq_ctl %s %s" % (source_hawq_env, hawq_command, sub_args)
-        result = local_ssh(cmd)
+        result = local_run(cmd)
     elif hawq_command == "stop":
         if second_arg not in cluster_type_list:
             print STOP_HELP
             sys.exit(1)
         cmd = "%s; hawq_ctl %s %s" % (source_hawq_env, hawq_command, sub_args)
-        result = local_ssh(cmd)
+        result = local_run(cmd)
     elif hawq_command == "init":
         if second_arg not in cluster_init_list:
             print INIT_HELP
             sys.exit(1)
         cmd = "%s; hawq_ctl %s %s" % (source_hawq_env, hawq_command, sub_args)
-        result = local_ssh(cmd)
+        result = local_run(cmd)
     elif hawq_command == "restart":
         if second_arg not in cluster_type_list:
             print RESTART_HELP
             sys.exit(1)
         cmd = "%s; hawq_ctl stop %s" % (source_hawq_env, sub_args)
-        check_return_code(local_ssh(cmd))
+        check_return_code(local_run(cmd))
         cmd = "%s; hawq_ctl start %s" % (source_hawq_env, sub_args)
-        result = local_ssh(cmd)
+        result = local_run(cmd)
     elif hawq_command == "activate":
         if second_arg in ['', 'help', '--help']:
             print ACTIVE_HELP
             sys.exit(1)
         cmd = "%s; hawq_ctl %s %s" % (source_hawq_env, hawq_command, sub_args)
-        result = local_ssh(cmd)
+        result = local_run(cmd)
     elif hawq_command == "config":
         if second_arg in ['', 'help', '--help']:
             print CONFIG_HELP
             sys.exit(1)
         cmd = "%s; hawqconfig %s" % (source_hawq_env, sub_args)
-        result = local_ssh(cmd)
+        result = local_run(cmd)
     elif hawq_command == "extract":
         cmd = "%s; hawqextract %s" % (source_hawq_env, sub_args)
-        result = local_ssh(cmd)
+        result = local_run(cmd)
     elif hawq_command == "check":
         cmd = "%s; gpcheck %s" % (source_hawq_env, sub_args)
-        result = local_ssh(cmd)
+        result = local_run(cmd)
     elif hawq_command == "checkperf":
         cmd = "%s; gpcheckperf %s" % (source_hawq_env, sub_args)
-        result = local_ssh(cmd)
+        result = local_run(cmd)
     elif hawq_command == "load":
         cmd = "%s; gpload %s" % (source_hawq_env, sub_args)
-        result = local_ssh(cmd)
+        result = local_run(cmd)
     elif hawq_command == "filespace":
         cmd = "%s; hawqfilespace %s" % (source_hawq_env, sub_args)
-        result = local_ssh(cmd)
+        result = local_run(cmd)
     elif hawq_command == "state":
         cmd = "%s; hawqstate %s" % (source_hawq_env, sub_args)
-        result = local_ssh(cmd)
+        result = local_run(cmd)
     elif hawq_command == "ssh":
         cmd = "%s; gpssh %s" % (source_hawq_env, sub_args)
-        result = local_ssh(cmd)
+        result = local_run(cmd)
     elif hawq_command == "ssh-exkeys":
         cmd = "%s; gpssh-exkeys %s" % (source_hawq_env, sub_args)
-        result = local_ssh(cmd)
+        result = local_run(cmd)
     elif hawq_command == "scp":
         cmd = "%s; gpscp %s" % (source_hawq_env, sub_args)
-        result = local_ssh(cmd)
+        result = local_run(cmd)
     elif hawq_command == "register":
         cmd = "%s; hawqregister %s" % (source_hawq_env, sub_args)
-        result = local_ssh(cmd)
+        result = local_run(cmd)
     elif hawq_command == "version" or hawq_command == "--version":
         print_version()
     else:

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a46166c2/tools/bin/hawq_ctl
----------------------------------------------------------------------
diff --git a/tools/bin/hawq_ctl b/tools/bin/hawq_ctl
index 211f599..bcfadc7 100755
--- a/tools/bin/hawq_ctl
+++ b/tools/bin/hawq_ctl
@@ -435,7 +435,7 @@ class HawqInit:
         for host in self.host_list:
             logger.debug("Start to init segment on node '%s'" % host)
             scpcmd = "scp %s/etc/_mgmt_config %s:%s/etc/_mgmt_config > 
/dev/null" % (self.GPHOME, host, self.GPHOME)
-            local_ssh(scpcmd)
+            local_ssh(scpcmd, logger)
             work_list.append({"func":remote_ssh,"args":(segment_cmd_str, host, 
self.user, q)})
         logger.info("Total segment number is: %s" % len(self.host_list))
         work_list.append({"func":check_progress,"args":(q, 
self.hosts_count_number, 'init', 0, self.quiet)})

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a46166c2/tools/bin/hawqconfig
----------------------------------------------------------------------
diff --git a/tools/bin/hawqconfig b/tools/bin/hawqconfig
index d2bc63d..5427a1b 100755
--- a/tools/bin/hawqconfig
+++ b/tools/bin/hawqconfig
@@ -27,6 +27,7 @@ except ImportError, e:
     sys.exit('ERROR: Cannot import modules.  Please check that you '
                  'have sourced greenplum_path.sh.  Detail: ' + str(e))
 
+logger, log_filename = 
setup_hawq_tool_logging('hawq_config',getLocalHostname(),getUserName())
 
 def parseargs():
     parser = OptionParser(usage="HAWQ config options.")
@@ -50,8 +51,6 @@ def parseargs():
     if options.quiet:
         quiet_stdout_logging()
 
-    logger, log_filename = 
setup_hawq_tool_logging('hawq_config',getLocalHostname(),getUserName())
-
     if options.change and options.remove:
         logger.error("Multiple actions specified.  See the --help info.")
         parser.exit()
@@ -174,7 +173,7 @@ def sync_hawq_site(config_dir, host_list, ignore_bad_hosts):
     sync_host_str = ""
     for node in host_list:
         sync_host_str += " -h %s" % node
-    result = local_ssh("hawq scp %s %s %s/etc/hawq-site.xml =:%s/etc/" % 
(sync_host_str, ignore_bad_hosts, config_dir, config_dir))
+    result = local_ssh("hawq scp %s %s %s/etc/hawq-site.xml =:%s/etc/" % 
(sync_host_str, ignore_bad_hosts, config_dir, config_dir), logger)
     if result != 0:
         sys.exit("sync hawq-site.xml failed.")
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a46166c2/tools/bin/hawqregister
----------------------------------------------------------------------
diff --git a/tools/bin/hawqregister b/tools/bin/hawqregister
index 96b932d..10bdf0b 100755
--- a/tools/bin/hawqregister
+++ b/tools/bin/hawqregister
@@ -258,7 +258,7 @@ def get_files_in_hdfs(filepath):
     files = []
     sizes = []
     hdfscmd = "hadoop fs -test -e %s" % filepath
-    result = local_ssh(hdfscmd)
+    result = local_ssh(hdfscmd, logger)
     if result != 0:
         logger.error("Path '%s' does not exist in hdfs" % filepath)
         sys.exit(1)
@@ -285,9 +285,9 @@ def check_parquet_format(files):
         if out == '0':
             continue
         hdfscmd = 'hadoop fs -cat %s | head -c 4 | grep PAR1' % f
-        result1 = local_ssh(hdfscmd)
+        result1 = local_ssh(hdfscmd, logger)
         hdfscmd = 'hadoop fs -cat %s | tail -c 4 | grep PAR1' % f
-        result2 = local_ssh(hdfscmd)
+        result2 = local_ssh(hdfscmd, logger)
         if result1 or result2:
             logger.error('File %s is not parquet format' % f)
             sys.exit(1)
@@ -304,7 +304,7 @@ def move_files_in_hdfs(databasename, tablename, files, 
firstsegno, tabledir, nor
             if srcfile != dstfile:
                 hdfscmd = 'hadoop fs -mv %s %s' % (srcfile, dstfile)
                 sys.stdout.write('hdfscmd: "%s"\n' % hdfscmd)
-                result = local_ssh(hdfscmd)
+                result = local_ssh(hdfscmd, logger)
                 if result != 0:
                     logger.error('Fail to move %s to %s' % (srcfile, dstfile))
                     sys.exit(1)
@@ -317,7 +317,7 @@ def move_files_in_hdfs(databasename, tablename, files, 
firstsegno, tabledir, nor
             if srcfile != dstfile:
                 hdfscmd = 'hadoop fs -mv %s %s' % (srcfile, dstfile)
                 sys.stdout.write('hdfscmd: "%s"\n' % hdfscmd)
-                result = local_ssh(hdfscmd)
+                result = local_ssh(hdfscmd, logger)
                 if result != 0:
                     logger.error('Fail to move "%s" to "%s"' % (srcfile, 
dstfile))
                     sys.exit(1)
@@ -347,7 +347,7 @@ if __name__ == '__main__':
     if len(args) != 1 or (options.yml_config and options.filepath):
         parser.print_help(sys.stderr)
         sys.exit(1)
-    if local_ssh('hadoop'):
+    if local_ssh('hadoop', logger):
         logger.error('command "hadoop" is not available.')
         sys.exit(1)
 

Reply via email to