You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ec...@apache.org on 2016/07/11 23:48:24 UTC

[31/50] [abbrv] hbase git commit: HBASE-15821 Document TestUtil

HBASE-15821 Document TestUtil


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/8014cdfe
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/8014cdfe
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/8014cdfe

Branch: refs/heads/HBASE-14850
Commit: 8014cdfe9d716eae92a91a7f376c002c05446ff9
Parents: dea1eb6
Author: Elliott Clark <ec...@apache.org>
Authored: Fri May 13 09:17:49 2016 -0700
Committer: Elliott Clark <ec...@apache.org>
Committed: Mon Jul 11 16:47:26 2016 -0700

----------------------------------------------------------------------
 hbase-native-client/bin/format-code.sh          |  2 +-
 .../connection/connection-pool.h                |  4 ++--
 hbase-native-client/core/location-cache.cc      |  2 +-
 hbase-native-client/core/location-cache.h       |  2 +-
 hbase-native-client/test-util/test-util.cc      | 20 +++++++++++++-------
 hbase-native-client/test-util/test-util.h       | 20 +++++++++++++++-----
 6 files changed, 33 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/8014cdfe/hbase-native-client/bin/format-code.sh
----------------------------------------------------------------------
diff --git a/hbase-native-client/bin/format-code.sh b/hbase-native-client/bin/format-code.sh
index 36a114d..cc8b368 100755
--- a/hbase-native-client/bin/format-code.sh
+++ b/hbase-native-client/bin/format-code.sh
@@ -19,5 +19,5 @@ set -euo pipefail
 IFS=$'\n\t'
 
 
-find core connection serde utils -name "*.h" -or -name "*.cc" | xargs -P8 clang-format -i
+find core connection serde utils test-util -name "*.h" -or -name "*.cc" | xargs -P8 clang-format -i
 find core connection serde utils third-party -name "BUCK" | xargs -P8 yapf -i

http://git-wip-us.apache.org/repos/asf/hbase/blob/8014cdfe/hbase-native-client/connection/connection-pool.h
----------------------------------------------------------------------
diff --git a/hbase-native-client/connection/connection-pool.h b/hbase-native-client/connection/connection-pool.h
index 605a81b..b8c950b 100644
--- a/hbase-native-client/connection/connection-pool.h
+++ b/hbase-native-client/connection/connection-pool.h
@@ -88,8 +88,8 @@ public:
   void Close(const hbase::pb::ServerName &sn);
 
 private:
-  std::shared_ptr<HBaseService> GetCached(const hbase::pb::ServerName& sn);
-  std::shared_ptr<HBaseService> GetNew(const hbase::pb::ServerName& sn);
+  std::shared_ptr<HBaseService> GetCached(const hbase::pb::ServerName &sn);
+  std::shared_ptr<HBaseService> GetNew(const hbase::pb::ServerName &sn);
   std::unordered_map<hbase::pb::ServerName, std::shared_ptr<HBaseService>,
                      ServerNameHash, ServerNameEquals>
       connections_;

