Github user xunzhang commented on a diff in the pull request:

    https://github.com/apache/incubator-hawq/pull/828#discussion_r72935273
  
    --- Diff: src/test/feature/lib/hdfs_config.cpp ---
    @@ -0,0 +1,284 @@
    +#include <fstream>
    +#include <string>
    +#include <vector>
    +#include <unordered_set>
    +
    +#include "hdfs_config.h"
    +#include "command.h"
    +#include "psql.h"
    +#include "xml_parser.h"
    +#include "string_util.h"
    +
    +using std::string;
    +
    +namespace hawq {
    +namespace test {
    +
    +string HdfsConfig::getHdfsUser() {
    +  string cmd = "ps aux|grep hdfs.server|grep -v grep";
    +  Command c(cmd);
    +  string result = c.run().getResultOutput();
    +  auto lines = hawq::test::split(result, '\n');
    +  if (lines.size() >= 1) {
    +    return hawq::test::trim(hawq::test::split(lines[lines.size()-1], ' 
')[0]);
    +  } 
    +  return "hdfs";
    +}
    +
    +bool HdfsConfig::LoadFromHawqConfigFile() {
    +  const char *env = getenv("GPHOME");
    +  string confPath = env ? env : "";
    +  if (!confPath.empty()) {
    +    confPath.append("/etc/hdfs-client.xml");
    +  } else {
    +    return false;
    +  }
    +
    +  hawqxmlconf.reset(new XmlConfig(confPath));
    +  hawqxmlconf->parse();
    +  return true;
    +}
    +
    +bool HdfsConfig::LoadFromHdfsConfigFile() {
    +  string confPath=getHadoopHome();
    +  if (confPath == "")
    +    return false;
    +  confPath.append("/etc/hadoop/hdfs-site.xml");
    +  hdfsxmlconf.reset(new XmlConfig(confPath));
    +  hdfsxmlconf->parse();
    +  return true;
    +}
    +
    +bool HdfsConfig::isHA() {
    +  bool ret = LoadFromHawqConfigFile();
    +  if (!ret) {
    +    return false;
    +  }
    +  string nameservice = hawqxmlconf->getString("dfs.nameservices");
    +  if (nameservice.length() > 0) {
    +    return true;
    +  } else {
    +    return false;
    +  }
    +}
    +
    +bool HdfsConfig::isKerbos() {
    +  bool ret = LoadFromHawqConfigFile();
    +  if (!ret) {
    +    return false;
    +  }
    +  string authentication = 
hawqxmlconf->getString("hadoop.security.authentication");
    +  if (authentication == "kerberos") {
    +    return true;
    +  } else {
    +    return false;
    +  }
    +}
    +
    +bool HdfsConfig::isTruncate() {
    +  string cmd = "hadoop fs -truncate";
    +  Command c(cmd);
    +  string result = c.run().getResultOutput();
    +  auto lines = hawq::test::split(result, '\n');
    +  if (lines.size() >= 1) {
    +    string valueLine = lines[0];
    +    int find = valueLine.find("-truncate: Unknown command");
    +    if (find < 0)
    --- End diff --
    
    Unify your coding style with parentheses


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to