You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hawq.apache.org by iw...@apache.org on 2016/09/09 02:00:52 UTC
[2/3] incubator-hawq git commit: HAWQ-1037. Get HDFS namenode host
from HAWQ catalog tables instead of from HDFS configuration file
HAWQ-1037. Get HDFS namenode host from HAWQ catalog tables instead of from HDFS configuration file
Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/65b0e27c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/65b0e27c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/65b0e27c
Branch: refs/heads/master
Commit: 65b0e27c93dad8fce9e84fb0c8c1eb03e761cfdd
Parents: 4b202a2
Author: Chunling Wang <wa...@126.com>
Authored: Wed Sep 7 10:40:40 2016 +0800
Committer: ivan <iw...@pivotal.io>
Committed: Fri Sep 9 10:00:14 2016 +0800
----------------------------------------------------------------------
.../feature/ManagementTool/test_hawq_register.cpp | 16 +++-------------
src/test/feature/lib/hdfs_config.cpp | 14 ++++++++++++++
src/test/feature/lib/hdfs_config.h | 7 +++++++
3 files changed, 24 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/65b0e27c/src/test/feature/ManagementTool/test_hawq_register.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/ManagementTool/test_hawq_register.cpp b/src/test/feature/ManagementTool/test_hawq_register.cpp
index 2f4291b..385f959 100644
--- a/src/test/feature/ManagementTool/test_hawq_register.cpp
+++ b/src/test/feature/ManagementTool/test_hawq_register.cpp
@@ -19,19 +19,9 @@ class TestHawqRegister : public ::testing::Test {
~TestHawqRegister() {}
string getHdfsLocation() {
HdfsConfig hc;
- string hostname = "";
- int port = 0;
- if (hc.isHA()) {
- hc.getActiveNamenode(hostname, port);
- }
- else {
- std::vector<std::string> hostList;
- std::vector<int> portList;
- hc.getNamenodes(hostList, portList);
- hostname = hostList[0];
- port = portList[0];
- }
- return hawq::test::stringFormat("hdfs://%s:%d", hostname.c_str(), port);
+ string namenodehost = "";
+ EXPECT_EQ(true, hc.getNamenodeHost(namenodehost));
+ return hawq::test::stringFormat("hdfs://%s", namenodehost.c_str());
}
};
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/65b0e27c/src/test/feature/lib/hdfs_config.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/lib/hdfs_config.cpp b/src/test/feature/lib/hdfs_config.cpp
index cded21e..8a8ed81 100644
--- a/src/test/feature/lib/hdfs_config.cpp
+++ b/src/test/feature/lib/hdfs_config.cpp
@@ -172,6 +172,20 @@ string HdfsConfig::getHadoopHome() {
return hadoopHome;
}
+bool HdfsConfig::getNamenodeHost(string &namenodehost) {
+ const hawq::test::PSQLQueryResult &result = psql.getQueryResult(
+ "SELECT substring(fselocation from length('hdfs:// ') for (position('/' in substring(fselocation from length('hdfs:// ')))-1)::int) "
+ "FROM pg_filespace pgfs, pg_filespace_entry pgfse "
+ "WHERE pgfs.fsname = 'dfs_system' AND pgfse.fsefsoid=pgfs.oid ;");
+ std::vector<std::vector<string>> table = result.getRows();
+ if (table.size() > 0) {
+ namenodehost = table[0][0];
+ return true;
+ }
+
+ return false;
+}
+
bool HdfsConfig::getActiveNamenode(string &activenamenode,
int &port) {
return getHANamenode("active", activenamenode, port);
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/65b0e27c/src/test/feature/lib/hdfs_config.h
----------------------------------------------------------------------
diff --git a/src/test/feature/lib/hdfs_config.h b/src/test/feature/lib/hdfs_config.h
index 2b68db1..6b57588 100644
--- a/src/test/feature/lib/hdfs_config.h
+++ b/src/test/feature/lib/hdfs_config.h
@@ -56,6 +56,13 @@ class HdfsConfig {
std::string getHadoopHome();
/**
+ * get HDFS namenode's host ('hostname:port' for non-HA, 'servicename' for HA)
+ * @ param namenodehost, namenode host reference which will be set
+ * @ return true if getNamenodeHost succeeded
+ */
+ bool getNamenodeHost(std::string &namenodehost);
+
+ /**
* get HDFS active namenode's hostname and port information
* @param activenamenode, active namenode hostname reference which will be set
* @param port, active namenode port reference which will be set