http://git-wip-us.apache.org/repos/asf/hbase/blob/8014cdfe/hbase-native-client/core/location-cache.cc
----------------------------------------------------------------------
diff --git a/hbase-native-client/core/location-cache.cc b/hbase-native-client/core/location-cache.cc
index 6ba8add..efd2210 100644
--- a/hbase-native-client/core/location-cache.cc
+++ b/hbase-native-client/core/location-cache.cc
@@ -116,7 +116,7 @@ LocationCache::LocateFromMeta(const TableName &tn, const string &row) {
   return this->LocateMeta()
       .via(cpu_executor_.get())
       .then([this](ServerName sn) { return this->cp_.Get(sn); })
-    .then([tn, row, this](std::shared_ptr<HBaseService> service) {
+      .then([tn, row, this](std::shared_ptr<HBaseService> service) {
         return (*service)(std::move(meta_util_.MetaRequest(tn, row)));
       })
       .then([this](Response resp) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/8014cdfe/hbase-native-client/core/location-cache.h
----------------------------------------------------------------------
diff --git a/hbase-native-client/core/location-cache.h b/hbase-native-client/core/location-cache.h
index d435530..830cd96 100644
--- a/hbase-native-client/core/location-cache.h
+++ b/hbase-native-client/core/location-cache.h
@@ -55,7 +55,7 @@ public:
    * @param io_executor executor used to talk to the network
    */
   LocationCache(std::string quorum_spec,
-                std::shared_ptr<wangle::CPUThreadPoolExecutor> cpu_exector,
+                std::shared_ptr<wangle::CPUThreadPoolExecutor> cpu_executor,
                 std::shared_ptr<wangle::IOThreadPoolExecutor> io_executor);
   /**
    * Destructor.

http://git-wip-us.apache.org/repos/asf/hbase/blob/8014cdfe/hbase-native-client/test-util/test-util.cc
----------------------------------------------------------------------
diff --git a/hbase-native-client/test-util/test-util.cc b/hbase-native-client/test-util/test-util.cc
index e5fba48..88ce7c8 100644
--- a/hbase-native-client/test-util/test-util.cc
+++ b/hbase-native-client/test-util/test-util.cc
@@ -24,13 +24,18 @@
 using hbase::TestUtil;
 using folly::Random;
 
-const static int STR_LEN = 32;
-
-std::string TestUtil::RandString() {
-  auto s = std::string(STR_LEN, 'z');
-
-  for (int i = 0; i < STR_LEN; i++) {
+std::string TestUtil::RandString(int len) {
+  // Create the whole string.
+  // Filling everything with z's
+  auto s = std::string(len, 'z');
+
+  // Now pick a bunch of random numbers
+  for (int i = 0; i < len; i++) {
+    // use Folly's random to get the numbers
+    // as I don't want to have to learn
+    // all the cpp rand invocation magic.
     auto r = Random::rand32('a', 'z');
+    // Cast that to ascii.
     s[i] = static_cast<char>(r);
   }
   return s;
@@ -42,12 +47,13 @@ TestUtil::TestUtil() : temp_dir_(TestUtil::RandString()) {
   auto res_code = std::system(cmd.c_str());
   CHECK(res_code == 0);
 }
+
 TestUtil::~TestUtil() {
   auto res_code = std::system("bin/stop-local-hbase.sh");
   CHECK(res_code == 0);
 }
 
-void TestUtil::RunShellCmd(const std::string& command) {
+void TestUtil::RunShellCmd(const std::string &command) {
   auto cmd_string = folly::sformat("echo \"{}\" | ../bin/hbase shell", command);
   auto res_code = std::system(cmd_string.c_str());
   CHECK(res_code == 0);

http://git-wip-us.apache.org/repos/asf/hbase/blob/8014cdfe/hbase-native-client/test-util/test-util.h
----------------------------------------------------------------------
diff --git a/hbase-native-client/test-util/test-util.h b/hbase-native-client/test-util/test-util.h
index 395b157..20e4981 100644
--- a/hbase-native-client/test-util/test-util.h
+++ b/hbase-native-client/test-util/test-util.h
@@ -30,20 +30,30 @@ namespace hbase {
  */
 class TestUtil {
 public:
-
   /**
    * Creating a TestUtil will spin up a cluster.
    */
   TestUtil();
+
   /**
-   * Destroying a TestUtil will spin down a cluster.
+   * Destroying a TestUtil will spin down a cluster and remove the test dir.
    */
   ~TestUtil();
+
+  /**
+   * Run a command in the hbase shell. Command should not include any double
+   * quotes.
+   *
+   * This should only be used until there is a good Admin support from the
+   * native client
+   */
+  void RunShellCmd(const std::string &command);
+
   /**
-   * Run a command in the hbase shell.
+   * Create a random string. This random string is all letters, as such it is
+   * very good for use as a directory name.
    */
-  void RunShellCmd(const std::string& command);
-  static std::string RandString();
+  static std::string RandString(int len = 32);
 
 private:
   folly::test::TemporaryDirectory temp_dir_;