Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 31CB2200AF5 for ; Thu, 19 May 2016 00:49:30 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 30645160A15; Wed, 18 May 2016 22:49:30 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 51648160A26 for ; Thu, 19 May 2016 00:49:29 +0200 (CEST) Received: (qmail 3740 invoked by uid 500); 18 May 2016 22:49:24 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 2705 invoked by uid 99); 18 May 2016 22:49:23 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 May 2016 22:49:23 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 8D97CE094B; Wed, 18 May 2016 22:49:23 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: eclark@apache.org To: commits@hbase.apache.org Date: Wed, 18 May 2016 22:50:00 -0000 Message-Id: <236592756187416abc7c03ea99cce745@git.apache.org> In-Reply-To: <5a847047da0a4c87828fc6fa66936f0d@git.apache.org> References: <5a847047da0a4c87828fc6fa66936f0d@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [39/42] hbase git commit: HBASE-15821 Document TestUtil archived-at: Wed, 18 May 2016 22:49:30 -0000 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/f49f262f Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/f49f262f Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/f49f262f Branch: refs/heads/HBASE-14850 Commit: f49f262f3c7efcae228713d3371df69d7c49efce Parents: 616405a Author: Elliott Clark Authored: Fri May 13 09:17:49 2016 -0700 Committer: Elliott Clark Committed: Wed May 18 15:48:52 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/f49f262f/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/f49f262f/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 GetCached(const hbase::pb::ServerName& sn); - std::shared_ptr GetNew(const hbase::pb::ServerName& sn); + std::shared_ptr GetCached(const hbase::pb::ServerName &sn); + std::shared_ptr GetNew(const hbase::pb::ServerName &sn); std::unordered_map, ServerNameHash, ServerNameEquals> connections_; http://git-wip-us.apache.org/repos/asf/hbase/blob/f49f262f/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 service) { + .then([tn, row, this](std::shared_ptr service) { return (*service)(std::move(meta_util_.MetaRequest(tn, row))); }) .then([this](Response resp) { http://git-wip-us.apache.org/repos/asf/hbase/blob/f49f262f/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 cpu_exector, + std::shared_ptr cpu_executor, std::shared_ptr io_executor); /** * Destructor. http://git-wip-us.apache.org/repos/asf/hbase/blob/f49f262f/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(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/f49f262f/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_;