You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by to...@apache.org on 2017/06/12 23:22:43 UTC

[1/4] kudu git commit: [python] Fix undefined TimeoutError in tests

Repository: kudu
Updated Branches:
  refs/heads/master 681f05b43 -> 7ac7762ff


[python] Fix undefined TimeoutError in tests

The tests use TimeoutError, which is not defined in Python 2
(but is in Python 3). I added a minimal definition of
TimeoutError.

Change-Id: I1c6c634803cf5cc8f083f4480606aed10f86db91
Reviewed-on: http://gerrit.cloudera.org:8080/7078
Tested-by: Kudu Jenkins
Reviewed-by: Will Berkeley <wd...@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/636e2a9d
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/636e2a9d
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/636e2a9d

Branch: refs/heads/master
Commit: 636e2a9d29ff9a80ee601717f6789da972acd123
Parents: 681f05b
Author: Will Berkeley <wd...@apache.org>
Authored: Mon Jun 5 09:53:29 2017 -0700
Committer: Will Berkeley <wd...@gmail.com>
Committed: Mon Jun 12 18:57:55 2017 +0000

----------------------------------------------------------------------
 python/kudu/tests/common.py       | 5 +++++
 python/kudu/tests/test_scanner.py | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/636e2a9d/python/kudu/tests/common.py
----------------------------------------------------------------------
diff --git a/python/kudu/tests/common.py b/python/kudu/tests/common.py
index 1b606aa..c6b1b7d 100644
--- a/python/kudu/tests/common.py
+++ b/python/kudu/tests/common.py
@@ -30,6 +30,11 @@ import socket
 import kudu
 from kudu.client import Partitioning
 
