Repository: incubator-hawq
Updated Branches:
  refs/heads/master fd9c36861 -> 9078784a5


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/9078784a/src/test/feature/lib/hawq-config.h
----------------------------------------------------------------------
diff --git a/src/test/feature/lib/hawq-config.h 
b/src/test/feature/lib/hawq-config.h
index a32cc0c..e1135f8 100644
--- a/src/test/feature/lib/hawq-config.h
+++ b/src/test/feature/lib/hawq-config.h
@@ -2,41 +2,112 @@
 #define SRC_TEST_FEATURE_LIB_HAWQ_CONFIG_H_
 
 #include "psql.h"
+#include "sql-util.h"
 #include "xml-parser.h"
 
+/**
+ *  HawqConfig common library. Get detailed infomation about HAWQ cluster
+ *  including checking state of master and slaves, setting GUC and checking 
standby.
+ *  @author hubert zhang
+ */
 class HawqConfig {
   public:
-    HawqConfig(const std::string& user = "gpadmin",
-        const std::string& password = "", const std::string& db = "postgres",
-        const std::string& host = "localhost", const std::string& port = 
"5432") :
-        psql(db, host, port, user, password) {
-      std::string masterHostname = "";
-      int masterPort = 0;
-      bool ret = getMaster(masterHostname, masterPort);
-      if (ret) {
-        std::string masterPortStr = std::to_string(masterPort);
-        psql.setHost(masterHostname);
-        psql.setPort(masterPortStr);
-      }
+    /**
+     * HawqConfig constructor
+     */
+    HawqConfig(): psql(HAWQ_DB, HAWQ_HOST, HAWQ_PORT, HAWQ_USER, 
HAWQ_PASSWORD) {
     }
+
+    /**
+     * HawqConfig destructor
+     */
     ~HawqConfig() {
     }
 
-    bool LoadFromConfigFile();
+    /**
+     * get hawq master's hostname and port information
+     * @param hostname master hostname reference which will be set
+     * @param port master port number reference which will be set
+     * @return true if getMaster succeeded
+     */
     bool getMaster(std::string &hostname, int &port);
+
+
+    /**
+     * get hawq standby master's hostname and port information
+     * @param hostname master hostname reference which will be set
+     * @param port master port number reference which will be set
+     * @return true if hawq getStandbyMaster succeeded
+     */
     void getStandbyMaster(std::string &hostname, int &port);
+
+
+    /**
+     * get the list of all of the hawq segments
+     * @param hostname hostname list of all of the hawq segments
+     * @param port port list of all of the hawq segments
+     */
     void getTotalSegments(std::vector<std::string> &hostname,
         std::vector<int> &port);
+
+    /**
+     * get list of hostnames in slave file
+     * @param hostname list of hostnames in slave file.
+     */
     void getSlaves(std::vector<std::string> &hostname);
+
+    /**
+     * get hawq segment list whose state is up(not down).
+     * @param hostname hostname list of all of the up segments
+     * @param port port list of all of the up segments
+     * @see getDownSegments
+     */
     void getUpSegments(std::vector<std::string> &hostname,
         std::vector<int> &port);
+
+    /**
+     * get hawq segment list whose state is down.
+     * @param hostname hostname list of all of the down segments
+     * @param port port list of all of the down segments
+     */
     void getDownSegments(std::vector<std::string> &hostname,
         std::vector<int> &port);
+
+    /**
+     * get the guc value by name
+     * @param gucName the guc name to be retrived
+     * @return guc value
+     */
     std::string getGucValue(std::string gucName);
+
+    /**
+     * set guc value by hawq config
+     * @param gucName guc name to be set
+     * @param gucValue the value to be set
+     * @return hawq config return information
+     */
     std::string setGucValue(std::string gucName, std::string gucValue);
+
+    /**
+     * whether hawq master and mirror is synchronized by checking 
gp_master_mirroring.
+     * @return true if Synchronized
+     */
     bool isMasterMirrorSynchronized();
+
+    /**
+     * whether hawq is in multi-node mode.
+     * @return true if hawq is multi-node
+     */
     bool isMultinodeMode();
+
   private:
+    /**
+     * load key-value parameters in hawq-site.xml
+     * @return true if succeeded
+     */
+    bool LoadFromConfigFile();
+
+
     std::unique_ptr<XmlConfig> xmlconf;
     PSQL psql;
 };

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/9078784a/src/test/feature/testlib/test-lib.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/testlib/test-lib.cpp 
b/src/test/feature/testlib/test-lib.cpp
index 4959f4a..97556d8 100644
--- a/src/test/feature/testlib/test-lib.cpp
+++ b/src/test/feature/testlib/test-lib.cpp
@@ -23,12 +23,8 @@ class TestCommonLib : public ::testing::Test {
 TEST_F(TestCommonLib, TestHawqConfig) {
   std::string hostname = "";
   int port = 0;
-  struct passwd *pw;
-  uid_t uid;
-  uid = geteuid();
-  pw = getpwuid(uid);
-  std::string uname(pw->pw_name);
-  HawqConfig hc(uname);
+
+  HawqConfig hc;
   hc.getMaster(hostname, port);
 
   hostname = "";

Reply via email to