hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject incubator-hawq git commit: HAWQ-20. Fix master data directory and port for analyzedb
Date Fri, 15 Apr 2016 06:28:46 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master c1e6c4388 -> 5ce4130b4


HAWQ-20. Fix master data directory and port for analyzedb


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

Branch: refs/heads/master
Commit: 5ce4130b4042f9da12eab1bd24accb2332ccea97
Parents: c1e6c43
Author: rlei <rlei@pivotal.io>
Authored: Fri Apr 15 14:00:39 2016 +0800
Committer: rlei <rlei@pivotal.io>
Committed: Fri Apr 15 14:24:45 2016 +0800

----------------------------------------------------------------------
 tools/bin/analyzedb              | 25 ++++++-------------------
 tools/bin/gppylib/commands/gp.py | 23 +++++++++++++++++++----
 2 files changed, 25 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/5ce4130b/tools/bin/analyzedb
----------------------------------------------------------------------
diff --git a/tools/bin/analyzedb b/tools/bin/analyzedb
index 352a560..d822894 100755
--- a/tools/bin/analyzedb
+++ b/tools/bin/analyzedb
@@ -47,10 +47,9 @@ try:
 except ImportError, e:
     sys.exit('Cannot import modules.  Please check that you have sourced greenplum_path.sh.
 Detail: ' + str(e))
 
-
 EXECNAME = 'analyzedb'
-ANALYZE_SQL = """psql %s -c 'analyze %s'"""
-ANALYZE_ROOT_SQL = """psql %s -c 'analyze rootpartition %s'"""
+ANALYZE_SQL = """psql %s -p %s -c 'analyze %s'"""
+ANALYZE_ROOT_SQL = """psql %s -p %s -c 'analyze rootpartition %s'"""
 STATEFILE_DIR = 'db_analyze'
 logger = gplog.get_default_logger()
 CURR_TIME = None
@@ -64,8 +63,7 @@ LEFT JOIN pg_class cl3 ON pr2.parchildrelid = cl3.oid
 WHERE pp.paristemplate = false AND pp.parrelid = cl.oid AND pr1.paroid = pp.oid AND cl2.oid
= pr1.parchildrelid AND cl.relnamespace = n.oid AND cl2.relnamespace = n2.oid
 """
 
-GET_ALL_DATA_TABLES_SQL = """
-select n.nspname as schemaname, c.relname as tablename from pg_class c, pg_namespace n where
+GET_ALL_DATA_TABLES_SQL = """ select n.nspname as schemaname, c.relname as tablename from
pg_class c, pg_namespace n where
 c.relnamespace = n.oid and c.relkind='r'::char and (c.relnamespace > 16384 or n.nspname
= 'public' or n.nspname = 'pg_catalog') and c.oid not in (select reloid from pg_exttable)
 EXCEPT
 select distinct schemaname, tablename from (%s) AS pps1
@@ -170,7 +168,7 @@ class AnalyzeDb(Operation):
             options.masterDataDirectory = gp.get_masterdatadir()
         self.master_datadir = options.masterDataDirectory
         self.analyze_dir = STATEFILE_DIR
-        self.pg_port = self._get_pgport()
+        self.pg_port = gp.get_master_port()
         self.dbname = options.dbname
         self.schema = options.schema
         self.single_table = options.single_table
@@ -355,10 +353,10 @@ class AnalyzeDb(Operation):
             for can in ordered_candidates:
                 if can in candidates:
                     target = self._get_tablename_with_cols(can, input_col_dict)
-                    cmd = Command('analyze %s' % target, ANALYZE_SQL % (self.dbname, quote_tbl(target)))
+                    cmd = Command('analyze %s' % target, ANALYZE_SQL % (self.dbname, self.pg_port,
quote_tbl(target)))
                 else: # can in root_partition_col_dict
                     target = self._get_tablename_with_cols(can, root_partition_col_dict)
-                    cmd = Command('analyze rootpartition %s' % target, ANALYZE_ROOT_SQL %
(self.dbname, quote_tbl(target)))
+                    cmd = Command('analyze rootpartition %s' % target, ANALYZE_ROOT_SQL %
(self.dbname, self.pg_port, quote_tbl(target)))
                 pool.addCommand(cmd)
 
             wait_count = len(ordered_candidates)
@@ -399,17 +397,6 @@ class AnalyzeDb(Operation):
 
         return 0
 
-    def _get_pgport(self):
-        env_pgport = os.getenv('PGPORT')
-        if not env_pgport:
-            return self._get_master_port(self.master_datadir)
-        return env_pgport
-
-    def _get_master_port(self, datadir):
-        logger.debug("Obtaining master's port from master data directory")
-        pgconf_dict = pgconf.readfile(datadir + "/postgresql.conf")
-        return pgconf_dict.int('port')
-
     def _get_input_tables(self, col_dict):
         """
         Depending on the way this program was invoked, gather all the requested tables to
be analyzed.

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/5ce4130b/tools/bin/gppylib/commands/gp.py
----------------------------------------------------------------------
diff --git a/tools/bin/gppylib/commands/gp.py b/tools/bin/gppylib/commands/gp.py
index e2a5a9a..66124cf 100644
--- a/tools/bin/gppylib/commands/gp.py
+++ b/tools/bin/gppylib/commands/gp.py
@@ -30,6 +30,7 @@ from unix import *
 import pg
 from gppylib import pgconf
 from gppylib.utils import writeLinesToFile, createFromSingleHostFile
+from hawqpylib.hawqlib import HawqXMLParser
 
 
 logger = get_default_logger()
@@ -978,13 +979,27 @@ def get_gphome():
 
 ######
 def get_masterdatadir():
-    logger.debug("Checking if MASTER_DATA_DIRECTORY env variable is set.")
-    master_datadir = os.environ.get('MASTER_DATA_DIRECTORY')
-    if master_datadir is None:
-        raise GpError("Environment Variable MASTER_DATA_DIRECTORY not set!")
+    logger.debug("Checking if GPHOME env variable is set.")
+    HAWQ_CONFIG_DIR = os.environ.get('GPHOME')
+    if HAWQ_CONFIG_DIR is None:
+        raise GpError("Environment Variable GPHOME not set!")
+    hawq_site = HawqXMLParser(HAWQ_CONFIG_DIR)
+    master_datadir = hawq_site.get_value_from_name('hawq_master_directory').strip()
+
     return master_datadir
 
 ######
+def get_master_port():
+    logger.debug("Checking if GPHOME env variable is set.")
+    HAWQ_CONFIG_DIR = os.environ.get('GPHOME')
+    if HAWQ_CONFIG_DIR is None:
+        raise GpError("Environment Variable GPHOME not set!")
+    hawq_site = HawqXMLParser(HAWQ_CONFIG_DIR)
+    master_port = hawq_site.get_value_from_name('hawq_master_address_port').strip()
+
+    return master_port
+
+######
 def get_masterport(datadir):
     return pgconf.readfile(os.path.join(datadir, 'postgresql.conf')).int('port')
 


Mime
View raw message