+# There's no built-in timeout error in Python 2.
+# See https://stackoverflow.com/questions/2281850.
+class TimeoutError(Exception):
+    pass
+
 class KuduTestBase(object):
 
     """

http://git-wip-us.apache.org/repos/asf/kudu/blob/636e2a9d/python/kudu/tests/test_scanner.py
----------------------------------------------------------------------
diff --git a/python/kudu/tests/test_scanner.py b/python/kudu/tests/test_scanner.py
index b483b38..2db0411 100644
--- a/python/kudu/tests/test_scanner.py
+++ b/python/kudu/tests/test_scanner.py
@@ -20,7 +20,7 @@ from __future__ import division
 
 from kudu.compat import unittest
 from kudu.tests.util import TestScanBase
-from kudu.tests.common import KuduTestBase
+from kudu.tests.common import KuduTestBase, TimeoutError
 import kudu
 import datetime
 import time


[2/4] kudu git commit: tidy: enable some identifier naming rules

Posted by to...@apache.org.
tidy: enable some identifier naming rules

This adds some basic identifier naming rules to our tidy config and
fixes some of the aberrations from our style guide.

There are many more such options we can add over time, but we're more
inconsistent in certain areas (eg FOO_BAR vs kFooBar for constants) and
I wanted to start with the rules that we apply most consistently.

Change-Id: I9749c4bef61ca780c3543a4894d289ef9a448ea9
Reviewed-on: http://gerrit.cloudera.org:8080/7157
Reviewed-by: Adar Dembo <ad...@cloudera.com>
Reviewed-by: Dan Burkert <da...@apache.org>
Reviewed-by: Hao Hao <ha...@cloudera.com>
Tested-by: Kudu Jenkins


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/850ebef6
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/850ebef6
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/850ebef6

Branch: refs/heads/master
Commit: 850ebef628650bbce193376343b8c468facf294b
Parents: 636e2a9
Author: Todd Lipcon <to...@cloudera.com>
Authored: Mon Jun 12 12:24:20 2017 -0700
Committer: Todd Lipcon <to...@apache.org>
Committed: Mon Jun 12 23:12:07 2017 +0000

----------------------------------------------------------------------
 src/kudu/.clang-tidy                            | 13 +++++++++
 src/kudu/benchmarks/tpch/tpch1.cc               |  6 ++---
 src/kudu/client/client-test.cc                  |  6 ++---
 src/kudu/common/scan_spec.cc                    | 12 ++++-----
 src/kudu/experiments/rwlock-perf.cc             | 28 ++++++++++----------
 src/kudu/gutil/hash/hash.cc                     |  2 +-
 src/kudu/gutil/spinlock.cc                      |  6 ++---
 .../full_stack-insert-scan-test.cc              |  6 ++---
 src/kudu/tools/ksck_remote.cc                   |  6 ++---
 src/kudu/util/memcmpable_varint.cc              | 20 +++++++-------
 src/kudu/util/memory/memory.cc                  | 12 ++++-----
 src/kudu/util/net/socket.cc                     |  4 +--
 src/kudu/util/striped64.cc                      |  6 ++---
 13 files changed, 70 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/850ebef6/src/kudu/.clang-tidy
----------------------------------------------------------------------
diff --git a/src/kudu/.clang-tidy b/src/kudu/.clang-tidy
index d8a072d..de0a477 100644
--- a/src/kudu/.clang-tidy
+++ b/src/kudu/.clang-tidy
@@ -16,3 +16,16 @@
 # under the License.
 Checks:          'clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,-*,readability-*,-readability-braces-around-statements,llvm-include-order,misc-*,-modernize-*,performance-*,-readability-implicit-bool-cast,google-*,-google-readability-braces-around-statements,-readability-redundant-string-init'
 HeaderFilterRegex: '.*,-*.pb.h'
+CheckOptions:
+  - key:             readability-identifier-naming.ClassCase
+    value:           CamelCase
+  - key:             readability-identifier-naming.EnumCase
+    value:           CamelCase
+  - key:             readability-identifier-naming.PrivateMemberSuffix
+    value:           '_'
+  - key:             readability-identifier-naming.ParameterCase
+    value:           lower_case
+  - key:             readability-identifier-naming.NamespaceCase
+    value:           lower_case
+  - key:             readability-identifier-naming.InlineNamespaceCase
+    value:           lower_case

http://git-wip-us.apache.org/repos/asf/kudu/blob/850ebef6/src/kudu/benchmarks/tpch/tpch1.cc
----------------------------------------------------------------------
diff --git a/src/kudu/benchmarks/tpch/tpch1.cc b/src/kudu/benchmarks/tpch/tpch1.cc
index da36872..7cc95eb 100644
--- a/src/kudu/benchmarks/tpch/tpch1.cc
+++ b/src/kudu/benchmarks/tpch/tpch1.cc
@@ -129,7 +129,7 @@ struct SliceMapKey {
   }
 };
 
-struct hash {
+struct Hash {
   size_t operator()(const SliceMapKey &key) const {
     return util_hash::CityHash64(
       reinterpret_cast<const char *>(key.slice.data()), key.slice.size());
@@ -154,8 +154,8 @@ void WarmupScanCache(RpcLineItemDAO* dao) {
 }
 
 void Tpch1(RpcLineItemDAO *dao) {
-  typedef unordered_map<SliceMapKey, Result*, hash> slice_map;
-  typedef unordered_map<SliceMapKey, slice_map*, hash> slice_map_map;
+  typedef unordered_map<SliceMapKey, Result*, Hash> slice_map;
+  typedef unordered_map<SliceMapKey, slice_map*, Hash> slice_map_map;
 
   gscoped_ptr<RpcLineItemDAO::Scanner> scanner;
   dao->OpenTpch1Scanner(&scanner);

http://git-wip-us.apache.org/repos/asf/kudu/blob/850ebef6/src/kudu/client/client-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/client-test.cc b/src/kudu/client/client-test.cc
index 244b80c..a7c5070 100644
--- a/src/kudu/client/client-test.cc
+++ b/src/kudu/client/client-test.cc
@@ -3911,16 +3911,16 @@ TEST_F(ClientTest, TestMasterLookupPermits) {
 namespace {
 class DLSCallback : public KuduStatusCallback {
  public:
-  explicit DLSCallback(Atomic32* i) : i(i) {
+  explicit DLSCallback(Atomic32* i) : i_(i) {
   }
 
   virtual void Run(const Status& s) OVERRIDE {
     CHECK_OK(s);
-    NoBarrier_AtomicIncrement(i, 1);
+    NoBarrier_AtomicIncrement(i_, 1);
     delete this;
   }
  private:
-  Atomic32* const i;
+  Atomic32* const i_;
 };
 
 // Returns col1 value of first row.

http://git-wip-us.apache.org/repos/asf/kudu/blob/850ebef6/src/kudu/common/scan_spec.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/scan_spec.cc b/src/kudu/common/scan_spec.cc
index 9251972..98a99e4 100644
--- a/src/kudu/common/scan_spec.cc
+++ b/src/kudu/common/scan_spec.cc
@@ -81,16 +81,16 @@ void ScanSpec::SetExclusiveUpperBoundKey(const EncodedKey* key) {
   }
 }
 
-void ScanSpec::SetLowerBoundPartitionKey(const Slice& partitionKey) {
-  if (partitionKey.compare(lower_bound_partition_key_) > 0) {
-    lower_bound_partition_key_ = partitionKey.ToString();
+void ScanSpec::SetLowerBoundPartitionKey(const Slice& partition_key) {
+  if (partition_key.compare(lower_bound_partition_key_) > 0) {
+    lower_bound_partition_key_ = partition_key.ToString();
   }
 }
 
-void ScanSpec::SetExclusiveUpperBoundPartitionKey(const Slice& partitionKey) {
+void ScanSpec::SetExclusiveUpperBoundPartitionKey(const Slice& partition_key) {
   if (exclusive_upper_bound_partition_key_.empty() ||
-      (!partitionKey.empty() && partitionKey.compare(exclusive_upper_bound_partition_key_) < 0)) {
-    exclusive_upper_bound_partition_key_ = partitionKey.ToString();
+      (!partition_key.empty() && partition_key.compare(exclusive_upper_bound_partition_key_) < 0)) {
+    exclusive_upper_bound_partition_key_ = partition_key.ToString();
   }
 }
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/850ebef6/src/kudu/experiments/rwlock-perf.cc
----------------------------------------------------------------------
diff --git a/src/kudu/experiments/rwlock-perf.cc b/src/kudu/experiments/rwlock-perf.cc
index 55a2d77..a419c32 100644
--- a/src/kudu/experiments/rwlock-perf.cc
+++ b/src/kudu/experiments/rwlock-perf.cc
@@ -46,19 +46,19 @@ class my_spinlock : public boost::detail::spinlock {
   DISALLOW_COPY_AND_ASSIGN(my_spinlock);
 };
 
-struct per_cpu_lock {
-  struct padded_lock {
+struct PerCpuLock {
+  struct PaddedLock {
     my_spinlock lock;
     char padding[CACHELINE_SIZE - sizeof(my_spinlock)];
   };
 
-  per_cpu_lock() {
+  PerCpuLock() {
     n_cpus_ = base::NumCPUs();
     CHECK_GT(n_cpus_, 0);
-    locks_ = new padded_lock[n_cpus_];
+    locks_ = new PaddedLock[n_cpus_];
   }
 
-  ~per_cpu_lock() {
+  ~PerCpuLock() {
     delete [] locks_;
   }
 
@@ -69,11 +69,11 @@ struct per_cpu_lock {
   }
 
   int n_cpus_;
-  padded_lock *locks_;
+  PaddedLock *locks_;
 
 };
 
-struct shared_data {
+struct SharedData {
   kudu::rw_spinlock rw_spinlock;
   kudu::RWMutex rwlock;
   std::mutex lock;
@@ -81,7 +81,7 @@ struct shared_data {
 };
 
 
-class noop_lock {
+class NoopLock {
  public:
   void lock() {}
   void unlock() {}
@@ -106,7 +106,7 @@ static void depend_on(float val) {
   }
 }
 
-void shared_rwlock_entry(shared_data *shared) {
+void shared_rwlock_entry(SharedData *shared) {
   float result = 1;
   for (int i = 0; i < 1000000; i++) {
     shared->rwlock.lock_shared();
@@ -116,7 +116,7 @@ void shared_rwlock_entry(shared_data *shared) {
   depend_on(result);
 }
 
-void shared_rw_spinlock_entry(shared_data *shared) {
+void shared_rw_spinlock_entry(SharedData *shared) {
   float result = 1;
   for (int i = 0; i < 1000000; i++) {
     shared->rw_spinlock.lock_shared();
@@ -126,7 +126,7 @@ void shared_rw_spinlock_entry(shared_data *shared) {
   depend_on(result);
 }
 
-void shared_mutex_entry(shared_data *shared) {
+void shared_mutex_entry(SharedData *shared) {
   float result = 1;
   for (int i = 0; i < 1000000; i++) {
     shared->lock.lock();
@@ -149,7 +149,7 @@ void own_mutex_entry() {
   depend_on(result);
 }
 
-void percpu_rwlock_entry(shared_data *shared) {
+void percpu_rwlock_entry(SharedData *shared) {
   float result = 1;
   for (int i = 0; i < 1000000; i++) {
     kudu::rw_spinlock &l = shared->per_cpu.get_lock();
@@ -174,7 +174,7 @@ enum TestMethod {
 
 void test_shared_lock(int num_threads, TestMethod method, const char *name) {
   vector<thread> threads;
-  shared_data shared;
+  SharedData shared;
 
   for (int i = 0; i < num_threads; i++) {
     switch (method) {
@@ -191,7 +191,7 @@ void test_shared_lock(int num_threads, TestMethod method, const char *name) {
         threads.emplace_back(own_mutex_entry<my_spinlock>);
         break;
       case NO_LOCK:
-        threads.emplace_back(own_mutex_entry<noop_lock>);
+        threads.emplace_back(own_mutex_entry<NoopLock>);
         break;
       case PERCPU_RWLOCK:
         threads.emplace_back(percpu_rwlock_entry, &shared);

http://git-wip-us.apache.org/repos/asf/kudu/blob/850ebef6/src/kudu/gutil/hash/hash.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/hash/hash.cc b/src/kudu/gutil/hash/hash.cc
index 92a8ca2..71141c0 100644
--- a/src/kudu/gutil/hash/hash.cc
+++ b/src/kudu/gutil/hash/hash.cc
@@ -187,7 +187,7 @@ uint64 FingerprintInterleavedImplementation(const char *s, uint32 len) {
 
 #if defined(__GNUC__)
 #include <ext/hash_set>
-namespace __gnu_cxx {
+namespace __gnu_cxx { // NOLINT(*)
 
 template class hash_set<std::string>;
 template class hash_map<std::string, std::string>;

http://git-wip-us.apache.org/repos/asf/kudu/blob/850ebef6/src/kudu/gutil/spinlock.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/spinlock.cc b/src/kudu/gutil/spinlock.cc
index 8a02c95..63b8513 100644
--- a/src/kudu/gutil/spinlock.cc
+++ b/src/kudu/gutil/spinlock.cc
@@ -57,8 +57,8 @@ const base::LinkerInitialized SpinLock::LINKER_INITIALIZED =
     base::LINKER_INITIALIZED;
 
 namespace {
-struct SpinLock_InitHelper {
-  SpinLock_InitHelper() {
+struct SpinLockInitHelper {
+  SpinLockInitHelper() {
     // On multi-cpu machines, spin for longer before yielding
     // the processor or sleeping.  Reduces idle time significantly.
     if (base::NumCPUs() > 1) {
@@ -70,7 +70,7 @@ struct SpinLock_InitHelper {
 // Hook into global constructor execution:
 // We do not do adaptive spinning before that,
 // but nothing lock-intensive should be going on at that time.
-static SpinLock_InitHelper init_helper;
+static SpinLockInitHelper init_helper;
 
 }  // unnamed namespace
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/850ebef6/src/kudu/integration-tests/full_stack-insert-scan-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/full_stack-insert-scan-test.cc b/src/kudu/integration-tests/full_stack-insert-scan-test.cc
index c2160af..abd3ea2 100644
--- a/src/kudu/integration-tests/full_stack-insert-scan-test.cc
+++ b/src/kudu/integration-tests/full_stack-insert-scan-test.cc
@@ -105,7 +105,7 @@ class FullStackInsertScanTest : public KuduTest {
     kNumInsertClients(DefaultFlag(FLAGS_concurrent_inserts, 3, 10)),
     kNumInsertsPerClient(DefaultFlag(FLAGS_inserts_per_client, 500, 50000)),
     kNumRows(kNumInsertClients * kNumInsertsPerClient),
-    kFlushEveryN(DefaultFlag(FLAGS_rows_per_batch, 125, 5000)),
+    flush_every_n_(DefaultFlag(FLAGS_rows_per_batch, 125, 5000)),
     random_(SeedRandom()),
     sessions_(kNumInsertClients),
     tables_(kNumInsertClients) {
@@ -204,7 +204,7 @@ class FullStackInsertScanTest : public KuduTest {
     kInt32ColBase,
     kInt64ColBase = kInt32ColBase + kNumIntCols
   };
-  const int kFlushEveryN;
+  const int flush_every_n_;
 
   Random random_;
 
@@ -365,7 +365,7 @@ void FullStackInsertScanTest::InsertRows(CountDownLatch* start_latch, int id,
 
     // Report updates or flush every so often, using the synchronizer to always
     // start filling up the next batch while previous one is sent out.
-    if (key % kFlushEveryN == 0) {
+    if (key % flush_every_n_ == 0) {
       Status s = sync.Wait();
       if (!s.ok()) {
         LogSessionErrorsAndDie(session, s);

http://git-wip-us.apache.org/repos/asf/kudu/blob/850ebef6/src/kudu/tools/ksck_remote.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tools/ksck_remote.cc b/src/kudu/tools/ksck_remote.cc
index b9f8eae..0a3d8e4 100644
--- a/src/kudu/tools/ksck_remote.cc
+++ b/src/kudu/tools/ksck_remote.cc
@@ -135,7 +135,7 @@ class ChecksumStepper;
 class ChecksumCallbackHandler {
  public:
   explicit ChecksumCallbackHandler(ChecksumStepper* const stepper)
-      : stepper(DCHECK_NOTNULL(stepper)) {
+      : stepper_(DCHECK_NOTNULL(stepper)) {
   }
 
   // Invoked by an RPC completion callback. Simply calls back into the stepper.
@@ -143,7 +143,7 @@ class ChecksumCallbackHandler {
   void Run();
 
  private:
-  ChecksumStepper* const stepper;
+  ChecksumStepper* const stepper_;
 };
 
 // Simple class to have a "conversation" over multiple requests to a server
@@ -267,7 +267,7 @@ class ChecksumStepper {
 };
 
 void ChecksumCallbackHandler::Run() {
-  stepper->HandleResponse();
+  stepper_->HandleResponse();
   delete this;
 }
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/850ebef6/src/kudu/util/memcmpable_varint.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/memcmpable_varint.cc b/src/kudu/util/memcmpable_varint.cc
index e55addf..35314f8 100644
--- a/src/kudu/util/memcmpable_varint.cc
+++ b/src/kudu/util/memcmpable_varint.cc
@@ -193,45 +193,45 @@ static size_t sqlite4PutVarint64(uint8_t *z, uint64_t x) {
 static int sqlite4GetVarint64(
   const uint8_t *z,
   int n,
-  uint64_t *pResult) {
+  uint64_t *p_result) {
   unsigned int x;
   if ( n < 1) return 0;
   if (z[0] <= 240) {
-    *pResult = z[0];
+    *p_result = z[0];
     return 1;
   }
   if (z[0] <= 248) {
     if ( n < 2) return 0;
-    *pResult = (z[0]-241)*256 + z[1] + 240;
+    *p_result = (z[0]-241)*256 + z[1] + 240;
     return 2;
   }
   if (n < z[0]-246 ) return 0;
   if (z[0] == 249) {
-    *pResult = 2288 + 256*z[1] + z[2];
+    *p_result = 2288 + 256*z[1] + z[2];
     return 3;
   }
   if (z[0] == 250) {
-    *pResult = (z[1]<<16) + (z[2]<<8) + z[3];
+    *p_result = (z[1]<<16) + (z[2]<<8) + z[3];
     return 4;
   }
   x = (z[1]<<24) + (z[2]<<16) + (z[3]<<8) + z[4];
   if (z[0] == 251) {
-    *pResult = x;
+    *p_result = x;
     return 5;
   }
   if (z[0] == 252) {
-    *pResult = (((uint64_t)x)<<8) + z[5];
+    *p_result = (((uint64_t)x)<<8) + z[5];
     return 6;
   }
   if (z[0] == 253) {
-    *pResult = (((uint64_t)x)<<16) + (z[5]<<8) + z[6];
+    *p_result = (((uint64_t)x)<<16) + (z[5]<<8) + z[6];
     return 7;
   }
   if (z[0] == 254) {
-    *pResult = (((uint64_t)x)<<24) + (z[5]<<16) + (z[6]<<8) + z[7];
+    *p_result = (((uint64_t)x)<<24) + (z[5]<<16) + (z[6]<<8) + z[7];
     return 8;
   }
-  *pResult = (((uint64_t)x)<<32) +
+  *p_result = (((uint64_t)x)<<32) +
                (0xffffffff & ((z[5]<<24) + (z[6]<<16) + (z[7]<<8) + z[8]));
   return 9;
 }

http://git-wip-us.apache.org/repos/asf/kudu/blob/850ebef6/src/kudu/util/memory/memory.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/memory/memory.cc b/src/kudu/util/memory/memory.cc
index 9db0464..e393540 100644
--- a/src/kudu/util/memory/memory.cc
+++ b/src/kudu/util/memory/memory.cc
@@ -147,23 +147,23 @@ void* HeapBufferAllocator::Malloc(size_t size) {
   }
 }
 
-void* HeapBufferAllocator::Realloc(void* previousData, size_t previousSize,
-                                   size_t newSize) {
+void* HeapBufferAllocator::Realloc(void* previous_data, size_t previous_size,
+                                   size_t new_size) {
   if (aligned_mode_) {
-    void* data = Malloc(newSize);
+    void* data = Malloc(new_size);
     if (data) {
 // NOTE(ptab): We should use realloc here to avoid memmory coping,
 // but it doesn't work on memory allocated by posix_memalign(...).
 // realloc reallocates the memory but doesn't preserve the content.
 // TODO(ptab): reiterate after some time to check if it is fixed (tcmalloc ?)
-      memcpy(data, previousData, min(previousSize, newSize));
-      free(previousData);
+      memcpy(data, previous_data, min(previous_size, new_size));
+      free(previous_data);
       return data;
     } else {
       return nullptr;
     }
   } else {
-    return realloc(previousData, newSize);
+    return realloc(previous_data, new_size);
   }
 }
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/850ebef6/src/kudu/util/net/socket.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/net/socket.cc b/src/kudu/util/net/socket.cc
index e0bea14..ac28b64 100644
--- a/src/kudu/util/net/socket.cc
+++ b/src/kudu/util/net/socket.cc
@@ -255,10 +255,10 @@ Status Socket::SetReuseAddr(bool flag) {
 }
 
 Status Socket::BindAndListen(const Sockaddr &sockaddr,
-                             int listenQueueSize) {
+                             int listen_queue_size) {
   RETURN_NOT_OK(SetReuseAddr(true));
   RETURN_NOT_OK(Bind(sockaddr));
-  RETURN_NOT_OK(Listen(listenQueueSize));
+  RETURN_NOT_OK(Listen(listen_queue_size));
   return Status::OK();
 }
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/850ebef6/src/kudu/util/striped64.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/striped64.cc b/src/kudu/util/striped64.cc
index 8343177..cf6c780 100644
--- a/src/kudu/util/striped64.cc
+++ b/src/kudu/util/striped64.cc
@@ -130,11 +130,11 @@ void Striped64::RetryUpdate(int64_t x, Rehash to_rehash) {
   tls_hashcode_ = h;
 }
 
-void Striped64::InternalReset(int64_t initialValue) {
+void Striped64::InternalReset(int64_t initial_value) {
   const int32_t n = base::subtle::Acquire_Load(&num_cells_);
-  base_.value_.Store(initialValue);
+  base_.value_.Store(initial_value);
   for (int i = 0; i < n; i++) {
-    cells_[i].value_.Store(initialValue);
+    cells_[i].value_.Store(initial_value);
   }
 }
 


[3/4] kudu git commit: tidy: enable rule for constant naming

Posted by to...@apache.org.
tidy: enable rule for constant naming

This enables the rule that constants should be named kFooBar and fixes
the cases where we didn't adhere to this. The fixes were started using
clang-tidy --fix, but it wasn't very good at finding all references, so
I did some by-hand tweaking to get it to compile after that.

I left a few aberrations in gutil, etc, but this should be at least a
good cleanup.

Change-Id: I7971659ef3152580d44d6ddfb18be7ebf41052c7
Reviewed-on: http://gerrit.cloudera.org:8080/7158
Reviewed-by: Adar Dembo <ad...@cloudera.com>
Tested-by: Kudu Jenkins


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

Branch: refs/heads/master
Commit: e719b5eff2a47f61f9e6ee1f18d2055247f45847
Parents: 850ebef
Author: Todd Lipcon <to...@cloudera.com>
Authored: Mon Jun 12 15:03:49 2017 -0700
Committer: Todd Lipcon <to...@apache.org>
Committed: Mon Jun 12 23:12:25 2017 +0000

----------------------------------------------------------------------
 src/kudu/.clang-tidy                            |  4 ++
 src/kudu/cfile/type_encodings.cc                |  6 +--
 src/kudu/client/meta_cache.cc                   |  6 +--
 src/kudu/fs/log_block_manager.cc                |  8 ++--
 src/kudu/fs/log_block_manager.h                 |  4 +-
 src/kudu/gutil/strings/escaping.cc              |  4 +-
 src/kudu/gutil/strings/substitute.cc            |  4 +-
 src/kudu/gutil/strings/substitute.h             | 42 ++++++++++----------
 src/kudu/integration-tests/all_types-itest.cc   | 24 +++++------
 src/kudu/master/master.cc                       |  2 +-
 src/kudu/rpc/protoc-gen-krpc.cc                 |  8 ++--
 src/kudu/rpc/request_tracker-test.cc            |  4 +-
 src/kudu/rpc/request_tracker.cc                 |  4 +-
 src/kudu/rpc/request_tracker.h                  |  4 +-
 src/kudu/rpc/retriable_rpc.h                    | 10 ++---
 src/kudu/security/ca/cert_management.cc         |  4 +-
 src/kudu/security/cert.cc                       |  2 +-
 src/kudu/security/crypto.cc                     | 22 +++++-----
 src/kudu/security/openssl_util.h                | 28 ++++++-------
 src/kudu/security/openssl_util_bio.h            | 10 ++---
 src/kudu/security/tls_context.cc                |  4 +-
 src/kudu/server/pprof-path-handlers.cc          |  8 ++--
 src/kudu/server/webserver.cc                    | 12 +++---
 .../tablet/all_types-scan-correctness-test.cc   | 22 +++++-----
 src/kudu/tablet/cbtree-test.cc                  | 10 ++---
 src/kudu/tablet/concurrent_btree.h              | 14 +++----
 src/kudu/tserver/tablet_server.cc               |  2 +-
 src/kudu/util/debug/trace_event_impl.cc         | 20 +++++-----
 src/kudu/util/maintenance_manager.cc            |  2 +-
 src/kudu/util/maintenance_manager.h             |  2 +-
 src/kudu/util/mem_tracker-test.cc               |  4 +-
 src/kudu/util/os-util.cc                        | 26 ++++++------
 src/kudu/util/process_memory.cc                 |  4 +-
 src/kudu/util/rle-test.cc                       | 12 +++---
 src/kudu/util/trace.h                           | 20 +++++-----
 35 files changed, 183 insertions(+), 179 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/.clang-tidy
----------------------------------------------------------------------
diff --git a/src/kudu/.clang-tidy b/src/kudu/.clang-tidy
index de0a477..e94a29d 100644
--- a/src/kudu/.clang-tidy
+++ b/src/kudu/.clang-tidy
@@ -29,3 +29,7 @@ CheckOptions:
     value:           lower_case
   - key:             readability-identifier-naming.InlineNamespaceCase
     value:           lower_case
+  - key:             readability-identifier-naming.GlobalConstantCase
+    value:           CamelCase
+  - key:             readability-identifier-naming.GlobalConstantPrefix
+    value:           'k'

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/cfile/type_encodings.cc
----------------------------------------------------------------------
diff --git a/src/kudu/cfile/type_encodings.cc b/src/kudu/cfile/type_encodings.cc
index fbb9036..3eae786 100644
--- a/src/kudu/cfile/type_encodings.cc
+++ b/src/kudu/cfile/type_encodings.cc
@@ -46,8 +46,8 @@ struct DataTypeEncodingTraits {};
 template<DataType Type, EncodingType Encoding> struct TypeEncodingTraits
   : public DataTypeEncodingTraits<Type, Encoding> {
 
-  static const DataType type = Type;
-  static const EncodingType encoding_type = Encoding;
+  static const DataType kType = Type;
+  static const EncodingType kEncodingType = Encoding;
 };
 
 // Generic, fallback, partial specialization that should work for all
@@ -185,7 +185,7 @@ struct DataTypeEncodingTraits<IntType, RLE> {
 
 template<typename TypeEncodingTraitsClass>
 TypeEncodingInfo::TypeEncodingInfo(TypeEncodingTraitsClass t)
-    : encoding_type_(TypeEncodingTraitsClass::encoding_type),
+    : encoding_type_(TypeEncodingTraitsClass::kEncodingType),
       create_builder_func_(TypeEncodingTraitsClass::CreateBlockBuilder),
       create_decoder_func_(TypeEncodingTraitsClass::CreateBlockDecoder) {
 }

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/client/meta_cache.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/meta_cache.cc b/src/kudu/client/meta_cache.cc
index b58f45c..398a395 100644
--- a/src/kudu/client/meta_cache.cc
+++ b/src/kudu/client/meta_cache.cc
@@ -71,7 +71,7 @@ namespace client {
 namespace internal {
 
 namespace {
-const int MAX_RETURNED_TABLE_LOCATIONS = 10;
+const int kMaxReturnedTableLocations = 10;
 } // anonymous namespace
 
 ////////////////////////////////////////////////////////////
@@ -651,7 +651,7 @@ void LookupRpc::SendRpc() {
   // Fill out the request.
   req_.mutable_table()->set_table_id(table_->id());
   req_.set_partition_key_start(partition_key_);
-  req_.set_max_returned_locations(MAX_RETURNED_TABLE_LOCATIONS);
+  req_.set_max_returned_locations(kMaxReturnedTableLocations);
 
   // The end partition key is left unset intentionally so that we'll prefetch
   // some additional tablets.
@@ -910,7 +910,7 @@ Status MetaCache::ProcessLookupResponse(const LookupRpc& rpc,
       InsertOrDie(&tablets_by_key, tablet_lower_bound, std::move(entry));
     }
 
-    if (!last_upper_bound.empty() && tablet_locations.size() < MAX_RETURNED_TABLE_LOCATIONS) {
+    if (!last_upper_bound.empty() && tablet_locations.size() < kMaxReturnedTableLocations) {
       // There is a non-covered range between the last tablet and the end of the
       // partition key space, such as F.
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/fs/log_block_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/log_block_manager.cc b/src/kudu/fs/log_block_manager.cc
index 8ca0a16..9565b5f 100644
--- a/src/kudu/fs/log_block_manager.cc
+++ b/src/kudu/fs/log_block_manager.cc
@@ -1382,7 +1382,7 @@ static const char* kBlockManagerType = "log";
 
 // These values were arrived at via experimentation. See commit 4923a74 for
 // more details.
-const map<int64_t, int64_t> LogBlockManager::per_fs_block_size_block_limits({
+const map<int64_t, int64_t> LogBlockManager::kPerFsBlockSizeBlockLimits({
   { 1024, 673 },
   { 2048, 1353 },
   { 4096, 2721 }});
@@ -1477,7 +1477,7 @@ Status LogBlockManager::Open(FsReport* report) {
         uint64_t fs_block_size =
             dd->instance()->metadata()->filesystem_block_size_bytes();
         bool untested_block_size =
-            !ContainsKey(per_fs_block_size_block_limits, fs_block_size);
+            !ContainsKey(kPerFsBlockSizeBlockLimits, fs_block_size);
         string msg = Substitute(
             "Data dir $0 is on an ext4 filesystem vulnerable to KUDU-1508 "
             "with $1block size $2", dd->dir(),
@@ -2368,7 +2368,7 @@ bool LogBlockManager::IsBuggyEl6Kernel(const string& kernel_release) {
 }
 
 int64_t LogBlockManager::LookupBlockLimit(int64_t fs_block_size) {
-  const int64_t* limit = FindFloorOrNull(per_fs_block_size_block_limits,
+  const int64_t* limit = FindFloorOrNull(kPerFsBlockSizeBlockLimits,
                                          fs_block_size);
   if (limit) {
     return *limit;
@@ -2376,7 +2376,7 @@ int64_t LogBlockManager::LookupBlockLimit(int64_t fs_block_size) {
 
   // Block size must have been less than the very first key. Return the
   // first recorded entry and hope for the best.
-  return per_fs_block_size_block_limits.begin()->second;
+  return kPerFsBlockSizeBlockLimits.begin()->second;
 }
 
 } // namespace fs

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/fs/log_block_manager.h
----------------------------------------------------------------------
diff --git a/src/kudu/fs/log_block_manager.h b/src/kudu/fs/log_block_manager.h
index eead3d2..ad6b7cf 100644
--- a/src/kudu/fs/log_block_manager.h
+++ b/src/kudu/fs/log_block_manager.h
@@ -338,7 +338,7 @@ class LogBlockManager : public BlockManager {
   // Returns whether the given kernel release is vulnerable to KUDU-1508.
   static bool IsBuggyEl6Kernel(const std::string& kernel_release);
 
-  // Finds an appropriate block limit from 'per_fs_block_size_block_limits'
+  // Finds an appropriate block limit from 'kPerFsBlockSizeBlockLimits'
   // using the given filesystem block size.
   static int64_t LookupBlockLimit(int64_t fs_block_size);
 
@@ -346,7 +346,7 @@ class LogBlockManager : public BlockManager {
 
   // For kernels affected by KUDU-1508, tracks a known good upper bound on the
   // number of blocks per container, given a particular filesystem block size.
-  static const std::map<int64_t, int64_t> per_fs_block_size_block_limits;
+  static const std::map<int64_t, int64_t> kPerFsBlockSizeBlockLimits;
 
   // Tracks memory consumption of any allocations numerous enough to be
   // interesting (e.g. LogBlocks).

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/gutil/strings/escaping.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/strings/escaping.cc b/src/kudu/gutil/strings/escaping.cc
index cf49359..7b03335 100644
--- a/src/kudu/gutil/strings/escaping.cc
+++ b/src/kudu/gutil/strings/escaping.cc
@@ -1639,7 +1639,7 @@ void TenHexDigitsToEightBase32Digits(const char *in, char *out) {
 // ----------------------------------------------------------------------
 // EscapeFileName / UnescapeFileName
 // ----------------------------------------------------------------------
-static const Charmap escape_file_name_exceptions(
+static const Charmap kEscapeFileNameExceptions(
     "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"  // letters
     "0123456789"  // digits
     "-_.");
@@ -1651,7 +1651,7 @@ void EscapeFileName(const StringPiece& src, string* dst) {
   for (char c : src) {
     // We do not use "isalpha" because we want the behavior to be
     // independent of the current locale settings.
-    if (escape_file_name_exceptions.contains(c)) {
+    if (kEscapeFileNameExceptions.contains(c)) {
       dst->push_back(c);
 
     } else if (c == '/') {

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/gutil/strings/substitute.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/strings/substitute.cc b/src/kudu/gutil/strings/substitute.cc
index 245894b..5e5c12a 100644
--- a/src/kudu/gutil/strings/substitute.cc
+++ b/src/kudu/gutil/strings/substitute.cc
@@ -13,13 +13,13 @@ namespace strings {
 
 using internal::SubstituteArg;
 
-const SubstituteArg SubstituteArg::NoArg;
+const SubstituteArg SubstituteArg::kNoArg;
 
 // Returns the number of args in arg_array which were passed explicitly
 // to Substitute().
 static int CountSubstituteArgs(const SubstituteArg* const* args_array) {
   int count = 0;
-  while (args_array[count] != &SubstituteArg::NoArg) {
+  while (args_array[count] != &SubstituteArg::kNoArg) {
     ++count;
   }
   return count;

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/gutil/strings/substitute.h
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/strings/substitute.h b/src/kudu/gutil/strings/substitute.h
index 0812c3f..2de5960 100644
--- a/src/kudu/gutil/strings/substitute.h
+++ b/src/kudu/gutil/strings/substitute.h
@@ -131,7 +131,7 @@ class SubstituteArg {
   inline int size() const { return size_; }
 
   // Indicates that no argument was given.
-  static const SubstituteArg NoArg;
+  static const SubstituteArg kNoArg;
 
  private:
   inline SubstituteArg() : text_(NULL), size_(-1) {}
@@ -158,29 +158,29 @@ char* SubstituteToBuffer(StringPiece format,
 
 void SubstituteAndAppend(
   string* output, StringPiece format,
-  const internal::SubstituteArg& arg0 = internal::SubstituteArg::NoArg,
-  const internal::SubstituteArg& arg1 = internal::SubstituteArg::NoArg,
-  const internal::SubstituteArg& arg2 = internal::SubstituteArg::NoArg,
-  const internal::SubstituteArg& arg3 = internal::SubstituteArg::NoArg,
-  const internal::SubstituteArg& arg4 = internal::SubstituteArg::NoArg,
-  const internal::SubstituteArg& arg5 = internal::SubstituteArg::NoArg,
-  const internal::SubstituteArg& arg6 = internal::SubstituteArg::NoArg,
-  const internal::SubstituteArg& arg7 = internal::SubstituteArg::NoArg,
-  const internal::SubstituteArg& arg8 = internal::SubstituteArg::NoArg,
-  const internal::SubstituteArg& arg9 = internal::SubstituteArg::NoArg);
+  const internal::SubstituteArg& arg0 = internal::SubstituteArg::kNoArg,
+  const internal::SubstituteArg& arg1 = internal::SubstituteArg::kNoArg,
+  const internal::SubstituteArg& arg2 = internal::SubstituteArg::kNoArg,
+  const internal::SubstituteArg& arg3 = internal::SubstituteArg::kNoArg,
+  const internal::SubstituteArg& arg4 = internal::SubstituteArg::kNoArg,
+  const internal::SubstituteArg& arg5 = internal::SubstituteArg::kNoArg,
+  const internal::SubstituteArg& arg6 = internal::SubstituteArg::kNoArg,
+  const internal::SubstituteArg& arg7 = internal::SubstituteArg::kNoArg,
+  const internal::SubstituteArg& arg8 = internal::SubstituteArg::kNoArg,
+  const internal::SubstituteArg& arg9 = internal::SubstituteArg::kNoArg);
 
 inline string Substitute(
   StringPiece format,
-  const internal::SubstituteArg& arg0 = internal::SubstituteArg::NoArg,
-  const internal::SubstituteArg& arg1 = internal::SubstituteArg::NoArg,
-  const internal::SubstituteArg& arg2 = internal::SubstituteArg::NoArg,
-  const internal::SubstituteArg& arg3 = internal::SubstituteArg::NoArg,
-  const internal::SubstituteArg& arg4 = internal::SubstituteArg::NoArg,
-  const internal::SubstituteArg& arg5 = internal::SubstituteArg::NoArg,
-  const internal::SubstituteArg& arg6 = internal::SubstituteArg::NoArg,
-  const internal::SubstituteArg& arg7 = internal::SubstituteArg::NoArg,
-  const internal::SubstituteArg& arg8 = internal::SubstituteArg::NoArg,
-  const internal::SubstituteArg& arg9 = internal::SubstituteArg::NoArg) {
+  const internal::SubstituteArg& arg0 = internal::SubstituteArg::kNoArg,
+  const internal::SubstituteArg& arg1 = internal::SubstituteArg::kNoArg,
+  const internal::SubstituteArg& arg2 = internal::SubstituteArg::kNoArg,
+  const internal::SubstituteArg& arg3 = internal::SubstituteArg::kNoArg,
+  const internal::SubstituteArg& arg4 = internal::SubstituteArg::kNoArg,
+  const internal::SubstituteArg& arg5 = internal::SubstituteArg::kNoArg,
+  const internal::SubstituteArg& arg6 = internal::SubstituteArg::kNoArg,
+  const internal::SubstituteArg& arg7 = internal::SubstituteArg::kNoArg,
+  const internal::SubstituteArg& arg8 = internal::SubstituteArg::kNoArg,
+  const internal::SubstituteArg& arg9 = internal::SubstituteArg::kNoArg) {
   string result;
   SubstituteAndAppend(&result, format, arg0, arg1, arg2, arg3, arg4,
                                        arg5, arg6, arg7, arg8, arg9);

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/integration-tests/all_types-itest.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/all_types-itest.cc b/src/kudu/integration-tests/all_types-itest.cc
index cb3147e..b5e5ac7 100644
--- a/src/kudu/integration-tests/all_types-itest.cc
+++ b/src/kudu/integration-tests/all_types-itest.cc
@@ -37,7 +37,7 @@ using sp::shared_ptr;
 
 static const int kNumTabletServers = 3;
 static const int kNumTablets = 3;
-static const int KMaxBatchSize = 8 * 1024 * 1024;
+static const int kMaxBatchSize = 8 * 1024 * 1024;
 
 template<typename KeyTypeWrapper>
 struct SliceKeysTestSetup {
@@ -50,7 +50,7 @@ struct SliceKeysTestSetup {
 
   void AddKeyColumnsToSchema(KuduSchemaBuilder* builder) const {
     builder->AddColumn("key")->Type(
-        client::FromInternalDataType(KeyTypeWrapper::type))->NotNull()->PrimaryKey();
+        client::FromInternalDataType(KeyTypeWrapper::kType))->NotNull()->PrimaryKey();
   }
 
   // Split points are calculated by equally partitioning the int64_t key space and then
@@ -67,7 +67,7 @@ struct SliceKeysTestSetup {
     for (string val : splits) {
       Slice slice(val);
       KuduPartialRow* row = schema.NewRow();
-      CHECK_OK(row->SetSliceCopy<TypeTraits<KeyTypeWrapper::type> >(0, slice));
+      CHECK_OK(row->SetSliceCopy<TypeTraits<KeyTypeWrapper::kType> >(0, slice));
       rows.push_back(row);
     }
     return rows;
@@ -77,7 +77,7 @@ struct SliceKeysTestSetup {
     int row_key_num = (split_idx * increment_) + row_idx;
     string row_key = StringPrintf("%08x", row_key_num);
     Slice row_key_slice(row_key);
-    return insert->mutable_row()->SetSliceCopy<TypeTraits<KeyTypeWrapper::type> >(0,
+    return insert->mutable_row()->SetSliceCopy<TypeTraits<KeyTypeWrapper::kType> >(0,
                                                                                   row_key_slice);
   }
 
@@ -95,7 +95,7 @@ struct SliceKeysTestSetup {
 
   Status VerifyRowKey(const KuduRowResult& result, int split_idx, int row_idx) const {
     Slice row_key;
-    RETURN_NOT_OK(result.Get<TypeTraits<KeyTypeWrapper::type>>(0, &row_key));
+    RETURN_NOT_OK(result.Get<TypeTraits<KeyTypeWrapper::kType>>(0, &row_key));
     return VerifyRowKeySlice(row_key, split_idx, row_idx);
   }
 
@@ -125,7 +125,7 @@ struct SliceKeysTestSetup {
 
 template<typename KeyTypeWrapper>
 struct IntKeysTestSetup {
-  typedef typename TypeTraits<KeyTypeWrapper::type>::cpp_type CppType;
+  typedef typename TypeTraits<KeyTypeWrapper::kType>::cpp_type CppType;
 
   IntKeysTestSetup()
      // If CppType is actually bigger than int (e.g. int64_t) casting the max to int
@@ -139,7 +139,7 @@ struct IntKeysTestSetup {
 
   void AddKeyColumnsToSchema(KuduSchemaBuilder* builder) const {
     builder->AddColumn("key")->Type(
-        client::FromInternalDataType(KeyTypeWrapper::type))->NotNull()->PrimaryKey();
+        client::FromInternalDataType(KeyTypeWrapper::kType))->NotNull()->PrimaryKey();
   }
 
   vector<const KuduPartialRow*> GenerateSplitRows(const KuduSchema& schema) const {
@@ -151,7 +151,7 @@ struct IntKeysTestSetup {
     vector<const KuduPartialRow*> rows;
     for (CppType val : splits) {
       KuduPartialRow* row = schema.NewRow();
-      CHECK_OK(row->Set<TypeTraits<KeyTypeWrapper::type> >(0, val));
+      CHECK_OK(row->Set<TypeTraits<KeyTypeWrapper::kType> >(0, val));
       rows.push_back(row);
     }
     return rows;
@@ -159,7 +159,7 @@ struct IntKeysTestSetup {
 
   Status GenerateRowKey(KuduInsert* insert, int split_idx, int row_idx) const {
     CppType val = (split_idx * increment_) + row_idx;
-    return insert->mutable_row()->Set<TypeTraits<KeyTypeWrapper::type> >(0, val);
+    return insert->mutable_row()->Set<TypeTraits<KeyTypeWrapper::kType> >(0, val);
   }
 
   Status VerifyIntRowKey(CppType val, int split_idx, int row_idx) const {
@@ -173,7 +173,7 @@ struct IntKeysTestSetup {
 
   Status VerifyRowKey(const KuduRowResult& result, int split_idx, int row_idx) const {
     CppType val;
-    RETURN_NOT_OK(result.Get<TypeTraits<KeyTypeWrapper::type>>(0, &val));
+    RETURN_NOT_OK(result.Get<TypeTraits<KeyTypeWrapper::kType>>(0, &val));
     return VerifyIntRowKey(val, split_idx, row_idx);
   }
 
@@ -426,7 +426,7 @@ class AllTypesItest : public KuduTest {
       }
 
       RETURN_NOT_OK(scanner_setup(&scanner));
-      RETURN_NOT_OK(scanner.SetBatchSizeBytes(KMaxBatchSize));
+      RETURN_NOT_OK(scanner.SetBatchSizeBytes(kMaxBatchSize));
       RETURN_NOT_OK(scanner.SetFaultTolerant());
       RETURN_NOT_OK(scanner.SetReadMode(KuduScanner::READ_AT_SNAPSHOT));
 
@@ -476,7 +476,7 @@ class AllTypesItest : public KuduTest {
 // without leaking DataType.
 template<DataType KeyType>
 struct KeyTypeWrapper {
-  static const DataType type = KeyType;
+  static const DataType kType = KeyType;
 };
 
 typedef ::testing::Types<IntKeysTestSetup<KeyTypeWrapper<INT8> >,

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/master/master.cc
----------------------------------------------------------------------
diff --git a/src/kudu/master/master.cc b/src/kudu/master/master.cc
index 079bd2d..2d883f6 100644
--- a/src/kudu/master/master.cc
+++ b/src/kudu/master/master.cc
@@ -89,7 +89,7 @@ Master::Master(const MasterOptions& opts)
     path_handlers_(new MasterPathHandlers(this)),
     opts_(opts),
     registration_initialized_(false),
-    maintenance_manager_(new MaintenanceManager(MaintenanceManager::DEFAULT_OPTIONS)) {
+    maintenance_manager_(new MaintenanceManager(MaintenanceManager::kDefaultOptions)) {
 }
 
 Master::~Master() {

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/rpc/protoc-gen-krpc.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/protoc-gen-krpc.cc b/src/kudu/rpc/protoc-gen-krpc.cc
index de41aa9..e892897 100644
--- a/src/kudu/rpc/protoc-gen-krpc.cc
+++ b/src/kudu/rpc/protoc-gen-krpc.cc
@@ -91,7 +91,7 @@ class Substituter {
 // NameInfo contains information about the output names.
 class FileSubstitutions : public Substituter {
  public:
-  static const std::string PROTO_EXTENSION;
+  static const std::string kProtoExtension;
 
   Status Init(const FileDescriptor *file) {
     string path = file->name();
@@ -99,9 +99,9 @@ class FileSubstitutions : public Substituter {
 
     // Initialize path_
     // If path = /foo/bar/baz_stuff.proto, path_ = /foo/bar/baz_stuff
-    if (!TryStripSuffixString(path, PROTO_EXTENSION, &path_no_extension_)) {
+    if (!TryStripSuffixString(path, kProtoExtension, &path_no_extension_)) {
       return Status::InvalidArgument("file name " + path +
-                                     " did not end in " + PROTO_EXTENSION);
+                                     " did not end in " + kProtoExtension);
     }
     map_["path_no_extension"] = path_no_extension_;
 
@@ -183,7 +183,7 @@ class FileSubstitutions : public Substituter {
   map<string, string> map_;
 };
 
-const std::string FileSubstitutions::PROTO_EXTENSION(".proto");
+const std::string FileSubstitutions::kProtoExtension(".proto");
 
 class MethodSubstitutions : public Substituter {
  public:

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/rpc/request_tracker-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/request_tracker-test.cc b/src/kudu/rpc/request_tracker-test.cc
index 89ea8a2..f39e131 100644
--- a/src/kudu/rpc/request_tracker-test.cc
+++ b/src/kudu/rpc/request_tracker-test.cc
@@ -33,7 +33,7 @@ TEST(RequestTrackerTest, TestSequenceNumberGeneration) {
 
   // A new tracker should have no incomplete RPCs
   RequestTracker::SequenceNumber seq_no = tracker_->FirstIncomplete();
-  ASSERT_EQ(seq_no, RequestTracker::NO_SEQ_NO);
+  ASSERT_EQ(seq_no, RequestTracker::kNoSeqNo);
 
   vector<RequestTracker::SequenceNumber> generated_seq_nos;
 
@@ -75,7 +75,7 @@ TEST(RequestTrackerTest, TestSequenceNumberGeneration) {
     tracker_->RpcCompleted(seq_no);
   }
 
-  ASSERT_EQ(tracker_->FirstIncomplete(), RequestTracker::NO_SEQ_NO);
+  ASSERT_EQ(tracker_->FirstIncomplete(), RequestTracker::kNoSeqNo);
 }
 
 } // namespace rpc

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/rpc/request_tracker.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/request_tracker.cc b/src/kudu/rpc/request_tracker.cc
index 1958664..84a445e 100644
--- a/src/kudu/rpc/request_tracker.cc
+++ b/src/kudu/rpc/request_tracker.cc
@@ -24,7 +24,7 @@
 namespace kudu {
 namespace rpc {
 
-const RequestTracker::SequenceNumber RequestTracker::NO_SEQ_NO = -1;
+const RequestTracker::SequenceNumber RequestTracker::kNoSeqNo = -1;
 
 RequestTracker::RequestTracker(const string& client_id)
     : client_id_(client_id),
@@ -40,7 +40,7 @@ Status RequestTracker::NewSeqNo(SequenceNumber* seq_no) {
 
 RequestTracker::SequenceNumber RequestTracker::FirstIncomplete() {
   std::lock_guard<simple_spinlock> l(lock_);
-  if (incomplete_rpcs_.empty()) return NO_SEQ_NO;
+  if (incomplete_rpcs_.empty()) return kNoSeqNo;
   return *incomplete_rpcs_.begin();
 }
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/rpc/request_tracker.h
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/request_tracker.h b/src/kudu/rpc/request_tracker.h
index 99f8d6c..9698d58 100644
--- a/src/kudu/rpc/request_tracker.h
+++ b/src/kudu/rpc/request_tracker.h
@@ -48,7 +48,7 @@ namespace rpc {
 class RequestTracker : public RefCountedThreadSafe<RequestTracker> {
  public:
   typedef int64_t SequenceNumber;
-  static const RequestTracker::SequenceNumber NO_SEQ_NO;
+  static const RequestTracker::SequenceNumber kNoSeqNo;
   explicit RequestTracker(const std::string& client_id);
 
   // Creates a new, unique, sequence number.
@@ -59,7 +59,7 @@ class RequestTracker : public RefCountedThreadSafe<RequestTracker> {
   Status NewSeqNo(SequenceNumber* seq_no);
 
   // Returns the sequence number of the first incomplete RPC.
-  // If there is no incomplete RPC returns NO_SEQ_NO.
+  // If there is no incomplete RPC returns kNoSeqNo.
   SequenceNumber FirstIncomplete();
 
   // Marks the rpc with 'seq_no' as completed.

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/rpc/retriable_rpc.h
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/retriable_rpc.h b/src/kudu/rpc/retriable_rpc.h
index c896027..897d7a7 100644
--- a/src/kudu/rpc/retriable_rpc.h
+++ b/src/kudu/rpc/retriable_rpc.h
@@ -56,11 +56,11 @@ class RetriableRpc : public Rpc {
       : Rpc(deadline, std::move(messenger)),
         server_picker_(server_picker),
         request_tracker_(request_tracker),
-        sequence_number_(RequestTracker::NO_SEQ_NO),
+        sequence_number_(RequestTracker::kNoSeqNo),
         num_attempts_(0) {}
 
   virtual ~RetriableRpc() {
-    DCHECK_EQ(sequence_number_, RequestTracker::NO_SEQ_NO);
+    DCHECK_EQ(sequence_number_, RequestTracker::kNoSeqNo);
   }
 
   // Performs server lookup/initialization.
@@ -138,7 +138,7 @@ class RetriableRpc : public Rpc {
 
 template <class Server, class RequestPB, class ResponsePB>
 void RetriableRpc<Server, RequestPB, ResponsePB>::SendRpc()  {
-  if (sequence_number_ == RequestTracker::NO_SEQ_NO) {
+  if (sequence_number_ == RequestTracker::kNoSeqNo) {
     CHECK_OK(request_tracker_->NewSeqNo(&sequence_number_));
   }
   server_picker_->PickLeader(Bind(&RetriableRpc::ReplicaFoundCb,
@@ -237,10 +237,10 @@ bool RetriableRpc<Server, RequestPB, ResponsePB>::RetryIfNeeded(
 
 template <class Server, class RequestPB, class ResponsePB>
 void RetriableRpc<Server, RequestPB, ResponsePB>::FinishInternal() {
-  // Mark the RPC as completed and set the sequence number to NO_SEQ_NO to make
+  // Mark the RPC as completed and set the sequence number to kNoSeqNo to make
   // sure we're in the appropriate state before destruction.
   request_tracker_->RpcCompleted(sequence_number_);
-  sequence_number_ = RequestTracker::NO_SEQ_NO;
+  sequence_number_ = RequestTracker::kNoSeqNo;
 }
 
 template <class Server, class RequestPB, class ResponsePB>

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/security/ca/cert_management.cc
----------------------------------------------------------------------
diff --git a/src/kudu/security/ca/cert_management.cc b/src/kudu/security/ca/cert_management.cc
index a6d7f7b..c63eb10 100644
--- a/src/kudu/security/ca/cert_management.cc
+++ b/src/kudu/security/ca/cert_management.cc
@@ -52,10 +52,10 @@ namespace kudu {
 namespace security {
 
 template<> struct SslTypeTraits<ASN1_INTEGER> {
-  static constexpr auto free = &ASN1_INTEGER_free;
+  static constexpr auto kFreeFunc = &ASN1_INTEGER_free;
 };
 template<> struct SslTypeTraits<BIGNUM> {
-  static constexpr auto free = &BN_free;
+  static constexpr auto kFreeFunc = &BN_free;
 };
 
 namespace ca {

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/security/cert.cc
----------------------------------------------------------------------
diff --git a/src/kudu/security/cert.cc b/src/kudu/security/cert.cc
index fa4c753..dabf2d3 100644
--- a/src/kudu/security/cert.cc
+++ b/src/kudu/security/cert.cc
@@ -39,7 +39,7 @@ namespace kudu {
 namespace security {
 
 template<> struct SslTypeTraits<GENERAL_NAMES> {
-  static constexpr auto free = &GENERAL_NAMES_free;
+  static constexpr auto kFreeFunc = &GENERAL_NAMES_free;
 };
 
 // This OID is generated via the UUID method.

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/security/crypto.cc
----------------------------------------------------------------------
diff --git a/src/kudu/security/crypto.cc b/src/kudu/security/crypto.cc
index 1aab6b1..cf4199e 100644
--- a/src/kudu/security/crypto.cc
+++ b/src/kudu/security/crypto.cc
@@ -64,25 +64,25 @@ int DerWritePublicKey(BIO* bio, EVP_PKEY* key) {
 } // anonymous namespace
 
 template<> struct SslTypeTraits<BIGNUM> {
-  static constexpr auto free = &BN_free;
+  static constexpr auto kFreeFunc = &BN_free;
 };
 struct RsaPrivateKeyTraits : public SslTypeTraits<EVP_PKEY> {
-  static constexpr auto read_pem = &PEM_read_bio_PrivateKey;
-  static constexpr auto read_der = &d2i_PrivateKey_bio;
-  static constexpr auto write_pem = &PemWritePrivateKey;
-  static constexpr auto write_der = &i2d_PrivateKey_bio;
+  static constexpr auto kReadPemFunc = &PEM_read_bio_PrivateKey;
+  static constexpr auto kReadDerFunc = &d2i_PrivateKey_bio;
+  static constexpr auto kWritePemFunc = &PemWritePrivateKey;
+  static constexpr auto kWriteDerFunc = &i2d_PrivateKey_bio;
 };
 struct RsaPublicKeyTraits : public SslTypeTraits<EVP_PKEY> {
-  static constexpr auto read_pem = &PEM_read_bio_PUBKEY;
-  static constexpr auto read_der = &d2i_PUBKEY_bio;
-  static constexpr auto write_pem = &PemWritePublicKey;
-  static constexpr auto write_der = &DerWritePublicKey;
+  static constexpr auto kReadPemFunc = &PEM_read_bio_PUBKEY;
+  static constexpr auto kReadDerFunc = &d2i_PUBKEY_bio;
+  static constexpr auto kWritePemFunc = &PemWritePublicKey;
+  static constexpr auto kWriteDerFunc = &DerWritePublicKey;
 };
 template<> struct SslTypeTraits<RSA> {
-  static constexpr auto free = &RSA_free;
+  static constexpr auto kFreeFunc = &RSA_free;
 };
 template<> struct SslTypeTraits<EVP_MD_CTX> {
-  static constexpr auto free = &EVP_MD_CTX_destroy;
+  static constexpr auto kFreeFunc = &EVP_MD_CTX_destroy;
 };
 
 namespace {

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/security/openssl_util.h
----------------------------------------------------------------------
diff --git a/src/kudu/security/openssl_util.h b/src/kudu/security/openssl_util.h
index db85a85..82392c1 100644
--- a/src/kudu/security/openssl_util.h
+++ b/src/kudu/security/openssl_util.h
@@ -106,32 +106,32 @@ template<typename SSL_TYPE>
 struct SslTypeTraits {};
 
 template<> struct SslTypeTraits<X509> {
-  static constexpr auto free = &X509_free;
-  static constexpr auto read_pem = &PEM_read_bio_X509;
-  static constexpr auto read_der = &d2i_X509_bio;
-  static constexpr auto write_pem = &PEM_write_bio_X509;
-  static constexpr auto write_der = &i2d_X509_bio;
+  static constexpr auto kFreeFunc = &X509_free;
+  static constexpr auto kReadPemFunc = &PEM_read_bio_X509;
+  static constexpr auto kReadDerFunc = &d2i_X509_bio;
+  static constexpr auto kWritePemFunc = &PEM_write_bio_X509;
+  static constexpr auto kWriteDerFunc = &i2d_X509_bio;
 };
 template<> struct SslTypeTraits<X509_EXTENSION> {
-  static constexpr auto free = &X509_EXTENSION_free;
+  static constexpr auto kFreeFunc = &X509_EXTENSION_free;
 };
 template<> struct SslTypeTraits<X509_REQ> {
-  static constexpr auto free = &X509_REQ_free;
-  static constexpr auto read_pem = &PEM_read_bio_X509_REQ;
-  static constexpr auto read_der = &d2i_X509_REQ_bio;
-  static constexpr auto write_pem = &PEM_write_bio_X509_REQ;
-  static constexpr auto write_der = &i2d_X509_REQ_bio;
+  static constexpr auto kFreeFunc = &X509_REQ_free;
+  static constexpr auto kReadPemFunc = &PEM_read_bio_X509_REQ;
+  static constexpr auto kReadDerFunc = &d2i_X509_REQ_bio;
+  static constexpr auto kWritePemFunc = &PEM_write_bio_X509_REQ;
+  static constexpr auto kWriteDerFunc = &i2d_X509_REQ_bio;
 };
 template<> struct SslTypeTraits<EVP_PKEY> {
-  static constexpr auto free = &EVP_PKEY_free;
+  static constexpr auto kFreeFunc = &EVP_PKEY_free;
 };
 template<> struct SslTypeTraits<SSL_CTX> {
-  static constexpr auto free = &SSL_CTX_free;
+  static constexpr auto kFreeFunc = &SSL_CTX_free;
 };
 
 template<typename SSL_TYPE, typename Traits = SslTypeTraits<SSL_TYPE>>
 c_unique_ptr<SSL_TYPE> ssl_make_unique(SSL_TYPE* d) {
-  return {d, Traits::free};
+  return {d, Traits::kFreeFunc};
 }
 
 // Acceptable formats for keys, X509 certificates and X509 CSRs.

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/security/openssl_util_bio.h
----------------------------------------------------------------------
diff --git a/src/kudu/security/openssl_util_bio.h b/src/kudu/security/openssl_util_bio.h
index 6ab6a55..d4dcc44 100644
--- a/src/kudu/security/openssl_util_bio.h
+++ b/src/kudu/security/openssl_util_bio.h
@@ -32,7 +32,7 @@ namespace kudu {
 namespace security {
 
 template<> struct SslTypeTraits<BIO> {
-  static constexpr auto free = &BIO_free;
+  static constexpr auto kFreeFunc = &BIO_free;
 };
 
 template<typename TYPE, typename Traits = SslTypeTraits<TYPE>>
@@ -41,11 +41,11 @@ Status ToBIO(BIO* bio, DataFormat format, TYPE* obj) {
   CHECK(obj);
   switch (format) {
     case DataFormat::DER:
-      OPENSSL_RET_NOT_OK(Traits::write_der(bio, obj),
+      OPENSSL_RET_NOT_OK(Traits::kWriteDerFunc(bio, obj),
           "error exporting data in DER format");
       break;
     case DataFormat::PEM:
-      OPENSSL_RET_NOT_OK(Traits::write_pem(bio, obj),
+      OPENSSL_RET_NOT_OK(Traits::kWritePemFunc(bio, obj),
           "error exporting data in PEM format");
       break;
   }
@@ -58,10 +58,10 @@ Status FromBIO(BIO* bio, DataFormat format, c_unique_ptr<TYPE>* ret) {
   CHECK(bio);
   switch (format) {
     case DataFormat::DER:
-      *ret = ssl_make_unique(Traits::read_der(bio, nullptr));
+      *ret = ssl_make_unique(Traits::kReadDerFunc(bio, nullptr));
       break;
     case DataFormat::PEM:
-      *ret = ssl_make_unique(Traits::read_pem(bio, nullptr, nullptr, nullptr));
+      *ret = ssl_make_unique(Traits::kReadPemFunc(bio, nullptr, nullptr, nullptr));
       break;
   }
   if (PREDICT_FALSE(!*ret)) {

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/security/tls_context.cc
----------------------------------------------------------------------
diff --git a/src/kudu/security/tls_context.cc b/src/kudu/security/tls_context.cc
index f28f31e..23b3d04 100644
--- a/src/kudu/security/tls_context.cc
+++ b/src/kudu/security/tls_context.cc
@@ -82,10 +82,10 @@ namespace security {
 using ca::CertRequestGenerator;
 
 template<> struct SslTypeTraits<SSL> {
-  static constexpr auto free = &SSL_free;
+  static constexpr auto kFreeFunc = &SSL_free;
 };
 template<> struct SslTypeTraits<X509_STORE_CTX> {
-  static constexpr auto free = &X509_STORE_CTX_free;
+  static constexpr auto kFreeFunc = &X509_STORE_CTX_free;
 };
 
 TlsContext::TlsContext()

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/server/pprof-path-handlers.cc
----------------------------------------------------------------------
diff --git a/src/kudu/server/pprof-path-handlers.cc b/src/kudu/server/pprof-path-handlers.cc
index ade01da..eb4071f 100644
--- a/src/kudu/server/pprof-path-handlers.cc
+++ b/src/kudu/server/pprof-path-handlers.cc
@@ -61,7 +61,7 @@ bool Symbolize(void *pc, char *out, int out_size);
 
 namespace kudu {
 
-const int PPROF_DEFAULT_SAMPLE_SECS = 30; // pprof default sample time in seconds.
+const int kPprofDefaultSampleSecs = 30; // pprof default sample time in seconds.
 
 // pprof asks for the url /pprof/cmdline to figure out what application it's profiling.
 // The server should respond by sending the executable path.
@@ -86,7 +86,7 @@ static void PprofHeapHandler(const Webserver::WebRequest& req, ostringstream* ou
   }
 
   auto it = req.parsed_args.find("seconds");
-  int seconds = PPROF_DEFAULT_SAMPLE_SECS;
+  int seconds = kPprofDefaultSampleSecs;
   if (it != req.parsed_args.end()) {
     seconds = atoi(it->second.c_str());
   }
@@ -109,7 +109,7 @@ static void PprofCpuProfileHandler(const Webserver::WebRequest& req, ostringstre
   (*output) << "CPU profiling is not available without tcmalloc.";
 #else
   auto it = req.parsed_args.find("seconds");
-  int seconds = PPROF_DEFAULT_SAMPLE_SECS;
+  int seconds = kPprofDefaultSampleSecs;
   if (it != req.parsed_args.end()) {
     seconds = atoi(it->second.c_str());
   }
@@ -144,7 +144,7 @@ static void PprofGrowthHandler(const Webserver::WebRequest& req, ostringstream*
 // Lock contention profiling
 static void PprofContentionHandler(const Webserver::WebRequest& req, ostringstream* output) {
   string secs_str = FindWithDefault(req.parsed_args, "seconds", "");
-  int32_t seconds = ParseLeadingInt32Value(secs_str.c_str(), PPROF_DEFAULT_SAMPLE_SECS);
+  int32_t seconds = ParseLeadingInt32Value(secs_str.c_str(), kPprofDefaultSampleSecs);
   int64_t discarded_samples = 0;
 
   *output << "--- contention" << endl;

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/server/webserver.cc
----------------------------------------------------------------------
diff --git a/src/kudu/server/webserver.cc b/src/kudu/server/webserver.cc
index 67fe64e..2c35402 100644
--- a/src/kudu/server/webserver.cc
+++ b/src/kudu/server/webserver.cc
@@ -459,7 +459,7 @@ void Webserver::RegisterPathHandler(const string& path, const string& alias,
   it->second->AddCallback(callback);
 }
 
-const char* const PAGE_HEADER = "<!DOCTYPE html>"
+const char* const kPageHeader = "<!DOCTYPE html>"
 " <html>"
 "   <head><title>Kudu</title>"
 " <meta charset='utf-8'/>"
@@ -470,7 +470,7 @@ const char* const PAGE_HEADER = "<!DOCTYPE html>"
 " </head>"
 " <body>";
 
-static const char* const NAVIGATION_BAR_PREFIX =
+static const char* const kNavigationBarPrefix =
 "<div class='navbar navbar-inverse navbar-fixed-top'>"
 "      <div class='navbar-inner'>"
 "        <div class='container-fluid'>"
@@ -480,7 +480,7 @@ static const char* const NAVIGATION_BAR_PREFIX =
 "          <div class='nav-collapse collapse'>"
 "            <ul class='nav'>";
 
-static const char* const NAVIGATION_BAR_SUFFIX =
+static const char* const kNavigationBarSuffix =
 "            </ul>"
 "          </div>"
 "        </div>"
@@ -489,15 +489,15 @@ static const char* const NAVIGATION_BAR_SUFFIX =
 "    <div class='container-fluid'>";
 
 void Webserver::BootstrapPageHeader(ostringstream* output) {
-  (*output) << PAGE_HEADER;
-  (*output) << NAVIGATION_BAR_PREFIX;
+  (*output) << kPageHeader;
+  (*output) << kNavigationBarPrefix;
   for (const PathHandlerMap::value_type& handler : path_handlers_) {
     if (handler.second->is_on_nav_bar()) {
       (*output) << "<li><a href=\"" << handler.first << "\">" << handler.second->alias()
                 << "</a></li>";
     }
   }
-  (*output) << NAVIGATION_BAR_SUFFIX;
+  (*output) << kNavigationBarSuffix;
 
   if (!static_pages_available()) {
     (*output) << "<div style=\"color: red\"><strong>"

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/tablet/all_types-scan-correctness-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/all_types-scan-correctness-test.cc b/src/kudu/tablet/all_types-scan-correctness-test.cc
index 9f98730..73ebd45 100644
--- a/src/kudu/tablet/all_types-scan-correctness-test.cc
+++ b/src/kudu/tablet/all_types-scan-correctness-test.cc
@@ -66,7 +66,7 @@ struct RowOpsBase {
 
 template<typename KeyTypeWrapper>
 struct SliceTypeRowOps : public RowOpsBase {
-  SliceTypeRowOps() : RowOpsBase(KeyTypeWrapper::type, KeyTypeWrapper::encoding),
+  SliceTypeRowOps() : RowOpsBase(KeyTypeWrapper::kType, KeyTypeWrapper::kEncoding),
     strs_(kNumAllocatedElements), slices_(kNumAllocatedElements), cur(0) {}
 
   // Assumes the string representation of n is under strlen characters.
@@ -88,10 +88,10 @@ struct SliceTypeRowOps : public RowOpsBase {
       Slice slice_a(string_a);
       Slice slice_b(string_b);
       Slice slice_c(string_c);
-      CHECK_OK(row->SetSliceCopy<TypeTraits<KeyTypeWrapper::type>>(kColA, slice_a));
-      CHECK_OK(row->SetSliceCopy<TypeTraits<KeyTypeWrapper::type>>(kColB, slice_b));
+      CHECK_OK(row->SetSliceCopy<TypeTraits<KeyTypeWrapper::kType>>(kColA, slice_a));
+      CHECK_OK(row->SetSliceCopy<TypeTraits<KeyTypeWrapper::kType>>(kColB, slice_b));
       if (altered) {
-        CHECK_OK(row->SetSliceCopy<TypeTraits<KeyTypeWrapper::type>>(kColC, slice_c));
+        CHECK_OK(row->SetSliceCopy<TypeTraits<KeyTypeWrapper::kType>>(kColC, slice_c));
       }
     }
   }
@@ -122,10 +122,10 @@ struct SliceTypeRowOps : public RowOpsBase {
 
 template<typename KeyTypeWrapper>
 struct NumTypeRowOps : public RowOpsBase {
-  NumTypeRowOps() : RowOpsBase(KeyTypeWrapper::type, KeyTypeWrapper::encoding),
+  NumTypeRowOps() : RowOpsBase(KeyTypeWrapper::kType, KeyTypeWrapper::kEncoding),
     nums_(kNumAllocatedElements), cur(0) {}
 
-  typedef typename TypeTraits<KeyTypeWrapper::type>::cpp_type CppType;
+  typedef typename TypeTraits<KeyTypeWrapper::kType>::cpp_type CppType;
 
   void GenerateRow(int value, bool altered, KuduPartialRow* row) {
     if (value < 0) {
@@ -135,10 +135,10 @@ struct NumTypeRowOps : public RowOpsBase {
         CHECK_OK(row->SetNull(kColC));
       }
     } else {
-      row->Set<TypeTraits<KeyTypeWrapper::type>>(kColA, value);
-      row->Set<TypeTraits<KeyTypeWrapper::type>>(kColB, value);
+      row->Set<TypeTraits<KeyTypeWrapper::kType>>(kColA, value);
+      row->Set<TypeTraits<KeyTypeWrapper::kType>>(kColB, value);
       if (altered) {
-        row->Set<TypeTraits<KeyTypeWrapper::type>>(kColC, value);
+        row->Set<TypeTraits<KeyTypeWrapper::kType>>(kColC, value);
       }
     }
   }
@@ -537,8 +537,8 @@ protected:
 
 template<DataType KeyType, EncodingType Encoding>
 struct KeyTypeWrapper {
-  static const DataType type = KeyType;
-  static const EncodingType encoding = Encoding;
+  static const DataType kType = KeyType;
+  static const EncodingType kEncoding = Encoding;
 };
 
 typedef ::testing::Types<NumTypeRowOps<KeyTypeWrapper<INT8, BIT_SHUFFLE>>,

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/tablet/cbtree-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/cbtree-test.cc b/src/kudu/tablet/cbtree-test.cc
index 5f5fb9d..b60161a 100644
--- a/src/kudu/tablet/cbtree-test.cc
+++ b/src/kudu/tablet/cbtree-test.cc
@@ -85,10 +85,10 @@ TEST_F(TestCBTree, TestNodeSizes) {
   ThreadSafeArena arena(1024, 1024);
 
   LeafNode<BTreeTraits> lnode(false);
-  ASSERT_LE(sizeof(lnode), BTreeTraits::leaf_node_size);
+  ASSERT_LE(sizeof(lnode), BTreeTraits::kLeafNodeSize);
 
   InternalNode<BTreeTraits> inode(Slice("split"), &lnode, &lnode, &arena);
-  ASSERT_LE(sizeof(inode), BTreeTraits::internal_node_size);
+  ASSERT_LE(sizeof(inode), BTreeTraits::kInternalNodeSize);
 
 }
 
@@ -157,15 +157,15 @@ TEST_F(TestCBTree, TestLeafNodeBigKVs) {
 // splitting, etc.
 struct SmallFanoutTraits : public BTreeTraits {
 
-  static const size_t internal_node_size = 84;
-  static const size_t leaf_node_size = 92;
+  static const size_t kInternalNodeSize = 84;
+  static const size_t kLeafNodeSize = 92;
 };
 
 // Enables yield() calls at interesting points of the btree
 // implementation to ensure that we are still correct even
 // with adversarial scheduling.
 struct RacyTraits : public SmallFanoutTraits {
-  static const size_t debug_raciness = 100;
+  static const size_t kDebugRaciness = 100;
 };
 
 void MakeKey(char *kbuf, size_t len, int i) {

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/tablet/concurrent_btree.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/concurrent_btree.h b/src/kudu/tablet/concurrent_btree.h
index b4c5012..ac7e536 100644
--- a/src/kudu/tablet/concurrent_btree.h
+++ b/src/kudu/tablet/concurrent_btree.h
@@ -77,15 +77,15 @@ namespace btree {
 struct BTreeTraits {
   enum TraitConstants {
     // Number of bytes used per internal node.
-    internal_node_size = 4 * CACHELINE_SIZE,
+    kInternalNodeSize = 4 * CACHELINE_SIZE,
 
     // Number of bytes used by a leaf node.
-    leaf_node_size = 4 * CACHELINE_SIZE,
+    kLeafNodeSize = 4 * CACHELINE_SIZE,
 
     // Tests can set this trait to a non-zero value, which inserts
     // some pause-loops in key parts of the code to try to simulate
     // races.
-    debug_raciness = 0
+    kDebugRaciness = 0
   };
   typedef ThreadSafeArena ArenaType;
 };
@@ -106,8 +106,8 @@ inline void PrefetchMemory(const T *addr) {
 // will compile away in production code.
 template<class Traits>
 void DebugRacyPoint() {
-  if (Traits::debug_raciness > 0) {
-    boost::detail::yield(Traits::debug_raciness);
+  if (Traits::kDebugRaciness > 0) {
+    boost::detail::yield(Traits::kDebugRaciness);
   }
 }
 
@@ -656,7 +656,7 @@ class PACKED InternalNode : public NodeBase<Traits> {
   enum SpaceConstants {
     constant_overhead = sizeof(NodeBase<Traits>) // base class
                       + sizeof(uint32_t), // num_children_
-    keyptr_space = Traits::internal_node_size - constant_overhead,
+    keyptr_space = Traits::kInternalNodeSize - constant_overhead,
     kFanout = keyptr_space / (sizeof(KeyInlineSlice) + sizeof(NodePtr<Traits>))
   };
 
@@ -809,7 +809,7 @@ class LeafNode : public NodeBase<Traits> {
     constant_overhead = sizeof(NodeBase<Traits>) // base class
                         + sizeof(LeafNode<Traits>*) // next_
                         + sizeof(uint8_t), // num_entries_
-    kv_space = Traits::leaf_node_size - constant_overhead,
+    kv_space = Traits::kLeafNodeSize - constant_overhead,
     kMaxEntries = kv_space / (sizeof(KeyInlineSlice) + sizeof(ValueSlice))
   };
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/tserver/tablet_server.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_server.cc b/src/kudu/tserver/tablet_server.cc
index 20bde34..800ff10 100644
--- a/src/kudu/tserver/tablet_server.cc
+++ b/src/kudu/tserver/tablet_server.cc
@@ -49,7 +49,7 @@ TabletServer::TabletServer(const TabletServerOptions& opts)
     tablet_manager_(new TSTabletManager(fs_manager_.get(), this, metric_registry())),
     scanner_manager_(new ScannerManager(metric_entity())),
     path_handlers_(new TabletServerPathHandlers(this)),
-    maintenance_manager_(new MaintenanceManager(MaintenanceManager::DEFAULT_OPTIONS)) {
+    maintenance_manager_(new MaintenanceManager(MaintenanceManager::kDefaultOptions)) {
 }
 
 TabletServer::~TabletServer() {

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/util/debug/trace_event_impl.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/debug/trace_event_impl.cc b/src/kudu/util/debug/trace_event_impl.cc
index 122cad1..f976c87 100644
--- a/src/kudu/util/debug/trace_event_impl.cc
+++ b/src/kudu/util/debug/trace_event_impl.cc
@@ -80,12 +80,12 @@ const char* g_category_groups[MAX_CATEGORY_GROUPS] = {
 // The enabled flag is char instead of bool so that the API can be used from C.
 unsigned char g_category_group_enabled[MAX_CATEGORY_GROUPS] = { 0 };
 // Indexes here have to match the g_category_groups array indexes above.
-const int g_category_already_shutdown = 1;
-const int g_category_categories_exhausted = 2;
-const int g_category_metadata = 3;
-const int g_num_builtin_categories = 4;
+const int kCategoryAlreadyShutdown = 1;
+const int kCategoryCategoriesExhausted = 2;
+const int kCategoryMetadata = 3;
+const int kNumBuiltinCategories = 4;
 // Skip default categories.
-AtomicWord g_category_index = g_num_builtin_categories;
+AtomicWord g_category_index = kNumBuiltinCategories;
 
 // The name of the current thread. This is used to decide if the current
 // thread name has changed. We combine all the seen thread names into the
@@ -366,7 +366,7 @@ void InitializeMetadataEvent(TraceEvent* trace_event,
   ::trace_event_internal::SetTraceValue(value, &arg_type, &arg_value);
   trace_event->Initialize(thread_id,
                           MicrosecondsInt64(0), MicrosecondsInt64(0), TRACE_EVENT_PHASE_METADATA,
-                          &g_category_group_enabled[g_category_metadata],
+                          &g_category_group_enabled[kCategoryMetadata],
                           metadata_name, ::trace_event_internal::kNoEventId,
                           num_args, &arg_name, &arg_type, &arg_value, nullptr,
                           TRACE_EVENT_FLAG_NONE);
@@ -1147,8 +1147,8 @@ const unsigned char* TraceLog::GetCategoryGroupEnabled(
     const char* category_group) {
   TraceLog* tracelog = GetInstance();
   if (!tracelog) {
-    DCHECK(!g_category_group_enabled[g_category_already_shutdown]);
-    return &g_category_group_enabled[g_category_already_shutdown];
+    DCHECK(!g_category_group_enabled[kCategoryAlreadyShutdown]);
+    return &g_category_group_enabled[kCategoryAlreadyShutdown];
   }
   return tracelog->GetCategoryGroupEnabledInternal(category_group);
 }
@@ -1267,7 +1267,7 @@ const unsigned char* TraceLog::GetCategoryGroupEnabledInternal(
     base::subtle::Release_Store(&g_category_index, category_index + 1);
   } else {
     category_group_enabled =
-        &g_category_group_enabled[g_category_categories_exhausted];
+        &g_category_group_enabled[kCategoryCategoriesExhausted];
   }
   return category_group_enabled;
 }
@@ -1276,7 +1276,7 @@ void TraceLog::GetKnownCategoryGroups(
     std::vector<std::string>* category_groups) {
   SpinLockHolder lock(&lock_);
   int category_index = base::subtle::NoBarrier_Load(&g_category_index);
-  for (int i = g_num_builtin_categories; i < category_index; i++)
+  for (int i = kNumBuiltinCategories; i < category_index; i++)
     category_groups->push_back(g_category_groups[i]);
 }
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/util/maintenance_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/maintenance_manager.cc b/src/kudu/util/maintenance_manager.cc
index 18ed8b8..b410646 100644
--- a/src/kudu/util/maintenance_manager.cc
+++ b/src/kudu/util/maintenance_manager.cc
@@ -111,7 +111,7 @@ void MaintenanceOp::Unregister() {
   manager_->UnregisterOp(this);
 }
 
-const MaintenanceManager::Options MaintenanceManager::DEFAULT_OPTIONS = {
+const MaintenanceManager::Options MaintenanceManager::kDefaultOptions = {
   .num_threads = 0,
   .polling_interval_ms = 0,
   .history_size = 0,

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/util/maintenance_manager.h
----------------------------------------------------------------------
diff --git a/src/kudu/util/maintenance_manager.h b/src/kudu/util/maintenance_manager.h
index 6070e2d..1d2419a 100644
--- a/src/kudu/util/maintenance_manager.h
+++ b/src/kudu/util/maintenance_manager.h
@@ -282,7 +282,7 @@ class MaintenanceManager : public std::enable_shared_from_this<MaintenanceManage
     memory_pressure_func_ = std::move(f);
   }
 
-  static const Options DEFAULT_OPTIONS;
+  static const Options kDefaultOptions;
 
  private:
   FRIEND_TEST(MaintenanceManagerTest, TestLogRetentionPrioritization);

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/util/mem_tracker-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/mem_tracker-test.cc b/src/kudu/util/mem_tracker-test.cc
index 7e78cbe..075931a 100644
--- a/src/kudu/util/mem_tracker-test.cc
+++ b/src/kudu/util/mem_tracker-test.cc
@@ -112,11 +112,11 @@ TEST(MemTrackerTest, TrackerHierarchy) {
 
 class GcFunctionHelper {
  public:
-  static const int NUM_RELEASE_BYTES = 1;
+  static const int kNumReleaseBytes = 1;
 
   explicit GcFunctionHelper(MemTracker* tracker) : tracker_(tracker) { }
 
-  void GcFunc() { tracker_->Release(NUM_RELEASE_BYTES); }
+  void GcFunc() { tracker_->Release(kNumReleaseBytes); }
 
  private:
   MemTracker* tracker_;

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/util/os-util.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/os-util.cc b/src/kudu/util/os-util.cc
index 8874bd8..9ea7e08 100644
--- a/src/kudu/util/os-util.cc
+++ b/src/kudu/util/os-util.cc
@@ -51,18 +51,18 @@ namespace kudu {
 #define _SC_CLK_TCK 2
 #endif
 
-static const int64_t TICKS_PER_SEC = sysconf(_SC_CLK_TCK);
+static const int64_t kTicksPerSec = sysconf(_SC_CLK_TCK);
 
 // Offsets into the ../stat file array of per-thread statistics.
 //
 // They are themselves offset by two because the pid and comm fields of the
 // file are parsed separately.
-static const int64_t USER_TICKS = 13 - 2;
-static const int64_t KERNEL_TICKS = 14 - 2;
-static const int64_t IO_WAIT = 41 - 2;
+static const int64_t kUserTicks = 13 - 2;
+static const int64_t kKernelTicks = 14 - 2;
+static const int64_t kIoWait = 41 - 2;
 
 // Largest offset we are interested in, to check we get a well formed stat file.
-static const int64_t MAX_OFFSET = IO_WAIT;
+static const int64_t kMaxOffset = kIoWait;
 
 Status ParseStat(const std::string& buffer, std::string* name, ThreadStats* stats) {
   DCHECK(stats != nullptr);
@@ -80,19 +80,19 @@ Status ParseStat(const std::string& buffer, std::string* name, ThreadStats* stat
   string extracted_name = buffer.substr(open_paren + 1, close_paren - (open_paren + 1));
   string rest = buffer.substr(close_paren + 2);
   vector<string> splits = Split(rest, " ", strings::SkipEmpty());
-  if (splits.size() < MAX_OFFSET) {
+  if (splits.size() < kMaxOffset) {
     return Status::IOError("Unrecognised /proc format");
   }
 
   int64 tmp;
-  if (safe_strto64(splits[USER_TICKS], &tmp)) {
-    stats->user_ns = tmp * (1e9 / TICKS_PER_SEC);
+  if (safe_strto64(splits[kUserTicks], &tmp)) {
+    stats->user_ns = tmp * (1e9 / kTicksPerSec);
   }
-  if (safe_strto64(splits[KERNEL_TICKS], &tmp)) {
-    stats->kernel_ns = tmp * (1e9 / TICKS_PER_SEC);
+  if (safe_strto64(splits[kKernelTicks], &tmp)) {
+    stats->kernel_ns = tmp * (1e9 / kTicksPerSec);
   }
-  if (safe_strto64(splits[IO_WAIT], &tmp)) {
-    stats->iowait_ns = tmp * (1e9 / TICKS_PER_SEC);
+  if (safe_strto64(splits[kIoWait], &tmp)) {
+    stats->iowait_ns = tmp * (1e9 / kTicksPerSec);
   }
   if (name != nullptr) {
     *name = extracted_name;
@@ -103,7 +103,7 @@ Status ParseStat(const std::string& buffer, std::string* name, ThreadStats* stat
 
 Status GetThreadStats(int64_t tid, ThreadStats* stats) {
   DCHECK(stats != nullptr);
-  if (TICKS_PER_SEC <= 0) {
+  if (kTicksPerSec <= 0) {
     return Status::NotSupported("ThreadStats not supported");
   }
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/util/process_memory.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/process_memory.cc b/src/kudu/util/process_memory.cc
index 986e15a..59fab51 100644
--- a/src/kudu/util/process_memory.cc
+++ b/src/kudu/util/process_memory.cc
@@ -84,7 +84,7 @@ Atomic64 g_released_memory_since_gc;
 // A higher value will make us call into tcmalloc less often (and therefore more
 // efficient). A lower value will mean our memory overhead is lower.
 // TODO(todd): this is a stopgap.
-const int64_t GC_RELEASE_SIZE = 128 * 1024L * 1024L;
+const int64_t kGcReleaseSize = 128 * 1024L * 1024L;
 
 #endif // TCMALLOC_ENABLED
 
@@ -264,7 +264,7 @@ void MaybeGCAfterRelease(int64_t released_bytes) {
 #ifdef TCMALLOC_ENABLED
   int64_t now_released = base::subtle::NoBarrier_AtomicIncrement(
       &g_released_memory_since_gc, -released_bytes);
-  if (PREDICT_FALSE(now_released > GC_RELEASE_SIZE)) {
+  if (PREDICT_FALSE(now_released > kGcReleaseSize)) {
     base::subtle::NoBarrier_Store(&g_released_memory_since_gc, 0);
     GcTcmalloc();
   }

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/util/rle-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/rle-test.cc b/src/kudu/util/rle-test.cc
index 185fed5..874bd71 100644
--- a/src/kudu/util/rle-test.cc
+++ b/src/kudu/util/rle-test.cc
@@ -35,7 +35,7 @@ using std::vector;
 
 namespace kudu {
 
-const int MAX_WIDTH = 64;
+const int kMaxWidth = 64;
 
 class TestRle : public KuduTest {};
 
@@ -123,7 +123,7 @@ void TestBitArrayValues(int bit_width, int num_vals) {
 }
 
 TEST(BitArray, TestValues) {
-  for (int width = 1; width <= MAX_WIDTH; ++width) {
+  for (int width = 1; width <= kMaxWidth; ++width) {
     TestBitArrayValues(width, 1);
     TestBitArrayValues(width, 2);
     // Don't write too many values
@@ -225,7 +225,7 @@ TEST(Rle, SpecificSequences) {
     ValidateRle(values, width, expected_buffer, 4);
   }
 
-  for (int width = 9; width <= MAX_WIDTH; ++width) {
+  for (int width = 9; width <= kMaxWidth; ++width) {
     ValidateRle(values, width, nullptr, 2 * (1 + BitUtil::Ceil(width, 8)));
   }
 
@@ -243,7 +243,7 @@ TEST(Rle, SpecificSequences) {
 
   // num_groups and expected_buffer only valid for bit width = 1
   ValidateRle(values, 1, expected_buffer, 1 + num_groups);
-  for (int width = 2; width <= MAX_WIDTH; ++width) {
+  for (int width = 2; width <= kMaxWidth; ++width) {
     ValidateRle(values, width, nullptr, 1 + BitUtil::Ceil(width * 100, 8));
   }
 }
@@ -260,7 +260,7 @@ void TestRleValues(int bit_width, int num_vals, int value = -1) {
 }
 
 TEST(Rle, TestValues) {
-  for (int width = 1; width <= MAX_WIDTH; ++width) {
+  for (int width = 1; width <= kMaxWidth; ++width) {
     TestRleValues(width, 1);
     TestRleValues(width, 1024);
     TestRleValues(width, 1024, 0);
@@ -320,7 +320,7 @@ TEST_F(BitRle, RandomBools) {
       }
       parity = !parity;
     }
-    ValidateRle(values, (iters % MAX_WIDTH) + 1, nullptr, -1);
+    ValidateRle(values, (iters % kMaxWidth) + 1, nullptr, -1);
   }
 }
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/util/trace.h
----------------------------------------------------------------------
diff --git a/src/kudu/util/trace.h b/src/kudu/util/trace.h
index 4d6df24..3c0f960 100644
--- a/src/kudu/util/trace.h
+++ b/src/kudu/util/trace.h
@@ -135,25 +135,25 @@ class Trace : public RefCountedThreadSafe<Trace> {
   void SubstituteAndTrace(const char* filepath, int line_number,
                           StringPiece format,
                           const strings::internal::SubstituteArg& arg0 =
-                            strings::internal::SubstituteArg::NoArg,
+                            strings::internal::SubstituteArg::kNoArg,
                           const strings::internal::SubstituteArg& arg1 =
-                            strings::internal::SubstituteArg::NoArg,
+                            strings::internal::SubstituteArg::kNoArg,
                           const strings::internal::SubstituteArg& arg2 =
-                            strings::internal::SubstituteArg::NoArg,
+                            strings::internal::SubstituteArg::kNoArg,
                           const strings::internal::SubstituteArg& arg3 =
-                            strings::internal::SubstituteArg::NoArg,
+                            strings::internal::SubstituteArg::kNoArg,
                           const strings::internal::SubstituteArg& arg4 =
-                            strings::internal::SubstituteArg::NoArg,
+                            strings::internal::SubstituteArg::kNoArg,
                           const strings::internal::SubstituteArg& arg5 =
-                            strings::internal::SubstituteArg::NoArg,
+                            strings::internal::SubstituteArg::kNoArg,
                           const strings::internal::SubstituteArg& arg6 =
-                            strings::internal::SubstituteArg::NoArg,
+                            strings::internal::SubstituteArg::kNoArg,
                           const strings::internal::SubstituteArg& arg7 =
-                            strings::internal::SubstituteArg::NoArg,
+                            strings::internal::SubstituteArg::kNoArg,
                           const strings::internal::SubstituteArg& arg8 =
-                            strings::internal::SubstituteArg::NoArg,
+                            strings::internal::SubstituteArg::kNoArg,
                           const strings::internal::SubstituteArg& arg9 =
-                            strings::internal::SubstituteArg::NoArg);
+                            strings::internal::SubstituteArg::kNoArg);
 
   // Dump the trace buffer to the given output stream.
   //


[4/4] kudu git commit: Use the same replica selection when adding a server as table creation

Posted by to...@apache.org.
Use the same replica selection when adding a server as table creation

When selecting TS to host replicas at table creation time, the
master uses a selection algorithm that (roughly) picks the less
loaded of two randomly chosen TS that haven't already been
picked to hold a replica. When adding a replica, for instance
after an eviction, it just picks a tserver at random from those
not already holding a replica. Let's use the same algorithm for
both, since the table creation algorithm has the benefit that it
tends to fill less-loaded tablet servers, like ones newly added
to the cluster.

Change-Id: I199e7a59c2c7832e7a87842b357ba3aa29e34685
Reviewed-on: http://gerrit.cloudera.org:8080/7143
Reviewed-by: Adar Dembo <ad...@cloudera.com>
Tested-by: Kudu Jenkins


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/7ac7762f
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/7ac7762f
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/7ac7762f

Branch: refs/heads/master
Commit: 7ac7762ff470ade1c6be3426e05d322d34dc3b2b
Parents: e719b5e
Author: Will Berkeley <wd...@apache.org>
Authored: Fri Jun 9 15:02:15 2017 -0700
Committer: Will Berkeley <wd...@gmail.com>
Committed: Mon Jun 12 23:18:56 2017 +0000

----------------------------------------------------------------------
 src/kudu/master/catalog_manager.cc | 220 ++++++++++++++++----------------
 src/kudu/master/catalog_manager.h  |  11 --
 2 files changed, 108 insertions(+), 123 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/7ac7762f/src/kudu/master/catalog_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/master/catalog_manager.cc b/src/kudu/master/catalog_manager.cc
index 8e19553..73e0c24 100644
--- a/src/kudu/master/catalog_manager.cc
+++ b/src/kudu/master/catalog_manager.cc
@@ -225,6 +225,7 @@ using cfile::TypeEncodingInfo;
 using consensus::ConsensusServiceProxy;
 using consensus::ConsensusStatePB;
 using consensus::GetConsensusRole;
+using consensus::IsRaftConfigMember;
 using consensus::RaftConsensus;
 using consensus::RaftPeerPB;
 using consensus::StartTabletCopyRequestPB;
@@ -3173,6 +3174,92 @@ class AsyncDeleteReplica : public RetrySpecificTSRpcTask {
   tserver::DeleteTabletResponsePB resp_;
 };
 
+namespace {
+
+// Given exactly two choices in 'two_choices', pick the better tablet server on
+// which to place a tablet replica. Ties are broken using 'rng'.
+shared_ptr<TSDescriptor> PickBetterReplicaLocation(const TSDescriptorVector& two_choices,
+                                                   ThreadSafeRandom* rng) {
+  DCHECK_EQ(two_choices.size(), 2);
+
+  const auto& a = two_choices[0];
+  const auto& b = two_choices[1];
+
+  // When creating replicas, we consider two aspects of load:
+  //   (1) how many tablet replicas are already on the server, and
+  //   (2) how often we've chosen this server recently.
+  //
+  // The first factor will attempt to put more replicas on servers that
+  // are under-loaded (eg because they have newly joined an existing cluster, or have
+  // been reformatted and re-joined).
+  //
+  // The second factor will ensure that we take into account the recent selection
+  // decisions even if those replicas are still in the process of being created (and thus
+  // not yet reported by the server). This is important because, while creating a table,
+  // we batch the selection process before sending any creation commands to the
+  // servers themselves.
+  //
+  // TODO(wdberkeley): in the future we may want to factor in other items such
+  // as available disk space, actual request load, etc.
+  double load_a = a->RecentReplicaCreations() + a->num_live_replicas();
+  double load_b = b->RecentReplicaCreations() + b->num_live_replicas();
+  if (load_a < load_b) {
+    return a;
+  }
+  if (load_b < load_a) {
+    return b;
+  }
+  // If the load is the same, we can just pick randomly.
+  return two_choices[rng->Uniform(2)];
+}
+
+// Given the tablet servers in 'ts_descs', use 'rng' to pick a tablet server to
+// host a tablet replica, excluding tablet servers in 'excluded'.
+// If there are no servers in 'ts_descs' that are not in 'excluded, return nullptr.
+shared_ptr<TSDescriptor> SelectReplica(const TSDescriptorVector& ts_descs,
+                                       const set<shared_ptr<TSDescriptor>>& excluded,
+                                       ThreadSafeRandom* rng) {
+  // The replica selection algorithm follows the idea from
+  // "Power of Two Choices in Randomized Load Balancing"[1]. For each replica,
+  // we randomly select two tablet servers, and then assign the replica to the
+  // less-loaded one of the two. This has some nice properties:
+  //
+  // 1) because the initial selection of two servers is random, we get good
+  //    spreading of replicas across the cluster. In contrast if we sorted by
+  //    load and always picked under-loaded servers first, we'd end up causing
+  //    all tablets of a new table to be placed on an empty server. This wouldn't
+  //    give good load balancing of that table.
+  //
+  // 2) because we pick the less-loaded of two random choices, we do end up with a
+  //    weighting towards filling up the underloaded one over time, without
+  //    the extreme scenario above.
+  //
+  // 3) because we don't follow any sequential pattern, every server is equally
+  //    likely to replicate its tablets to every other server. In contrast, a
+  //    round-robin design would enforce that each server only replicates to its
+  //    adjacent nodes in the TS sort order, limiting recovery bandwidth (see
+  //    KUDU-1317).
+  //
+  // [1] http://www.eecs.harvard.edu/~michaelm/postscripts/mythesis.pdf
+
+  // Pick two random servers, excluding those we've already picked.
+  // If we've only got one server left, 'two_choices' will actually
+  // just contain one element.
+  vector<shared_ptr<TSDescriptor>> two_choices;
+  rng->ReservoirSample(ts_descs, 2, excluded, &two_choices);
+
+  if (two_choices.size() == 2) {
+    // Pick the better of the two.
+    return PickBetterReplicaLocation(two_choices, rng);
+  }
+  if (two_choices.size() == 1) {
+    return two_choices[0];
+  }
+  return nullptr;
+}
+
+} // anonymous namespace
+
 // Send the "Alter Table" with the latest table schema to the leader replica
 // for the tablet.
 // Keeps retrying until we get an "ok" response.
@@ -3252,39 +3339,18 @@ class AsyncAlterTable : public RetryingTSRpcTask {
   tserver::AlterSchemaResponsePB resp_;
 };
 
-namespace {
-
-// Select a random TS not in the 'exclude_uuids' list.
-// Will not select tablet servers that have not heartbeated recently.
-// Returns true iff it was possible to select a replica.
-bool SelectRandomTSForReplica(const TSDescriptorVector& ts_descs,
-                              const unordered_set<string>& exclude_uuids,
-                              shared_ptr<TSDescriptor>* selection) {
-  TSDescriptorVector tablet_servers;
-  for (const shared_ptr<TSDescriptor>& ts : ts_descs) {
-    if (!ContainsKey(exclude_uuids, ts->permanent_uuid())) {
-      tablet_servers.push_back(ts);
-    }
-  }
-  if (tablet_servers.empty()) {
-    return false;
-  }
-  *selection = tablet_servers[rand() % tablet_servers.size()];
-  return true;
-}
-
-} // anonymous namespace
-
 class AsyncAddServerTask : public RetryingTSRpcTask {
  public:
   AsyncAddServerTask(Master *master,
                      const scoped_refptr<TabletInfo>& tablet,
-                     const ConsensusStatePB& cstate)
+                     const ConsensusStatePB& cstate,
+                     ThreadSafeRandom* rng)
     : RetryingTSRpcTask(master,
                         gscoped_ptr<TSPicker>(new PickLeaderReplica(tablet)),
                         tablet->table()),
       tablet_(tablet),
-      cstate_(cstate) {
+      cstate_(cstate),
+      rng_(rng) {
     deadline_ = MonoTime::Max(); // Never time out.
   }
 
@@ -3302,6 +3368,9 @@ class AsyncAddServerTask : public RetryingTSRpcTask {
   const scoped_refptr<TabletInfo> tablet_;
   const ConsensusStatePB cstate_;
 
+  // Used to make random choices in replica selection.
+  ThreadSafeRandom* rng_;
+
   consensus::ChangeConfigRequestPB req_;
   consensus::ChangeConfigResponsePB resp_;
 };
@@ -3334,14 +3403,16 @@ bool AsyncAddServerTask::SendRequest(int attempt) {
 
   // Select the replica we wish to add to the config.
   // Do not include current members of the config.
-  unordered_set<string> replica_uuids;
-  for (const RaftPeerPB& peer : cstate_.committed_config().peers()) {
-    InsertOrDie(&replica_uuids, peer.permanent_uuid());
-  }
   TSDescriptorVector ts_descs;
   master_->ts_manager()->GetAllLiveDescriptors(&ts_descs);
-  shared_ptr<TSDescriptor> replacement_replica;
-  if (PREDICT_FALSE(!SelectRandomTSForReplica(ts_descs, replica_uuids, &replacement_replica))) {
+  set<std::shared_ptr<TSDescriptor>> excluded;
+  for (const auto& ts_desc : ts_descs) {
+    if (IsRaftConfigMember(ts_desc->permanent_uuid(), cstate_.committed_config())) {
+      InsertOrDie(&excluded, ts_desc);
+    }
+  }
+  auto replacement_replica = SelectReplica(ts_descs, excluded, rng_);
+  if (PREDICT_FALSE(!replacement_replica)) {
     KLOG_EVERY_N(WARNING, 100) << LogPrefix() << "No candidate replacement replica found "
                                << "for tablet " << tablet_->ToString();
     return false;
@@ -3467,7 +3538,7 @@ void CatalogManager::SendDeleteReplicaRequest(
 
 void CatalogManager::SendAddServerRequest(const scoped_refptr<TabletInfo>& tablet,
                                           const ConsensusStatePB& cstate) {
-  auto task = new AsyncAddServerTask(master_, tablet, cstate);
+  auto task = new AsyncAddServerTask(master_, tablet, cstate, &rng_);
   tablet->table()->AddTask(task);
   WARN_NOT_OK(task->Run(),
               Substitute("Failed to send AddServer request for tablet $0", tablet->tablet_id()));
@@ -3824,85 +3895,6 @@ void CatalogManager::SendCreateTabletRequest(const scoped_refptr<TabletInfo>& ta
   }
 }
 
-shared_ptr<TSDescriptor> CatalogManager::PickBetterReplicaLocation(
-    const TSDescriptorVector& two_choices) {
-  DCHECK_EQ(two_choices.size(), 2);
-
-  const auto& a = two_choices[0];
-  const auto& b = two_choices[1];
-
-  // When creating replicas, we consider two aspects of load:
-  //   (1) how many tablet replicas are already on the server, and
-  //   (2) how often we've chosen this server recently.
-  //
-  // The first factor will attempt to put more replicas on servers that
-  // are under-loaded (eg because they have newly joined an existing cluster, or have
-  // been reformatted and re-joined).
-  //
-  // The second factor will ensure that we take into account the recent selection
-  // decisions even if those replicas are still in the process of being created (and thus
-  // not yet reported by the server). This is important because, while creating a table,
-  // we batch the selection process before sending any creation commands to the
-  // servers themselves.
-  //
-  // TODO: in the future we may want to factor in other items such as available disk space,
-  // actual request load, etc.
-  double load_a = a->RecentReplicaCreations() + a->num_live_replicas();
-  double load_b = b->RecentReplicaCreations() + b->num_live_replicas();
-  if (load_a < load_b) {
-    return a;
-  } else if (load_b < load_a) {
-    return b;
-  } else {
-    // If the load is the same, we can just pick randomly.
-    return two_choices[rng_.Uniform(2)];
-  }
-}
-
-shared_ptr<TSDescriptor> CatalogManager::SelectReplica(
-    const TSDescriptorVector& ts_descs,
-    const set<shared_ptr<TSDescriptor>>& excluded) {
-  // The replica selection algorithm follows the idea from
-  // "Power of Two Choices in Randomized Load Balancing"[1]. For each replica,
-  // we randomly select two tablet servers, and then assign the replica to the
-  // less-loaded one of the two. This has some nice properties:
-  //
-  // 1) because the initial selection of two servers is random, we get good
-  //    spreading of replicas across the cluster. In contrast if we sorted by
-  //    load and always picked under-loaded servers first, we'd end up causing
-  //    all tablets of a new table to be placed on an empty server. This wouldn't
-  //    give good load balancing of that table.
-  //
-  // 2) because we pick the less-loaded of two random choices, we do end up with a
-  //    weighting towards filling up the underloaded one over time, without
-  //    the extreme scenario above.
-  //
-  // 3) because we don't follow any sequential pattern, every server is equally
-  //    likely to replicate its tablets to every other server. In contrast, a
-  //    round-robin design would enforce that each server only replicates to its
-  //    adjacent nodes in the TS sort order, limiting recovery bandwidth (see
-  //    KUDU-1317).
-  //
-  // [1] http://www.eecs.harvard.edu/~michaelm/postscripts/mythesis.pdf
-
-  // Pick two random servers, excluding those we've already picked.
-  // If we've only got one server left, 'two_choices' will actually
-  // just contain one element.
-  vector<shared_ptr<TSDescriptor> > two_choices;
-  rng_.ReservoirSample(ts_descs, 2, excluded, &two_choices);
-
-  if (two_choices.size() == 2) {
-    // Pick the better of the two.
-    return PickBetterReplicaLocation(two_choices);
-  }
-
-  // If we couldn't randomly sample two servers, it's because we only had one
-  // more non-excluded choice left.
-  CHECK_EQ(1, ts_descs.size() - excluded.size())
-      << "ts_descs: " << ts_descs.size() << " already_sel: " << excluded.size();
-  return two_choices[0];
-}
-
 void CatalogManager::SelectReplicas(const TSDescriptorVector& ts_descs,
                                     int nreplicas,
                                     consensus::RaftConfigPB *config) {
@@ -3913,7 +3905,11 @@ void CatalogManager::SelectReplicas(const TSDescriptorVector& ts_descs,
   // put two replicas on the same host.
   set<shared_ptr<TSDescriptor> > already_selected;
   for (int i = 0; i < nreplicas; ++i) {
-    shared_ptr<TSDescriptor> ts = SelectReplica(ts_descs, already_selected);
+    shared_ptr<TSDescriptor> ts = SelectReplica(ts_descs, already_selected, &rng_);
+    // We must be able to find a tablet server for the replica because of
+    // checks before this function is called.
+    DCHECK(ts) << "ts_descs: " << ts_descs.size()
+               << " already_sel: " << already_selected.size();
     InsertOrDie(&already_selected, ts);
 
     // Increment the number of pending replicas so that we take this selection into

http://git-wip-us.apache.org/repos/asf/kudu/blob/7ac7762f/src/kudu/master/catalog_manager.h
----------------------------------------------------------------------
diff --git a/src/kudu/master/catalog_manager.h b/src/kudu/master/catalog_manager.h
index b69ea8e..72401b0 100644
--- a/src/kudu/master/catalog_manager.h
+++ b/src/kudu/master/catalog_manager.h
@@ -682,17 +682,6 @@ class CatalogManager : public tserver::TabletReplicaLookupIf {
   // Loops through the "not created" tablets and sends a CreateTablet() request.
   Status ProcessPendingAssignments(const std::vector<scoped_refptr<TabletInfo> >& tablets);
 
-  // Given 'two_choices', which should be a vector of exactly two elements, select which
-  // one is the better choice for a new replica.
-  std::shared_ptr<TSDescriptor> PickBetterReplicaLocation(const TSDescriptorVector& two_choices);
-
-  // Select a tablet server from 'ts_descs' on which to place a new replica.
-  // Any tablet servers in 'excluded' are not considered.
-  // REQUIRES: 'ts_descs' must include at least one non-excluded server.
-  std::shared_ptr<TSDescriptor> SelectReplica(
-      const TSDescriptorVector& ts_descs,
-      const std::set<std::shared_ptr<TSDescriptor>>& excluded);
-
   // Select N Replicas from online tablet servers (as specified by
   // 'ts_descs') for the specified tablet and populate the consensus configuration
   // object. If 'ts_descs' does not specify enough online tablet