You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by ad...@apache.org on 2016/09/26 19:25:07 UTC
[6/6] kudu git commit: ensure every gflag is defined outside of a
namespace
ensure every gflag is defined outside of a namespace
The gflags docs recommend that all gflags be defined globally, outside of any
namespace. This patch moves a couple gflags out of their respective namespaces
accordingly. It shouldn't be backwards incompatible in any way.
Change-Id: Iea2cb97539d19feae5e86f3873dab741b08e37b1
Reviewed-on: http://gerrit.cloudera.org:8080/4505
Reviewed-by: Dan Burkert <da...@cloudera.com>
Tested-by: Adar Dembo <ad...@cloudera.com>
Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/dba7cddf
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/dba7cddf
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/dba7cddf
Branch: refs/heads/master
Commit: dba7cddf7c0867eaae24916c709c1d4405b822b6
Parents: 9bcd522
Author: Adar Dembo <ad...@cloudera.com>
Authored: Fri Sep 16 16:02:36 2016 -0700
Committer: Adar Dembo <ad...@cloudera.com>
Committed: Mon Sep 26 19:24:10 2016 +0000
----------------------------------------------------------------------
src/kudu/master/master_options.cc | 6 ++---
src/kudu/rpc/outbound_call.cc | 19 ++++++---------
src/kudu/server/server_base_options.cc | 7 +++---
src/kudu/tablet/svg_dump.cc | 14 +++++------
src/kudu/tablet/tablet-decoder-eval-test.cc | 10 ++++----
src/kudu/tablet/tablet-test.cc | 15 ++++++------
src/kudu/tools/ksck.cc | 25 ++++++++++---------
src/kudu/tserver/tablet_server_options.cc | 5 ++--
src/kudu/util/flag_tags.h | 2 +-
src/kudu/util/memory/memory.cc | 31 +++++++++++-------------
src/kudu/util/striped64-test.cc | 4 +--
11 files changed, 66 insertions(+), 72 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kudu/blob/dba7cddf/src/kudu/master/master_options.cc
----------------------------------------------------------------------
diff --git a/src/kudu/master/master_options.cc b/src/kudu/master/master_options.cc
index 2a5544b..dc9d4b6 100644
--- a/src/kudu/master/master_options.cc
+++ b/src/kudu/master/master_options.cc
@@ -23,15 +23,15 @@
#include "kudu/master/master.h"
#include "kudu/util/flag_tags.h"
-namespace kudu {
-namespace master {
-
DEFINE_string(master_addresses, "",
"Comma-separated list of the RPC addresses belonging to all "
"Masters in this cluster. "
"NOTE: if not specified, configures a non-replicated Master.");
TAG_FLAG(master_addresses, stable);
+namespace kudu {
+namespace master {
+
MasterOptions::MasterOptions() {
rpc_opts.default_port = Master::kDefaultPort;
http://git-wip-us.apache.org/repos/asf/kudu/blob/dba7cddf/src/kudu/rpc/outbound_call.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/outbound_call.cc b/src/kudu/rpc/outbound_call.cc
index cfa0316..2795e16 100644
--- a/src/kudu/rpc/outbound_call.cc
+++ b/src/kudu/rpc/outbound_call.cc
@@ -19,7 +19,6 @@
#include <boost/functional/hash.hpp>
#include <gflags/gflags.h>
#include <mutex>
-#include <set>
#include <string>
#include <unordered_set>
#include <vector>
@@ -35,16 +34,6 @@
#include "kudu/util/flag_tags.h"
#include "kudu/util/kernel_stack_watchdog.h"
-namespace kudu {
-namespace rpc {
-
-using google::protobuf::io::CodedOutputStream;
-using google::protobuf::Message;
-using std::set;
-using strings::Substitute;
-
-static const double kMicrosPerSecond = 1000000.0;
-
// 100M cycles should be about 50ms on a 2Ghz box. This should be high
// enough that involuntary context switches don't trigger it, but low enough
// that any serious blocking behavior on the reactor would.
@@ -55,6 +44,14 @@ DEFINE_int64(rpc_callback_max_cycles, 100 * 1000 * 1000,
TAG_FLAG(rpc_callback_max_cycles, advanced);
TAG_FLAG(rpc_callback_max_cycles, runtime);
+namespace kudu {
+namespace rpc {
+
+using google::protobuf::Message;
+using strings::Substitute;
+
+static const double kMicrosPerSecond = 1000000.0;
+
///
/// OutboundCall
///
http://git-wip-us.apache.org/repos/asf/kudu/blob/dba7cddf/src/kudu/server/server_base_options.cc
----------------------------------------------------------------------
diff --git a/src/kudu/server/server_base_options.cc b/src/kudu/server/server_base_options.cc
index 6f7c2b4..af70488 100644
--- a/src/kudu/server/server_base_options.cc
+++ b/src/kudu/server/server_base_options.cc
@@ -18,10 +18,8 @@
#include "kudu/server/server_base_options.h"
#include <gflags/gflags.h>
-#include "kudu/util/flag_tags.h"
-namespace kudu {
-namespace server {
+#include "kudu/util/flag_tags.h"
DEFINE_string(server_dump_info_path, "",
"Path into which the server information will be "
@@ -41,6 +39,9 @@ DEFINE_int32(metrics_log_interval_ms, 0,
"value, then metrics logging will be disabled.");
TAG_FLAG(metrics_log_interval_ms, advanced);
+namespace kudu {
+namespace server {
+
ServerBaseOptions::ServerBaseOptions()
: env(Env::Default()),
dump_info_path(FLAGS_server_dump_info_path),
http://git-wip-us.apache.org/repos/asf/kudu/blob/dba7cddf/src/kudu/tablet/svg_dump.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/svg_dump.cc b/src/kudu/tablet/svg_dump.cc
index 56af079..1c5f49f 100644
--- a/src/kudu/tablet/svg_dump.cc
+++ b/src/kudu/tablet/svg_dump.cc
@@ -34,13 +34,6 @@
#include "kudu/tablet/rowset_info.h"
#include "kudu/util/flag_tags.h"
-using std::ostream;
-using std::unordered_set;
-using std::vector;
-
-namespace kudu {
-namespace tablet {
-
// Flag to dump SVGs of every compaction decision.
//
// After dumping, these may be converted to an animation using a series of
@@ -56,6 +49,13 @@ DEFINE_string(compaction_policy_dump_svgs_pattern, "",
"with the compaction selection timestamp.");
TAG_FLAG(compaction_policy_dump_svgs_pattern, hidden);
+using std::ostream;
+using std::unordered_set;
+using std::vector;
+
+namespace kudu {
+namespace tablet {
+
namespace {
// Organize the input rowsets into rows for presentation. This simply
http://git-wip-us.apache.org/repos/asf/kudu/blob/dba7cddf/src/kudu/tablet/tablet-decoder-eval-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet-decoder-eval-test.cc b/src/kudu/tablet/tablet-decoder-eval-test.cc
index e35f416..ed43024 100644
--- a/src/kudu/tablet/tablet-decoder-eval-test.cc
+++ b/src/kudu/tablet/tablet-decoder-eval-test.cc
@@ -24,6 +24,11 @@
#include "kudu/common/schema.h"
#include "kudu/tablet/tablet-test-base.h"
+DEFINE_int32(decoder_eval_test_nrepeats, 1, "Number of times to repeat per tablet");
+DEFINE_int32(decoder_eval_test_lower, 0, "Lower bound on the predicate [lower, upper)");
+DEFINE_int32(decoder_eval_test_upper, 50, "Upper bound on the predicate [lower, upper)");
+DEFINE_int32(decoder_eval_test_strlen, 10, "Number of strings per cell");
+
namespace kudu {
namespace tablet {
@@ -37,11 +42,6 @@ enum Setup {
#endif
};
-DEFINE_int32(decoder_eval_test_nrepeats, 1, "Number of times to repeat per tablet");
-DEFINE_int32(decoder_eval_test_lower, 0, "Lower bound on the predicate [lower, upper)");
-DEFINE_int32(decoder_eval_test_upper, 50, "Upper bound on the predicate [lower, upper)");
-DEFINE_int32(decoder_eval_test_strlen, 10, "Number of strings per cell");
-
class TabletDecoderEvalTest : public KuduTabletTest,
public ::testing::WithParamInterface<Setup> {
public:
http://git-wip-us.apache.org/repos/asf/kudu/blob/dba7cddf/src/kudu/tablet/tablet-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet-test.cc b/src/kudu/tablet/tablet-test.cc
index f704f0d..21ce05c 100644
--- a/src/kudu/tablet/tablet-test.cc
+++ b/src/kudu/tablet/tablet-test.cc
@@ -31,14 +31,6 @@
#include "kudu/util/slice.h"
#include "kudu/util/test_macros.h"
-using std::shared_ptr;
-using std::unordered_set;
-
-namespace kudu {
-namespace tablet {
-
-using fs::ReadableBlock;
-
DEFINE_int32(testflush_num_inserts, 1000,
"Number of rows inserted in TestFlush");
DEFINE_int32(testiterator_num_inserts, 1000,
@@ -46,6 +38,13 @@ DEFINE_int32(testiterator_num_inserts, 1000,
DEFINE_int32(testcompaction_num_rows, 1000,
"Number of rows per rowset in TestCompaction");
+using std::shared_ptr;
+
+namespace kudu {
+namespace tablet {
+
+using fs::ReadableBlock;
+
template<class SETUP>
class TestTablet : public TabletTestBase<SETUP> {
typedef SETUP Type;
http://git-wip-us.apache.org/repos/asf/kudu/blob/dba7cddf/src/kudu/tools/ksck.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tools/ksck.cc b/src/kudu/tools/ksck.cc
index 270765d..21cc6ba 100644
--- a/src/kudu/tools/ksck.cc
+++ b/src/kudu/tools/ksck.cc
@@ -38,30 +38,31 @@
#include "kudu/util/monotime.h"
#include "kudu/util/threadpool.h"
-namespace kudu {
-namespace tools {
-
-using std::cout;
-using std::endl;
-using std::ostream;
-using std::shared_ptr;
-using std::string;
-using std::unordered_map;
-using strings::Substitute;
-
DEFINE_int32(checksum_timeout_sec, 3600,
"Maximum total seconds to wait for a checksum scan to complete "
"before timing out.");
DEFINE_int32(checksum_scan_concurrency, 4,
"Number of concurrent checksum scans to execute per tablet server.");
DEFINE_bool(checksum_snapshot, true, "Should the checksum scanner use a snapshot scan");
-DEFINE_uint64(checksum_snapshot_timestamp, ChecksumOptions::kCurrentTimestamp,
+DEFINE_uint64(checksum_snapshot_timestamp,
+ kudu::tools::ChecksumOptions::kCurrentTimestamp,
"timestamp to use for snapshot checksum scans, defaults to 0, which "
"uses the current timestamp of a tablet server involved in the scan");
DEFINE_int32(fetch_replica_info_concurrency, 20,
"Number of concurrent tablet servers to fetch replica info from.");
+namespace kudu {
+namespace tools {
+
+using std::cout;
+using std::endl;
+using std::ostream;
+using std::shared_ptr;
+using std::string;
+using std::unordered_map;
+using strings::Substitute;
+
// The stream to write output to. If this is NULL, defaults to cout.
// This is used by tests to capture output.
ostream* g_err_stream = NULL;
http://git-wip-us.apache.org/repos/asf/kudu/blob/dba7cddf/src/kudu/tserver/tablet_server_options.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_server_options.cc b/src/kudu/tserver/tablet_server_options.cc
index 70b6fc4..7361c41 100644
--- a/src/kudu/tserver/tablet_server_options.cc
+++ b/src/kudu/tserver/tablet_server_options.cc
@@ -24,9 +24,6 @@
#include "kudu/tserver/tablet_server.h"
#include "kudu/util/flag_tags.h"
-namespace kudu {
-namespace tserver {
-
DEFINE_string(tserver_master_addrs, "127.0.0.1:7051",
"Comma separated addresses of the masters which the "
"tablet server should connect to. The masters do not "
@@ -34,6 +31,8 @@ DEFINE_string(tserver_master_addrs, "127.0.0.1:7051",
"using 'rpc_bind_addresses'.");
TAG_FLAG(tserver_master_addrs, stable);
+namespace kudu {
+namespace tserver {
TabletServerOptions::TabletServerOptions() {
rpc_opts.default_port = TabletServer::kDefaultPort;
http://git-wip-us.apache.org/repos/asf/kudu/blob/dba7cddf/src/kudu/util/flag_tags.h
----------------------------------------------------------------------
diff --git a/src/kudu/util/flag_tags.h b/src/kudu/util/flag_tags.h
index 425fec7..d11e82d 100644
--- a/src/kudu/util/flag_tags.h
+++ b/src/kudu/util/flag_tags.h
@@ -132,7 +132,7 @@ struct FlagTags {
// This also validates that 'tag' is a valid flag as defined in the FlagTags
// enum above.
#define TAG_FLAG(flag_name, tag) \
- COMPILE_ASSERT(sizeof(FLAGS_##flag_name), flag_does_not_exist); \
+ COMPILE_ASSERT(sizeof(decltype(FLAGS_##flag_name)), flag_does_not_exist); \
COMPILE_ASSERT(sizeof(::kudu::FlagTags::tag), invalid_tag); \
namespace { \
::kudu::flag_tags_internal::FlagTagger t_##flag_name##_##tag( \
http://git-wip-us.apache.org/repos/asf/kudu/blob/dba7cddf/src/kudu/util/memory/memory.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/memory/memory.cc b/src/kudu/util/memory/memory.cc
index 835ad3e..9db0464 100644
--- a/src/kudu/util/memory/memory.cc
+++ b/src/kudu/util/memory/memory.cc
@@ -20,23 +20,28 @@
#include "kudu/util/memory/memory.h"
+#include <string.h>
+
+#include <algorithm>
+#include <cstdlib>
+
+#include <gflags/gflags.h>
+
#include "kudu/util/alignment.h"
#include "kudu/util/flag_tags.h"
#include "kudu/util/memory/overwrite.h"
#include "kudu/util/mem_tracker.h"
-#include <gflags/gflags.h>
-#include <string.h>
-
-#include <algorithm>
using std::copy;
-using std::max;
using std::min;
-using std::reverse;
-using std::sort;
-using std::swap;
-#include <cstdlib>
+// TODO(onufry) - test whether the code still tests OK if we set this to true,
+// or remove this code and add a test that Google allocator does not change it's
+// contract - 16-aligned in -c opt and %16 == 8 in debug.
+DEFINE_bool(allocator_aligned_mode, false,
+ "Use 16-byte alignment instead of 8-byte, "
+ "unless explicitly specified otherwise - to boost SIMD");
+TAG_FLAG(allocator_aligned_mode, hidden);
namespace kudu {
@@ -77,14 +82,6 @@ void BufferAllocator::LogAllocation(size_t requested,
}
}
-// TODO(onufry) - test whether the code still tests OK if we set this to true,
-// or remove this code and add a test that Google allocator does not change it's
-// contract - 16-aligned in -c opt and %16 == 8 in debug.
-DEFINE_bool(allocator_aligned_mode, false,
- "Use 16-byte alignment instead of 8-byte, "
- "unless explicitly specified otherwise - to boost SIMD");
-TAG_FLAG(allocator_aligned_mode, hidden);
-
HeapBufferAllocator::HeapBufferAllocator()
: aligned_mode_(FLAGS_allocator_aligned_mode) {
}
http://git-wip-us.apache.org/repos/asf/kudu/blob/dba7cddf/src/kudu/util/striped64-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/striped64-test.cc b/src/kudu/util/striped64-test.cc
index 6cabdce..fee07ca 100644
--- a/src/kudu/util/striped64-test.cc
+++ b/src/kudu/util/striped64-test.cc
@@ -25,12 +25,12 @@
#include "kudu/util/test_util.h"
#include "kudu/util/thread.h"
-namespace kudu {
-
// These flags are used by the multi-threaded tests, can be used for microbenchmarking.
DEFINE_int32(num_operations, 10*1000, "Number of operations to perform");
DEFINE_int32(num_threads, 2, "Number of worker threads");
+namespace kudu {
+
// Test some basic operations
TEST(Striped64Test, TestBasic) {
LongAdder adder;