hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cjcjame...@apache.org
Subject [1/3] incubator-hawq git commit: HAWQ-567. Add HAWQ commands option conflict checks
Date Tue, 22 Mar 2016 18:21:10 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/HAWQ-537 203b2e093 -> f0f61de11


HAWQ-567. Add HAWQ commands option conflict checks


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

Branch: refs/heads/HAWQ-537
Commit: d8d0d96ddc7d5f2fb88c926c3af0b0a489bb8c4d
Parents: 203b2e0
Author: rlei <rlei@pivotal.io>
Authored: Fri Mar 18 15:52:07 2016 +0800
Committer: rlei <rlei@pivotal.io>
Committed: Tue Mar 22 10:23:24 2016 +0800

----------------------------------------------------------------------
 tools/bin/hawq_ctl   |  19 ++++---
 tools/bin/hawqconfig | 141 +++++++++++++++++++++++++++++-----------------
 tools/bin/hawqstate  |   7 +++
 3 files changed, 106 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d8d0d96d/tools/bin/hawq_ctl
----------------------------------------------------------------------
diff --git a/tools/bin/hawq_ctl b/tools/bin/hawq_ctl
index d94a4c2..49a9ff4 100755
--- a/tools/bin/hawq_ctl
+++ b/tools/bin/hawq_ctl
@@ -939,6 +939,14 @@ def get_args():
     if args_lens != 2:
         sys.exit('Only support two arguements.')
     
+    if opts.verbose and opts.quiet_run:
+        logger.error("Multiple actions specified.  See the --help info.")
+        sys.exit(1)
+
+    if opts.special_mode and (opts.node_type != 'start'):
+        logger.error("['-U', '--special-mode'] only apply to 'hawq start'.  See the --help
info.")
+        sys.exit(1)
+
     opts.GPHOME = os.getenv('GPHOME')
     if not opts.GPHOME:
         logger.error("Didn't get GPHOME value, exit")
@@ -1165,21 +1173,13 @@ def create_parser():
                       action="store_true",
                       dest="quiet_run",
                       help="Execute in quiet mode")
-    parser.add_option("-y", "--nostandby",
-                      action="store_false",
-                      dest="nostandby",
-                      help="Exclude standby master")
     parser.add_option("-l", "--logdir",
                       dest="log_dir",
                       help="Sets the directory for log files")
     parser.add_option("-t", "--timeout",
                       dest="timeout_seconds",
                       default="600",
-                      help="Set the timeout seconds, default is 60")
-    parser.add_option("-B", "--parallel",
-                      dest="parallel_processses",
-                      default="60",
-                      help="Sets the max parallel processes")
+                      help="Set the timeout seconds, default is 600")
     parser.add_option("--user",
                       dest="user",
                       default="",
@@ -1262,6 +1262,7 @@ def create_parser():
     if len(args) == 0:
         parser.print_help()
         sys.exit(1)
+
     return (options, args)
 
 if __name__ == '__main__':

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d8d0d96d/tools/bin/hawqconfig
----------------------------------------------------------------------
diff --git a/tools/bin/hawqconfig b/tools/bin/hawqconfig
index 2bf0db0..fda8782 100755
--- a/tools/bin/hawqconfig
+++ b/tools/bin/hawqconfig
@@ -15,12 +15,18 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+try:
+    import os, sys, re
+    from optparse import Option, OptionParser
+    from hawqpylib.hawqlib import HawqXMLParser, parse_hosts_file, remove_property_xml, local_ssh
+    from gppylib.commands.unix import getLocalHostname, getUserName
+    from gppylib.db import dbconn
+    from pg import DatabaseError
+    from gppylib.gplog import setup_hawq_tool_logging, quiet_stdout_logging, enable_verbose_logging
+except ImportError, e:
+    sys.exit('ERROR: Cannot import modules.  Please check that you '
+                 'have sourced greenplum_path.sh.  Detail: ' + str(e))
 
-import os, sys, re
-from optparse import Option, OptionParser
-from hawqpylib.hawqlib import HawqXMLParser, parse_hosts_file, remove_property_xml, local_ssh
-from gppylib.db import dbconn
-from pg import DatabaseError
 
 def parseargs():
     parser = OptionParser(usage="HAWQ config options.")
@@ -41,6 +47,36 @@ def parseargs():
                       dest="hawq_home",
                       help="HAWQ home directory.")
     (options, args) = parser.parse_args()
+
+    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()
+
+    if options.change and not options.property_value:
+        logger.error("change requested but value not specified")
+        parser.exit()
+
+    if options.show and options.list:
+        logger.error("Multiple actions specified.  See the --help info.")
+        parser.exit()
+
+    if options.show and (options.change or options.remove):
+        logger.error("Multiple actions specified.  See the --help info.")
+        parser.exit()
+
+    if options.list and (options.change or options.remove):
+        logger.error("Multiple actions specified.  See the --help info.")
+        parser.exit()
+
+    if (options.show or options.list) and options.skipvalidation:
+        logger.error("--skipvalidation can not be combined with --show/--list.")
+        parser.exit()
+
     return (options, args)
 
 
@@ -199,55 +235,56 @@ def sync_hawq_site(config_dir, host_list):
     if result != 0:
         sys.exit("sync hawq-site.xml failed.")
 
-options, args = parseargs()
-
-if options.hawq_home is None:
-    GPHOME = os.getenv('GPHOME')
-else:
-    GPHOME = options.hawq_home
-hawq_site = HawqXMLParser(GPHOME)
-hawq_site.get_all_values()
-org_config_file = "%s/etc/hawq-site.xml" % GPHOME
-segment_list = parse_hosts_file(GPHOME)
-master_host = hawq_site.hawq_dict['hawq_master_address_host']
-host_list = segment_list + [master_host]
-if 'hawq_standby_address_host' in hawq_site.hawq_dict:
-    standby_host = hawq_site.hawq_dict['hawq_standby_address_host']
-    if standby_host not in ('None', 'none', ''):
-        host_list = host_list + [standby_host]
-else:
-    print "No standby host configured, skip it."
-
-# Update hawq-site.xml
-if options.change:
-    if not options.property_value:
-        print "Please specify GUC value"
-        sys.exit(1)
-    if not options.skipvalidation:
-        check_property_valid(hawq_site, options.change)
+if __name__ == '__main__':
+    options, args = parseargs()
 
-    update_hawq_site(org_config_file, hawq_site, options.change, options.property_value)
-    sync_hawq_site(GPHOME, host_list)
+    if options.hawq_home is None:
+        GPHOME = os.getenv('GPHOME')
+    else:
+        GPHOME = options.hawq_home
+    hawq_site = HawqXMLParser(GPHOME)
+    hawq_site.get_all_values()
+    org_config_file = "%s/etc/hawq-site.xml" % GPHOME
+    segment_list = parse_hosts_file(GPHOME)
+    master_host = hawq_site.hawq_dict['hawq_master_address_host']
+    host_list = segment_list + [master_host]
+    if 'hawq_standby_address_host' in hawq_site.hawq_dict:
+        standby_host = hawq_site.hawq_dict['hawq_standby_address_host']
+        if standby_host not in ('None', 'none', ''):
+            host_list = host_list + [standby_host]
+    else:
+        print "No standby host configured, skip it."
+
+    # Update hawq-site.xml
+    if options.change:
+        if not options.property_value:
+            print "Please specify GUC value"
+            sys.exit(1)
+        if not options.skipvalidation:
+            check_property_valid(hawq_site, options.change)
+
+        update_hawq_site(org_config_file, hawq_site, options.change, options.property_value)
+        sync_hawq_site(GPHOME, host_list)
 
-    if not options.quiet:
+        if not options.quiet:
+            latest_hawq_site = HawqXMLParser(GPHOME)
+            latest_hawq_site.get_all_values()
+            show_property(latest_hawq_site, options.change)
+    elif options.show:
         latest_hawq_site = HawqXMLParser(GPHOME)
         latest_hawq_site.get_all_values()
-        show_property(latest_hawq_site, options.change)
-elif options.show:
-    latest_hawq_site = HawqXMLParser(GPHOME)
-    latest_hawq_site.get_all_values()
-    show_guc(latest_hawq_site, options.show)
-elif options.list:
-    latest_hawq_site = HawqXMLParser(GPHOME)
-    latest_hawq_site.get_all_values()
-    list_properties(latest_hawq_site)
-elif options.remove:
-    except_list = ['hawq_master_address_host', 'hawq_master_directory', 'hawq_segment_directory']
-    if options.remove in except_list:
-        print "Remove %s is not allowed" % options.remove
+        show_guc(latest_hawq_site, options.show)
+    elif options.list:
+        latest_hawq_site = HawqXMLParser(GPHOME)
+        latest_hawq_site.get_all_values()
+        list_properties(latest_hawq_site)
+    elif options.remove:
+        except_list = ['hawq_master_address_host', 'hawq_master_directory', 'hawq_segment_directory']
+        if options.remove in except_list:
+            print "Remove %s is not allowed" % options.remove
+            sys.exit(1)
+        remove_property_xml(options.remove, org_config_file)
+        sync_hawq_site(GPHOME, host_list)
+    else:
+        print "Please input correct options"
         sys.exit(1)
-    remove_property_xml(options.remove, org_config_file)
-    sync_hawq_site(GPHOME, host_list)
-else:
-    print "Please input correct options"
-    sys.exit(1)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d8d0d96d/tools/bin/hawqstate
----------------------------------------------------------------------
diff --git a/tools/bin/hawqstate b/tools/bin/hawqstate
index abf7782..5ff4105 100755
--- a/tools/bin/hawqstate
+++ b/tools/bin/hawqstate
@@ -120,16 +120,23 @@ def show_brief_status(hawq_site, segment_list, standby_host):
 
 if __name__ == '__main__':
     options, args = parseargs()
+
+    if options.verbose and options.quiet:
+        print "Multiple actions specified.  See the --help info."
+        sys.exit(1)
+
     if options.verbose:
         enable_verbose_logging()
     if options.quiet:
         quiet_stdout_logging()
 
     logger, log_filename = setup_hawq_tool_logging('hawq_state',getLocalHostname(),getUserName(),
options.logDir) 
+
     if options.hawq_home is None:
         GPHOME = os.getenv('GPHOME')
     else:
         GPHOME = options.hawq_home
+
     hawq_site = HawqXMLParser(GPHOME)
     hawq_site.get_all_values()
     segment_list = parse_hosts_file(GPHOME)


Mime
View raw message