You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by ad...@apache.org on 2020/03/30 18:56:34 UTC

[kudu] branch master updated (5cd26cf -> 676a765)

This is an automated email from the ASF dual-hosted git repository.

adar pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git.


    from 5cd26cf  env: add a fifo class
     new 0846456  env: remove kudu::Bind usage from Walk
     new 5db8297  gutil: remove BASE_EXPORT
     new 8d92905  logging: remove kudu::Bind usage from LoggingCallback
     new 56ec81e  rpc: remove kudu::Bind usage from ServerPicker
     new ea9243a  fs: remove kudu::Bind usage from ErrorManager
     new c497253  tracing: remove kudu::Bind usage from various callbacks
     new 676a765  fs: remove kudu::Bind usage from DataDir closures

The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/kudu/client/batcher.cc                         |  4 +--
 src/kudu/client/client.cc                          |  8 +++--
 src/kudu/client/meta_cache.cc                      |  5 ++-
 src/kudu/client/meta_cache.h                       |  6 ++--
 src/kudu/fs/block_manager-test.cc                  |  9 ++---
 src/kudu/fs/dir_manager.cc                         | 10 +++---
 src/kudu/fs/dir_manager.h                          |  4 +--
 src/kudu/fs/error_manager-test.cc                  | 36 +++++++++++---------
 src/kudu/fs/error_manager.cc                       | 11 +++---
 src/kudu/fs/error_manager.h                        |  5 ++-
 src/kudu/fs/file_block_manager.cc                  | 26 +++++++++------
 src/kudu/fs/fs_manager.cc                          |  9 ++---
 src/kudu/fs/log_block_manager-test.cc              |  9 ++---
 src/kudu/fs/log_block_manager.cc                   | 39 +++++++++++-----------
 src/kudu/gutil/atomicops-internals-tsan.h          | 11 ++----
 src/kudu/gutil/bind_helpers.h                      |  4 ---
 src/kudu/gutil/ref_counted_memory.h                | 18 ++++------
 src/kudu/gutil/threading/thread_collision_warner.h | 16 ++++-----
 src/kudu/master/master.cc                          |  5 ++-
 src/kudu/rpc/exactly_once_rpc-test.cc              | 11 +++---
 src/kudu/rpc/retriable_rpc.h                       |  9 ++---
 src/kudu/rpc/rpc.h                                 |  3 +-
 src/kudu/tserver/tablet_server.cc                  | 15 +++++----
 src/kudu/util/debug/trace_event.h                  | 12 +++----
 src/kudu/util/debug/trace_event_impl.cc            | 39 ++++++++++++----------
 src/kudu/util/debug/trace_event_impl.h             | 22 ++++++------
 src/kudu/util/debug/trace_event_synthetic_delay.h  | 10 +++---
 src/kudu/util/env-test.cc                          | 18 ++++++----
 src/kudu/util/env.h                                | 10 ++----
 src/kudu/util/env_posix.cc                         | 22 +++++++-----
 src/kudu/util/env_util.cc                          |  8 +++--
 src/kudu/util/env_util.h                           |  5 +--
 src/kudu/util/logging.cc                           |  4 +--
 src/kudu/util/logging_callback.h                   | 20 +++++------
 src/kudu/util/metrics.h                            |  2 +-
 35 files changed, 220 insertions(+), 225 deletions(-)


[kudu] 06/07: tracing: remove kudu::Bind usage from various callbacks

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

adar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit c497253f0d95313dc6ea5d3a6dbf64ef0787115b
Author: Adar Dembo <ad...@cloudera.com>
AuthorDate: Sat Mar 28 01:44:14 2020 -0700

    tracing: remove kudu::Bind usage from various callbacks
    
    Change-Id: I0ecad2771dd77b8532bffb983866898e26ef8aa3
    Reviewed-on: http://gerrit.cloudera.org:8080/15580
    Tested-by: Kudu Jenkins
    Reviewed-by: Alexey Serbin <as...@cloudera.com>
    Reviewed-by: Andrew Wong <aw...@cloudera.com>
---
 src/kudu/util/debug/trace_event_impl.cc | 38 +++++++++++++++++----------------
 src/kudu/util/debug/trace_event_impl.h  |  9 ++++----
 2 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/src/kudu/util/debug/trace_event_impl.cc b/src/kudu/util/debug/trace_event_impl.cc
index 6388243..a03808c 100644
--- a/src/kudu/util/debug/trace_event_impl.cc
+++ b/src/kudu/util/debug/trace_event_impl.cc
@@ -21,8 +21,6 @@
 
 #include <gflags/gflags.h>
 
-#include "kudu/gutil/bind.h"
-#include "kudu/gutil/bind_helpers.h"
 #include "kudu/gutil/dynamic_annotations.h"
 #include "kudu/gutil/map-util.h"
 #include "kudu/gutil/mathlimits.h"
@@ -871,11 +869,15 @@ string TraceResultBuffer::FlushTraceLogToStringButLeaveBufferIntact() {
 
 string TraceResultBuffer::DoFlush(bool leave_intact) {
   TraceResultBuffer buf;
+  auto* buf_ptr = &buf;
   TraceLog* tl = TraceLog::GetInstance();
+  auto cb = [buf_ptr](const scoped_refptr<RefCountedString>& s, bool has_more_events) {
+    buf_ptr->Collect(s, has_more_events);
+  };
   if (leave_intact) {
-    tl->FlushButLeaveBufferIntact(Bind(&TraceResultBuffer::Collect, Unretained(&buf)));
+    tl->FlushButLeaveBufferIntact(cb);
   } else {
-    tl->Flush(Bind(&TraceResultBuffer::Collect, Unretained(&buf)));
+    tl->Flush(cb);
   }
   buf.json_.append("]}\n");
   return buf.json_;
@@ -908,7 +910,7 @@ void TraceResultBuffer::Collect(
 ////////////////////////////////////////////////////////////////////////////////
 class TraceBucketData;
 
-typedef Callback<void(TraceBucketData*)> TraceSampleCallback;
+typedef std::function<void(TraceBucketData*)> TraceSampleCallback;
 
 class TraceBucketData {
  public:
@@ -930,7 +932,7 @@ class TraceSamplingThread {
 
   void ThreadMain();
 
-  static void DefaultSamplingCallback(TraceBucketData* bucekt_data);
+  static void DefaultSamplingCallback(TraceBucketData* bucket_data);
 
   void Stop();
 
@@ -990,7 +992,7 @@ void TraceSamplingThread::DefaultSamplingCallback(
 void TraceSamplingThread::GetSamples() {
   for (auto& sample_bucket : sample_buckets_) {
     TraceBucketData* bucket_data = &sample_bucket;
-    bucket_data->callback.Run(bucket_data);
+    bucket_data->callback(bucket_data);
   }
 }
 
@@ -1349,15 +1351,15 @@ void TraceLog::SetEnabled(const CategoryFilter& category_filter,
       sampling_thread_->RegisterSampleBucket(
           &g_trace_state[0],
           "bucket0",
-          Bind(&TraceSamplingThread::DefaultSamplingCallback));
+          &TraceSamplingThread::DefaultSamplingCallback);
       sampling_thread_->RegisterSampleBucket(
           &g_trace_state[1],
           "bucket1",
-          Bind(&TraceSamplingThread::DefaultSamplingCallback));
+          &TraceSamplingThread::DefaultSamplingCallback);
       sampling_thread_->RegisterSampleBucket(
           &g_trace_state[2],
           "bucket2",
-          Bind(&TraceSamplingThread::DefaultSamplingCallback));
+          &TraceSamplingThread::DefaultSamplingCallback);
 
       Status s = Thread::CreateWithFlags(
           "tracing", "sampler",
@@ -1559,8 +1561,8 @@ void TraceLog::Flush(const TraceLog::OutputCallback& cb) {
     // - deschedule the calling thread on some platforms causing inaccurate
     //   timing of the trace events.
     scoped_refptr<RefCountedString> empty_result = new RefCountedString;
-    if (!cb.is_null())
-      cb.Run(empty_result, false);
+    if (cb)
+      cb(empty_result, false);
     LOG(WARNING) << "Ignored TraceLog::Flush called when tracing is enabled";
     return;
   }
@@ -1620,7 +1622,7 @@ void TraceLog::ConvertTraceEventsToTraceFormat(
     unique_ptr<TraceBuffer> logged_events,
     const TraceLog::OutputCallback& flush_output_callback) {
 
-  if (flush_output_callback.is_null())
+  if (!flush_output_callback)
     return;
 
   // The callback need to be called at least once even if there is no events
@@ -1643,7 +1645,7 @@ void TraceLog::ConvertTraceEventsToTraceFormat(
       }
     }
 
-    flush_output_callback.Run(json_events_str_ptr, has_more_events);
+    flush_output_callback(json_events_str_ptr, has_more_events);
   } while (has_more_events);
   logged_events.reset();
 }
@@ -1673,7 +1675,7 @@ void TraceLog::FlushButLeaveBufferIntact(
     SpinLockHolder lock(&lock_);
     if (mode_ == DISABLED || (trace_options_ & RECORD_CONTINUOUSLY) == 0) {
       scoped_refptr<RefCountedString> empty_result = new RefCountedString;
-      flush_output_callback.Run(empty_result, false);
+      flush_output_callback(empty_result, false);
       LOG(WARNING) << "Ignored TraceLog::FlushButLeaveBufferIntact when monitoring is not enabled";
       return;
     }
@@ -1901,8 +1903,8 @@ TraceEventHandle TraceLog::AddTraceEventWithThreadIdAndTimestamp(
       watch_event_callback_copy = watch_event_callback_;
     }
     if (event_name_matches) {
-      if (!watch_event_callback_copy.is_null())
-        watch_event_callback_copy.Run();
+      if (watch_event_callback_copy)
+        watch_event_callback_copy();
     }
   }
 
@@ -2062,7 +2064,7 @@ void TraceLog::CancelWatchEvent() {
   SpinLockHolder lock(&lock_);
   base::subtle::NoBarrier_Store(&watch_category_, 0);
   watch_event_name_ = "";
-  watch_event_callback_.Reset();
+  watch_event_callback_ = nullptr;
 }
 
 void TraceLog::AddMetadataEventsWhileLocked() {
diff --git a/src/kudu/util/debug/trace_event_impl.h b/src/kudu/util/debug/trace_event_impl.h
index 4503e0e..5be70c2 100644
--- a/src/kudu/util/debug/trace_event_impl.h
+++ b/src/kudu/util/debug/trace_event_impl.h
@@ -5,6 +5,7 @@
 
 #include <cstddef>
 #include <cstdint>
+#include <functional>
 #include <iosfwd>
 #include <memory>
 #include <stack>
@@ -16,7 +17,6 @@
 #include <gtest/gtest_prod.h>
 
 #include "kudu/gutil/atomicops.h"
-#include "kudu/gutil/callback.h"
 #include "kudu/gutil/macros.h"
 #include "kudu/gutil/ref_counted.h"
 #include "kudu/gutil/spinlock.h"
@@ -436,7 +436,6 @@ class TraceLog {
   float GetBufferPercentFull() const;
   bool BufferIsFull() const;
 
-  // Not using kudu::Callback because of its limited by 7 parameters.
   // Also, using primitive type allows directly passing callback from WebCore.
   // WARNING: It is possible for the previously set callback to be called
   // after a call to SetEventCallbackEnabled() that replaces or a call to
@@ -470,8 +469,8 @@ class TraceLog {
   // done when tracing is enabled. If called when tracing is enabled, the
   // callback will be called directly with (empty_string, false) to indicate
   // the end of this unsuccessful flush.
-  typedef kudu::Callback<void(const scoped_refptr<kudu::RefCountedString>&,
-                              bool has_more_events)> OutputCallback;
+  typedef std::function<void(const scoped_refptr<kudu::RefCountedString>&,
+                             bool has_more_events)> OutputCallback;
   void Flush(const OutputCallback& cb);
   void FlushButLeaveBufferIntact(const OutputCallback& flush_output_callback);
 
@@ -523,7 +522,7 @@ class TraceLog {
                                 TraceEventHandle handle);
 
   // For every matching event, the callback will be called.
-  typedef kudu::Callback<void()> WatchEventCallback;
+  typedef std::function<void()> WatchEventCallback;
   void SetWatchEvent(const std::string& category_name,
                      const std::string& event_name,
                      const WatchEventCallback& callback);


[kudu] 01/07: env: remove kudu::Bind usage from Walk

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

adar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 08464561d95651470957ddeceb94a1ad3170df3d
Author: Adar Dembo <ad...@cloudera.com>
AuthorDate: Fri Mar 27 23:49:07 2020 -0700

    env: remove kudu::Bind usage from Walk
    
    This isn't as elegant as the other patches in this series due to the number
    of parameters in WalkCallback. C++14 allows the use of 'auto' for parameter
    types which can shorten them somewhat.
    
    Change-Id: I080809aef7e2f0ac3c240d4ca6909951b9615bb0
    Reviewed-on: http://gerrit.cloudera.org:8080/15575
    Tested-by: Kudu Jenkins
    Reviewed-by: Alexey Serbin <as...@cloudera.com>
    Reviewed-by: Andrew Wong <aw...@cloudera.com>
---
 src/kudu/fs/block_manager-test.cc |  9 +++++----
 src/kudu/fs/file_block_manager.cc | 14 +++++++++-----
 src/kudu/util/env-test.cc         | 18 ++++++++++++------
 src/kudu/util/env.h               | 10 +++-------
 src/kudu/util/env_posix.cc        | 22 +++++++++++++---------
 src/kudu/util/env_util.cc         |  8 ++++++--
 src/kudu/util/env_util.h          |  5 +----
 src/kudu/util/metrics.h           |  2 +-
 8 files changed, 50 insertions(+), 38 deletions(-)

diff --git a/src/kudu/fs/block_manager-test.cc b/src/kudu/fs/block_manager-test.cc
index 88143d3..1aca697 100644
--- a/src/kudu/fs/block_manager-test.cc
+++ b/src/kudu/fs/block_manager-test.cc
@@ -43,7 +43,6 @@
 #include "kudu/fs/fs_report.h"
 #include "kudu/fs/log_block_manager.h"
 #include "kudu/gutil/basictypes.h"
-#include "kudu/gutil/bind.h"
 #include "kudu/gutil/casts.h"
 #include "kudu/gutil/map-util.h"
 #include "kudu/gutil/ref_counted.h"
@@ -224,9 +223,11 @@ class BlockManagerTest : public KuduTest {
   // hierarchy, ignoring '.', '..', and file 'kInstanceMetadataFileName'.
   Status CountFiles(const string& root, int* num_files) {
     *num_files = 0;
-    RETURN_NOT_OK(env_->Walk(root, Env::PRE_ORDER,
-                             Bind(BlockManagerTest::CountFilesCb, num_files)));
-    return Status::OK();
+    return env_->Walk(
+        root, Env::PRE_ORDER,
+        [num_files](Env::FileType type, const string& dirname, const string& basename) {
+          return CountFilesCb(num_files, type, dirname, basename);
+        });
   }
 
   // Keep an internal copy of the data dir group to act as metadata.
diff --git a/src/kudu/fs/file_block_manager.cc b/src/kudu/fs/file_block_manager.cc
index 09b2a99..ae8f1bc 100644
--- a/src/kudu/fs/file_block_manager.cc
+++ b/src/kudu/fs/file_block_manager.cc
@@ -18,6 +18,7 @@
 #include "kudu/fs/file_block_manager.h"
 
 #include <cstddef>
+#include <functional>
 #include <memory>
 #include <mutex>
 #include <numeric>
@@ -921,11 +922,14 @@ Status GetAllBlockIdsForDataDirCb(Dir* dd,
 }
 
 void GetAllBlockIdsForDir(Env* env,
-                              Dir* dd,
-                              vector<BlockId>* block_ids,
-                              Status* status) {
-  *status = env->Walk(dd->dir(), Env::PRE_ORDER,
-                      Bind(&GetAllBlockIdsForDataDirCb, dd, block_ids));
+                          Dir* dd,
+                          vector<BlockId>* block_ids,
+                          Status* status) {
+  *status = env->Walk(
+      dd->dir(), Env::PRE_ORDER,
+      [dd, block_ids](Env::FileType type, const string& dirname, const string& basename) {
+        return GetAllBlockIdsForDataDirCb(dd, block_ids, type, dirname, basename);
+      });
 }
 
 } // anonymous namespace
diff --git a/src/kudu/util/env-test.cc b/src/kudu/util/env-test.cc
index 6dda618..3eb4253 100644
--- a/src/kudu/util/env-test.cc
+++ b/src/kudu/util/env-test.cc
@@ -52,7 +52,6 @@
 #include <glog/stl_logging.h> // IWYU pragma: keep
 #include <gtest/gtest.h>
 
-#include "kudu/gutil/bind.h"
 #include "kudu/gutil/macros.h"
 #include "kudu/gutil/map-util.h"
 #include "kudu/gutil/port.h"
@@ -752,13 +751,17 @@ TEST_F(TestEnv, TestWalk) {
 
   // Do the walk.
   unordered_set<string> actual;
-  ASSERT_OK(env_->Walk(root, Env::PRE_ORDER, Bind(&TestWalkCb, &actual)));
+  ASSERT_OK(env_->Walk(
+      root, Env::PRE_ORDER,
+      [&actual](Env::FileType type, const string& dirname, const string& basename) {
+        return TestWalkCb(&actual, type, dirname, basename);
+      }));
   ASSERT_EQ(expected, actual);
 }
 
 TEST_F(TestEnv, TestWalkNonExistentPath) {
   // A walk on a non-existent path should fail.
-  Status s = env_->Walk("/not/a/real/path", Env::PRE_ORDER, Bind(&NoopTestWalkCb));
+  Status s = env_->Walk("/not/a/real/path", Env::PRE_ORDER, &NoopTestWalkCb);
   ASSERT_TRUE(s.IsIOError());
   ASSERT_STR_CONTAINS(s.ToString(), "One or more errors occurred");
 }
@@ -777,7 +780,7 @@ TEST_F(TestEnv, TestWalkBadPermissions) {
 
   // A walk on a directory without execute permission should fail,
   // unless the calling process has super-user's effective ID.
-  Status s = env_->Walk(kTestPath, Env::PRE_ORDER, Bind(&NoopTestWalkCb));
+  Status s = env_->Walk(kTestPath, Env::PRE_ORDER, &NoopTestWalkCb);
   if (geteuid() == 0) {
     ASSERT_TRUE(s.ok()) << s.ToString();
   } else {
@@ -801,8 +804,11 @@ TEST_F(TestEnv, TestWalkCbReturnsError) {
   unique_ptr<WritableFile> writer;
   ASSERT_OK(env_->NewWritableFile(JoinPathSegments(new_dir, new_file), &writer));
   int num_calls = 0;
-  ASSERT_TRUE(env_->Walk(new_dir, Env::PRE_ORDER,
-                         Bind(&TestWalkErrorCb, &num_calls)).IsIOError());
+  ASSERT_TRUE(env_->Walk(
+      new_dir, Env::PRE_ORDER,
+      [&num_calls](Env::FileType type, const string& dirname, const string& basename) {
+        return TestWalkErrorCb(&num_calls, type, dirname, basename);
+      }).IsIOError());
 
   // Once for the directory and once for the file inside it.
   ASSERT_EQ(2, num_calls);
diff --git a/src/kudu/util/env.h b/src/kudu/util/env.h
index 9a2d7bc..7c57bb3 100644
--- a/src/kudu/util/env.h
+++ b/src/kudu/util/env.h
@@ -9,19 +9,17 @@
 //
 // All Env implementations are safe for concurrent access from
 // multiple threads without any external synchronization.
-
-#ifndef STORAGE_LEVELDB_INCLUDE_ENV_H_
-#define STORAGE_LEVELDB_INCLUDE_ENV_H_
+#pragma once
 
 #include <cstddef>
 #include <cstdint>
+#include <functional>
 #include <iosfwd>
 #include <map>
 #include <memory>
 #include <string>
 #include <vector>
 
-#include "kudu/gutil/callback_forward.h"
 #include "kudu/gutil/macros.h"
 #include "kudu/util/status.h"
 
@@ -278,7 +276,7 @@ class Env {
   //
   // Returning an error won't halt the walk, but it will cause it to return
   // with an error status when it's done.
-  typedef Callback<Status(FileType, const std::string&, const std::string&)> WalkCallback;
+  typedef std::function<Status(FileType, const std::string&, const std::string&)> WalkCallback;
 
   // Whether to walk directories in pre-order or post-order.
   enum DirectoryOrder {
@@ -702,5 +700,3 @@ extern Status ReadFileToString(Env* env, const std::string& fname,
 std::ostream& operator<<(std::ostream& o, Env::ResourceLimitType t);
 
 }  // namespace kudu
-
-#endif  // STORAGE_LEVELDB_INCLUDE_ENV_H_
diff --git a/src/kudu/util/env_posix.cc b/src/kudu/util/env_posix.cc
index 3590fd1..586b333 100644
--- a/src/kudu/util/env_posix.cc
+++ b/src/kudu/util/env_posix.cc
@@ -26,6 +26,7 @@
 #include <cstdlib>
 #include <cstring>
 #include <ctime>
+#include <functional>
 #include <map>
 #include <memory>
 #include <numeric>
@@ -39,8 +40,6 @@
 
 #include "kudu/gutil/atomicops.h"
 #include "kudu/gutil/basictypes.h"
-#include "kudu/gutil/bind.h"
-#include "kudu/gutil/bind_helpers.h"
 #include "kudu/gutil/macros.h"
 #include "kudu/gutil/map-util.h"
 #include "kudu/gutil/once.h"
@@ -1332,8 +1331,11 @@ class PosixEnv : public Env {
   }
 
   virtual Status DeleteRecursively(const string &name) OVERRIDE {
-    return Walk(name, POST_ORDER, Bind(&PosixEnv::DeleteRecursivelyCb,
-                                       Unretained(this)));
+    return Walk(
+        name, POST_ORDER,
+        [this](FileType type, const string& dirname, const string& basename) -> Status {
+          return this->DeleteRecursivelyCb(type, dirname, basename);
+        });
   }
 
   virtual Status GetFileSize(const string& fname, uint64_t* size) OVERRIDE {
@@ -1373,9 +1375,11 @@ class PosixEnv : public Env {
                                               uint64_t* bytes_used) OVERRIDE {
     TRACE_EVENT1("io", "PosixEnv::GetFileSizeOnDiskRecursively", "path", root);
     uint64_t total = 0;
-    RETURN_NOT_OK(Walk(root, Env::PRE_ORDER,
-                       Bind(&PosixEnv::GetFileSizeOnDiskRecursivelyCb,
-                            Unretained(this), &total)));
+    RETURN_NOT_OK(Walk(
+        root, PRE_ORDER,
+        [this, &total](FileType type, const string& dirname, const string& basename) -> Status {
+          return this->GetFileSizeOnDiskRecursivelyCb(&total, type, dirname, basename);
+        }));
     *bytes_used = total;
     return Status::OK();
   }
@@ -1625,7 +1629,7 @@ class PosixEnv : public Env {
           break;
       }
       if (doCb) {
-        if (!cb.Run(type, DirName(ent->fts_path), ent->fts_name).ok()) {
+        if (!cb(type, DirName(ent->fts_path), ent->fts_name).ok()) {
           had_errors = true;
         }
       }
@@ -1891,7 +1895,7 @@ class PosixEnv : public Env {
   }
 
   Status GetFileSizeOnDiskRecursivelyCb(uint64_t* bytes_used,
-                                        Env::FileType type,
+                                        FileType type,
                                         const string& dirname,
                                         const string& basename) {
     uint64_t file_bytes_used = 0;
diff --git a/src/kudu/util/env_util.cc b/src/kudu/util/env_util.cc
index 6fb8b8a..41f0ad1 100644
--- a/src/kudu/util/env_util.cc
+++ b/src/kudu/util/env_util.cc
@@ -23,6 +23,7 @@
 #include <cerrno>
 #include <cstdint>
 #include <ctime>
+#include <functional>
 #include <memory>
 #include <string>
 #include <unordered_set>
@@ -32,7 +33,6 @@
 #include <gflags/gflags.h>
 #include <glog/logging.h>
 
-#include "kudu/gutil/bind.h"
 #include "kudu/gutil/macros.h"
 #include "kudu/gutil/port.h"
 #include "kudu/gutil/strings/split.h"
@@ -309,7 +309,11 @@ static Status DeleteTmpFilesRecursivelyCb(Env* env,
 }
 
 Status DeleteTmpFilesRecursively(Env* env, const string& path) {
-  return env->Walk(path, Env::PRE_ORDER, Bind(&DeleteTmpFilesRecursivelyCb, env));
+  return env->Walk(
+      path, Env::PRE_ORDER,
+      [env](Env::FileType type, const string& dirname, const string& basename) {
+        return DeleteTmpFilesRecursivelyCb(env, type, dirname, basename);
+      });
 }
 
 Status IsDirectoryEmpty(Env* env, const string& path, bool* is_empty) {
diff --git a/src/kudu/util/env_util.h b/src/kudu/util/env_util.h
index bba1e92..00007d6 100644
--- a/src/kudu/util/env_util.h
+++ b/src/kudu/util/env_util.h
@@ -14,8 +14,7 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-#ifndef KUDU_UTIL_ENV_UTIL_H
-#define KUDU_UTIL_ENV_UTIL_H
+#pragma once
 
 #include <cstddef>
 #include <cstdint>
@@ -111,5 +110,3 @@ Status ListFilesInDir(Env* env,
 
 } // namespace env_util
 } // namespace kudu
-
-#endif
diff --git a/src/kudu/util/metrics.h b/src/kudu/util/metrics.h
index 7a1ed07..ab31113 100644
--- a/src/kudu/util/metrics.h
+++ b/src/kudu/util/metrics.h
@@ -1169,7 +1169,7 @@ class AtomicGauge : public Gauge {
 //  public:
 //   MyClassWithMetrics(const scoped_refptr<MetricEntity>& entity) {
 //     METRIC_my_metric.InstantiateFunctionGauge(entity,
-//       Bind(&MyClassWithMetrics::ComputeMyMetric, Unretained(this)))
+//       [this]() { return this->ComputeMyMetric(); })
 //       ->AutoDetach(&metric_detacher_);
 //   }
 //   ~MyClassWithMetrics() {


[kudu] 07/07: fs: remove kudu::Bind usage from DataDir closures

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

adar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 676a765f2f8744bd7273b7358ab3a8b22c148edb
Author: Adar Dembo <ad...@cloudera.com>
AuthorDate: Sat Mar 28 01:46:12 2020 -0700

    fs: remove kudu::Bind usage from DataDir closures
    
    Change-Id: Id58b8740ccc33762383a48680c726e8d30e7f25c
    Reviewed-on: http://gerrit.cloudera.org:8080/15581
    Tested-by: Kudu Jenkins
    Reviewed-by: Alexey Serbin <as...@cloudera.com>
    Reviewed-by: Andrew Wong <aw...@cloudera.com>
---
 src/kudu/fs/dir_manager.cc        | 10 +++++-----
 src/kudu/fs/dir_manager.h         |  4 ++--
 src/kudu/fs/file_block_manager.cc | 12 ++++++------
 src/kudu/fs/log_block_manager.cc  | 39 ++++++++++++++++++++-------------------
 4 files changed, 33 insertions(+), 32 deletions(-)

diff --git a/src/kudu/fs/dir_manager.cc b/src/kudu/fs/dir_manager.cc
index c76f773..fd8a81f 100644
--- a/src/kudu/fs/dir_manager.cc
+++ b/src/kudu/fs/dir_manager.cc
@@ -34,7 +34,6 @@
 
 #include "kudu/fs/dir_util.h"
 #include "kudu/fs/fs.pb.h"
-#include "kudu/gutil/bind.h"
 #include "kudu/gutil/map-util.h"
 #include "kudu/gutil/port.h"
 #include "kudu/gutil/strings/join.h"
@@ -103,12 +102,12 @@ void Dir::Shutdown() {
   is_shutdown_ = true;
 }
 
-void Dir::ExecClosure(const Closure& task) {
-  Status s = pool_->Submit([task]() { task.Run(); });
+void Dir::ExecClosure(const std::function<void()>& task) {
+  Status s = pool_->Submit(task);
   if (!s.ok()) {
     WARN_NOT_OK(
         s, "Could not submit task to thread pool, running it synchronously");
-    task.Run();
+    task();
   }
 }
 
@@ -577,7 +576,8 @@ Status DirManager::Open() {
   // Use the per-dir thread pools to delete temporary files in parallel.
   for (const auto& dir : dirs) {
     if (dir->instance()->healthy()) {
-      dir->ExecClosure(Bind(&DeleteTmpFilesRecursively, env_, dir->dir()));
+      auto* d = dir.get();
+      dir->ExecClosure([this, d]() { DeleteTmpFilesRecursively(this->env_, d->dir()); });
     }
   }
   for (const auto& dir : dirs) {
diff --git a/src/kudu/fs/dir_manager.h b/src/kudu/fs/dir_manager.h
index e1beae0..d162ae8 100644
--- a/src/kudu/fs/dir_manager.h
+++ b/src/kudu/fs/dir_manager.h
@@ -19,6 +19,7 @@
 
 #include <stdint.h>
 
+#include <functional>
 #include <memory>
 #include <mutex>
 #include <set>
@@ -26,7 +27,6 @@
 #include <unordered_map>
 #include <vector>
 
-#include "kudu/gutil/callback.h"
 #include "kudu/gutil/macros.h"
 #include "kudu/gutil/ref_counted.h"
 #include "kudu/util/locks.h"
@@ -109,7 +109,7 @@ class Dir {
   //
   // Normally the task is performed asynchronously. However, if submission to
   // the pool fails, it runs synchronously on the current thread.
-  void ExecClosure(const Closure& task);
+  void ExecClosure(const std::function<void()>& task);
 
   // Waits for any outstanding closures submitted via ExecClosure() to finish.
   void WaitOnClosures();
diff --git a/src/kudu/fs/file_block_manager.cc b/src/kudu/fs/file_block_manager.cc
index ae8f1bc..2e631cb 100644
--- a/src/kudu/fs/file_block_manager.cc
+++ b/src/kudu/fs/file_block_manager.cc
@@ -37,7 +37,6 @@
 #include "kudu/fs/dir_manager.h"
 #include "kudu/fs/error_manager.h"
 #include "kudu/fs/fs_report.h"
-#include "kudu/gutil/bind.h"
 #include "kudu/gutil/casts.h"
 #include "kudu/gutil/integral_types.h"
 #include "kudu/gutil/map-util.h"
@@ -943,11 +942,12 @@ Status FileBlockManager::GetAllBlockIds(vector<BlockId>* block_ids) {
   vector<vector<BlockId>> block_id_vecs(dds.size());
   vector<Status> statuses(dds.size());
   for (int i = 0; i < dds.size(); i++) {
-    dds[i]->ExecClosure(Bind(&GetAllBlockIdsForDir,
-                             env_,
-                             dds[i].get(),
-                             &block_id_vecs[i],
-                             &statuses[i]));
+    auto* dd = dds[i].get();
+    auto* bid_vec = &block_id_vecs[i];
+    auto* s = &statuses[i];
+    dds[i]->ExecClosure([this, dd, bid_vec, s]() {
+      GetAllBlockIdsForDir(this->env_, dd, bid_vec, s);
+    });
   }
   for (const auto& dd : dd_manager_->dirs()) {
     dd->WaitOnClosures();
diff --git a/src/kudu/fs/log_block_manager.cc b/src/kudu/fs/log_block_manager.cc
index cb40778..945d53f 100644
--- a/src/kudu/fs/log_block_manager.cc
+++ b/src/kudu/fs/log_block_manager.cc
@@ -22,6 +22,7 @@
 #include <algorithm>
 #include <cstddef>
 #include <cstdint>
+#include <functional>
 #include <map>
 #include <memory>
 #include <mutex>
@@ -44,9 +45,6 @@
 #include "kudu/fs/error_manager.h"
 #include "kudu/fs/fs.pb.h"
 #include "kudu/fs/fs_report.h"
-#include "kudu/gutil/bind.h"
-#include "kudu/gutil/bind_helpers.h"
-#include "kudu/gutil/callback.h"
 #include "kudu/gutil/casts.h"
 #include "kudu/gutil/map-util.h"
 #include "kudu/gutil/port.h"
@@ -502,7 +500,7 @@ class LogBlockContainer: public RefCountedThreadSafe<LogBlockContainer> {
   //
   // Normally the task is performed asynchronously. However, if submission to
   // the pool fails, it runs synchronously on the current thread.
-  void ExecClosure(const Closure& task);
+  void ExecClosure(const std::function<void()>& task);
 
   // Produces a debug-friendly string representation of this container.
   string ToString() const;
@@ -1337,7 +1335,7 @@ void LogBlockContainer::BlockDeleted(const LogBlockRefPtr& block) {
   live_blocks_.IncrementBy(-1);
 }
 
-void LogBlockContainer::ExecClosure(const Closure& task) {
+void LogBlockContainer::ExecClosure(const std::function<void()>& task) {
   data_dir_->ExecClosure(task);
 }
 
@@ -1496,11 +1494,11 @@ LogBlockDeletionTransaction::~LogBlockDeletionTransaction() {
                      Substitute("could not coalesce hole punching for container: $0",
                                 container->ToString()));
 
+    scoped_refptr<LogBlockContainer> self(container);
     for (const auto& interval : entry.second) {
-      container->ExecClosure(Bind(&LogBlockContainer::ContainerDeletionAsync,
-                                  container,
-                                  interval.first,
-                                  interval.second - interval.first));
+      container->ExecClosure([self, interval]() {
+        self->ContainerDeletionAsync(interval.first, interval.second - interval.first);
+      });
     }
   }
 }
@@ -2081,12 +2079,12 @@ Status LogBlockManager::Open(FsReport* report) {
     }
 
     // Open the data dir asynchronously.
-    dd->ExecClosure(
-        Bind(&LogBlockManager::OpenDataDir,
-             Unretained(this),
-             dd.get(),
-             &container_results[i],
-             &statuses[i]));
+    auto* dd_raw = dd.get();
+    auto* results = &container_results[i];
+    auto* s = &statuses[i];
+    dd->ExecClosure([this, dd_raw, results, s]() {
+      this->OpenDataDir(dd_raw, results, s);
+    });
   }
 
   // Wait for the opens to complete.
@@ -2136,8 +2134,9 @@ Status LogBlockManager::Open(FsReport* report) {
     }
     if (do_repair) {
       dir_results[i] = std::move(dir_result);
-      dd->ExecClosure(Bind(&LogBlockManager::RepairTask, Unretained(this),
-                           dd.get(), Unretained(dir_results[i].get())));
+      auto* dd_raw = dd.get();
+      auto* dr = dir_results[i].get();
+      dd->ExecClosure([this, dd_raw, dr]() { this->RepairTask(dd_raw, dr); });
     }
   }
 
@@ -2558,8 +2557,10 @@ void LogBlockManager::OpenDataDir(
     }
 
     // Load the container's records asynchronously.
-    dir->ExecClosure(Bind(&LogBlockManager::LoadContainer, Unretained(this),
-                          dir, container, Unretained(results->back().get())));
+    auto* r = results->back().get();
+    dir->ExecClosure([this, dir, container, r]() {
+      this->LoadContainer(dir, container, r);
+    });
   }
 }
 


[kudu] 03/07: logging: remove kudu::Bind usage from LoggingCallback

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

adar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 8d92905a472e5b010d8f1bdfbe1770fd564ce082
Author: Adar Dembo <ad...@cloudera.com>
AuthorDate: Sat Mar 28 01:25:43 2020 -0700

    logging: remove kudu::Bind usage from LoggingCallback
    
    Change-Id: I8d3c995617ace2a5974be1104fa6f22b3ee5acea
    Reviewed-on: http://gerrit.cloudera.org:8080/15577
    Tested-by: Kudu Jenkins
    Reviewed-by: Alexey Serbin <as...@cloudera.com>
    Reviewed-by: Andrew Wong <aw...@cloudera.com>
---
 src/kudu/client/client.cc        |  8 +++++---
 src/kudu/util/logging.cc         |  4 ++--
 src/kudu/util/logging_callback.h | 20 ++++++++------------
 3 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/src/kudu/client/client.cc b/src/kudu/client/client.cc
index 67976e0..e602eb6 100644
--- a/src/kudu/client/client.cc
+++ b/src/kudu/client/client.cc
@@ -69,8 +69,6 @@
 #include "kudu/common/wire_protocol.pb.h"
 #include "kudu/consensus/metadata.pb.h"
 #include "kudu/gutil/basictypes.h"
-#include "kudu/gutil/bind.h"
-#include "kudu/gutil/bind_helpers.h"
 #include "kudu/gutil/casts.h"
 #include "kudu/gutil/ref_counted.h"
 #include "kudu/gutil/stl_util.h"
@@ -234,7 +232,11 @@ static void LoggingAdapterCB(KuduLoggingCallback* user_cb,
 }
 
 void InstallLoggingCallback(KuduLoggingCallback* cb) {
-  RegisterLoggingCallback(Bind(&LoggingAdapterCB, Unretained(cb)));
+  RegisterLoggingCallback(
+      [=](LogSeverity severity, const char* filename, int line_number,
+          const struct ::tm* time, const char* message, size_t message_len) {
+        LoggingAdapterCB(cb, severity, filename, line_number, time, message, message_len);
+      });
 }
 
 void UninstallLoggingCallback() {
diff --git a/src/kudu/util/logging.cc b/src/kudu/util/logging.cc
index 0ad4504..96b9a54 100644
--- a/src/kudu/util/logging.cc
+++ b/src/kudu/util/logging.cc
@@ -24,6 +24,7 @@
 #include <cstdlib>
 #include <ctime>
 #include <fstream>
+#include <functional>
 #include <initializer_list>
 #include <mutex>
 #include <utility>
@@ -34,7 +35,6 @@
 #include <glog/logging.h>
 
 #include "kudu/gutil/basictypes.h"
-#include "kudu/gutil/callback.h"  // IWYU pragma: keep
 #include "kudu/gutil/port.h"
 #include "kudu/gutil/spinlock.h"
 #include "kudu/gutil/stringprintf.h"
@@ -118,7 +118,7 @@ class SimpleSink : public google::LogSink {
       default:
         LOG(FATAL) << "Unknown glog severity: " << severity;
     }
-    cb_.Run(kudu_severity, full_filename, line, tm_time, message, message_len);
+    cb_(kudu_severity, full_filename, line, tm_time, message, message_len);
   }
 
  private:
diff --git a/src/kudu/util/logging_callback.h b/src/kudu/util/logging_callback.h
index 83fb973..5920bea 100644
--- a/src/kudu/util/logging_callback.h
+++ b/src/kudu/util/logging_callback.h
@@ -14,14 +14,12 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-#ifndef KUDU_UTIL_LOGGING_CALLBACK_H
-#define KUDU_UTIL_LOGGING_CALLBACK_H
+#pragma once
 
 #include <ctime>
+#include <functional>
 #include <string>
 
-#include "kudu/gutil/callback_forward.h"
-
 namespace kudu {
 
 enum LogSeverity {
@@ -34,13 +32,11 @@ enum LogSeverity {
 // Callback for simple logging.
 //
 // 'message' is NOT terminated with an endline.
-typedef Callback<void(LogSeverity severity,
-                      const char* filename,
-                      int line_number,
-                      const struct ::tm* time,
-                      const char* message,
-                      size_t message_len)> LoggingCallback;
+typedef std::function<void(LogSeverity severity,
+                           const char* filename,
+                           int line_number,
+                           const struct ::tm* time,
+                           const char* message,
+                           size_t message_len)> LoggingCallback;
 
 } // namespace kudu
-
-#endif


[kudu] 04/07: rpc: remove kudu::Bind usage from ServerPicker

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

adar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 56ec81e06dd7e25f5513521256085d40309446b0
Author: Adar Dembo <ad...@cloudera.com>
AuthorDate: Sat Mar 28 01:27:37 2020 -0700

    rpc: remove kudu::Bind usage from ServerPicker
    
    Snuck in a Bind removal from batcher.cc too.
    
    Change-Id: I40554f59152eec1b84171f16f1fa2b91aa3a1e55
    Reviewed-on: http://gerrit.cloudera.org:8080/15578
    Tested-by: Adar Dembo <ad...@cloudera.com>
    Reviewed-by: Alexey Serbin <as...@cloudera.com>
    Reviewed-by: Andrew Wong <aw...@cloudera.com>
---
 src/kudu/client/batcher.cc            |  4 ++--
 src/kudu/client/meta_cache.cc         |  5 ++---
 src/kudu/client/meta_cache.h          |  6 +++---
 src/kudu/rpc/exactly_once_rpc-test.cc | 11 +++++------
 src/kudu/rpc/retriable_rpc.h          |  9 +++++----
 src/kudu/rpc/rpc.h                    |  3 +--
 6 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/src/kudu/client/batcher.cc b/src/kudu/client/batcher.cc
index e673ac8..3653173 100644
--- a/src/kudu/client/batcher.cc
+++ b/src/kudu/client/batcher.cc
@@ -45,7 +45,7 @@
 #include "kudu/common/wire_protocol.h"
 #include "kudu/common/wire_protocol.pb.h"
 #include "kudu/gutil/atomic_refcount.h"
-#include "kudu/gutil/bind_helpers.h"
+#include "kudu/gutil/basictypes.h"
 #include "kudu/gutil/map-util.h"
 #include "kudu/gutil/port.h"
 #include "kudu/gutil/strings/substitute.h"
@@ -733,7 +733,7 @@ Status Batcher::Add(KuduWriteOperation* write_op) {
       MetaCache::LookupType::kPoint,
       &op->tablet,
       [self, op_raw](const Status& s) { self->TabletLookupFinished(op_raw, s); });
-  IgnoreResult(op.release());
+  ignore_result(op.release());
 
   buffer_bytes_used_.IncrementBy(write_op->SizeInBuffer());
 
diff --git a/src/kudu/client/meta_cache.cc b/src/kudu/client/meta_cache.cc
index 263659c..b005256 100644
--- a/src/kudu/client/meta_cache.cc
+++ b/src/kudu/client/meta_cache.cc
@@ -38,7 +38,6 @@
 #include "kudu/common/wire_protocol.h"
 #include "kudu/consensus/metadata.pb.h"
 #include "kudu/gutil/basictypes.h"
-#include "kudu/gutil/callback.h"
 #include "kudu/gutil/map-util.h"
 #include "kudu/gutil/port.h"
 #include "kudu/gutil/stl_util.h"
@@ -495,7 +494,7 @@ void MetaCacheServerPicker::LookUpTabletCb(const ServerPickedCallback& callback,
 
   // If we couldn't lookup the tablet call the user callback immediately.
   if (!status.ok()) {
-    callback.Run(status, nullptr);
+    callback(status, nullptr);
     return;
   }
 
@@ -509,7 +508,7 @@ void MetaCacheServerPicker::LookUpTabletCb(const ServerPickedCallback& callback,
 void MetaCacheServerPicker::InitProxyCb(const ServerPickedCallback& callback,
                                         RemoteTabletServer* replica,
                                         const Status& status) {
-  callback.Run(status, replica);
+  callback(status, replica);
 }
 
 
diff --git a/src/kudu/client/meta_cache.h b/src/kudu/client/meta_cache.h
index c645f54..2e9a216 100644
--- a/src/kudu/client/meta_cache.h
+++ b/src/kudu/client/meta_cache.h
@@ -164,9 +164,9 @@ class MetaCacheServerPicker : public rpc::ServerPicker<RemoteTabletServer> {
                       const Status& status);
 
   // Called when the proxy is initialized.
-  void InitProxyCb(const ServerPickedCallback& callback,
-                   RemoteTabletServer* replica,
-                   const Status& status);
+  static void InitProxyCb(const ServerPickedCallback& callback,
+                          RemoteTabletServer* replica,
+                          const Status& status);
 
   // Lock protecting accesses/updates to 'followers_'.
   mutable simple_spinlock lock_;
diff --git a/src/kudu/rpc/exactly_once_rpc-test.cc b/src/kudu/rpc/exactly_once_rpc-test.cc
index 4d7a0fd..5a93e3a 100644
--- a/src/kudu/rpc/exactly_once_rpc-test.cc
+++ b/src/kudu/rpc/exactly_once_rpc-test.cc
@@ -32,7 +32,6 @@
 #include <glog/logging.h>
 #include <gtest/gtest.h>
 
-#include "kudu/gutil/callback.h"
 #include "kudu/gutil/ref_counted.h"
 #include "kudu/rpc/request_tracker.h"
 #include "kudu/rpc/response_callback.h"
@@ -90,13 +89,13 @@ class TestServerPicker : public ServerPicker<CalculatorServiceProxy> {
  public:
   explicit TestServerPicker(CalculatorServiceProxy* proxy) : proxy_(proxy) {}
 
-  void PickLeader(const ServerPickedCallback& callback, const MonoTime& deadline) override {
-    callback.Run(Status::OK(), proxy_);
+  void PickLeader(const ServerPickedCallback& callback, const MonoTime& /*deadline*/) override {
+    callback(Status::OK(), proxy_);
   }
 
-  void MarkServerFailed(CalculatorServiceProxy*, const Status&) override {}
-  void MarkReplicaNotLeader(CalculatorServiceProxy*) override {}
-  void MarkResourceNotFound(CalculatorServiceProxy*) override {}
+  void MarkServerFailed(CalculatorServiceProxy* /*server*/, const Status& /*status*/) override {}
+  void MarkReplicaNotLeader(CalculatorServiceProxy* /*replica*/) override {}
+  void MarkResourceNotFound(CalculatorServiceProxy* /*replica*/) override {}
 
  private:
   CalculatorServiceProxy* proxy_;
diff --git a/src/kudu/rpc/retriable_rpc.h b/src/kudu/rpc/retriable_rpc.h
index 8bca0c4..aa0d207 100644
--- a/src/kudu/rpc/retriable_rpc.h
+++ b/src/kudu/rpc/retriable_rpc.h
@@ -21,7 +21,6 @@
 
 #include <boost/bind.hpp>
 
-#include "kudu/gutil/bind.h"
 #include "kudu/gutil/ref_counted.h"
 #include "kudu/gutil/strings/substitute.h"
 #include "kudu/rpc/messenger.h"
@@ -162,9 +161,11 @@ void RetriableRpc<Server, RequestPB, ResponsePB>::SendRpc()  {
   if (sequence_number_ == RequestTracker::kNoSeqNo) {
     CHECK_OK(request_tracker_->NewSeqNo(&sequence_number_));
   }
-  server_picker_->PickLeader(Bind(&RetriableRpc::ReplicaFoundCb,
-                                  Unretained(this)),
-                             retrier().deadline());
+  server_picker_->PickLeader(
+      [this](const Status& status, Server* server) {
+        this->ReplicaFoundCb(status, server);
+      },
+      retrier().deadline());
 }
 
 template <class Server, class RequestPB, class ResponsePB>
diff --git a/src/kudu/rpc/rpc.h b/src/kudu/rpc/rpc.h
index 541efa8..32f2112 100644
--- a/src/kudu/rpc/rpc.h
+++ b/src/kudu/rpc/rpc.h
@@ -20,7 +20,6 @@
 #include <string>
 #include <utility>
 
-#include "kudu/gutil/callback.h"
 #include "kudu/gutil/macros.h"
 #include "kudu/gutil/ref_counted.h"
 #include "kudu/rpc/rpc_controller.h"
@@ -90,7 +89,7 @@ class ServerPicker : public RefCountedThreadSafe<ServerPicker<Server>> {
  public:
   virtual ~ServerPicker() {}
 
-  typedef Callback<void(const Status& status, Server* server)> ServerPickedCallback;
+  typedef std::function<void(const Status&, Server*)> ServerPickedCallback;
 
   // Picks the leader among the replicas serving a resource.
   // If the leader was found, it calls the callback with Status::OK() and


[kudu] 05/07: fs: remove kudu::Bind usage from ErrorManager

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

adar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit ea9243a10cfa7d67547d3e1996af35b0455d1e97
Author: Adar Dembo <ad...@cloudera.com>
AuthorDate: Sat Mar 28 01:42:01 2020 -0700

    fs: remove kudu::Bind usage from ErrorManager
    
    Change-Id: I15df4eda0e205535df5ec3700f66164840a1b183
    Reviewed-on: http://gerrit.cloudera.org:8080/15579
    Tested-by: Adar Dembo <ad...@cloudera.com>
    Reviewed-by: Alexey Serbin <as...@cloudera.com>
    Reviewed-by: Andrew Wong <aw...@cloudera.com>
---
 src/kudu/fs/error_manager-test.cc     | 36 +++++++++++++++++++----------------
 src/kudu/fs/error_manager.cc          | 11 +++++------
 src/kudu/fs/error_manager.h           |  5 ++---
 src/kudu/fs/fs_manager.cc             |  9 +++++----
 src/kudu/fs/log_block_manager-test.cc |  9 +++++----
 src/kudu/master/master.cc             |  5 ++---
 src/kudu/tserver/tablet_server.cc     | 15 +++++++++------
 7 files changed, 48 insertions(+), 42 deletions(-)

diff --git a/src/kudu/fs/error_manager-test.cc b/src/kudu/fs/error_manager-test.cc
index 33a4866..538d3db 100644
--- a/src/kudu/fs/error_manager-test.cc
+++ b/src/kudu/fs/error_manager-test.cc
@@ -15,11 +15,14 @@
 // specific language governing permissions and limitations
 // under the License.
 
+#include "kudu/fs/error_manager.h"
+
+#include <cstdlib>
+#include <functional>
 #include <map>
 #include <memory>
 #include <set>
 #include <sstream>
-#include <stdlib.h>
 #include <string>
 #include <thread>
 #include <vector>
@@ -27,9 +30,6 @@
 #include <glog/logging.h>
 #include <gtest/gtest.h>
 
-#include "kudu/fs/error_manager.h"
-#include "kudu/gutil/bind.h"
-#include "kudu/gutil/bind_helpers.h"
 #include "kudu/gutil/map-util.h"
 #include "kudu/gutil/strings/join.h"
 #include "kudu/gutil/threading/thread_collision_warner.h"
@@ -129,9 +129,10 @@ TEST_F(FsErrorManagerTest, TestBasicRegistration) {
 
   // Register a callback to update the first '-1' entry in test_vec_ to '0'
   // after waiting a random amount of time.
-  em()->SetErrorNotificationCb(ErrorHandlerType::DISK_ERROR,
-      Bind(&FsErrorManagerTest::SleepAndWriteFirstEmptyCb,
-           Unretained(this), ErrorHandlerType::DISK_ERROR));
+  em()->SetErrorNotificationCb(
+      ErrorHandlerType::DISK_ERROR, [this](const string& uuid) {
+        this->SleepAndWriteFirstEmptyCb(ErrorHandlerType::DISK_ERROR, uuid);
+      });
   em()->RunErrorNotificationCb(ErrorHandlerType::DISK_ERROR, "");
   ASSERT_EQ(0, FindFirst(ErrorHandlerType::DISK_ERROR));
 
@@ -141,9 +142,10 @@ TEST_F(FsErrorManagerTest, TestBasicRegistration) {
   ASSERT_EQ(-1, FindFirst(ErrorHandlerType::NO_AVAILABLE_DISKS));
 
   // Now register another callback.
-  em()->SetErrorNotificationCb(ErrorHandlerType::NO_AVAILABLE_DISKS,
-      Bind(&FsErrorManagerTest::SleepAndWriteFirstEmptyCb,
-           Unretained(this), ErrorHandlerType::NO_AVAILABLE_DISKS));
+  em()->SetErrorNotificationCb(
+      ErrorHandlerType::NO_AVAILABLE_DISKS, [this](const string& uuid) {
+        this->SleepAndWriteFirstEmptyCb(ErrorHandlerType::NO_AVAILABLE_DISKS, uuid);
+      });
   em()->RunErrorNotificationCb(ErrorHandlerType::NO_AVAILABLE_DISKS, "");
   ASSERT_EQ(1, FindFirst(ErrorHandlerType::NO_AVAILABLE_DISKS));
 
@@ -162,12 +164,14 @@ TEST_F(FsErrorManagerTest, TestBasicRegistration) {
 
 // Test that the callbacks get run serially.
 TEST_F(FsErrorManagerTest, TestSerialization) {
-  em()->SetErrorNotificationCb(ErrorHandlerType::DISK_ERROR,
-      Bind(&FsErrorManagerTest::SleepAndWriteFirstEmptyCb,
-           Unretained(this), ErrorHandlerType::DISK_ERROR));
-  em()->SetErrorNotificationCb(ErrorHandlerType::NO_AVAILABLE_DISKS,
-      Bind(&FsErrorManagerTest::SleepAndWriteFirstEmptyCb,
-           Unretained(this), ErrorHandlerType::NO_AVAILABLE_DISKS));
+  em()->SetErrorNotificationCb(
+      ErrorHandlerType::DISK_ERROR, [this](const string& uuid) {
+        this->SleepAndWriteFirstEmptyCb(ErrorHandlerType::DISK_ERROR, uuid);
+      });
+  em()->SetErrorNotificationCb(
+      ErrorHandlerType::NO_AVAILABLE_DISKS, [this](const string& uuid) {
+        this->SleepAndWriteFirstEmptyCb(ErrorHandlerType::NO_AVAILABLE_DISKS, uuid);
+      });
 
   // Swap back and forth between error-handler type.
   const auto IntToEnum = [&] (int i) {
diff --git a/src/kudu/fs/error_manager.cc b/src/kudu/fs/error_manager.cc
index 0e2bb41..55b78db 100644
--- a/src/kudu/fs/error_manager.cc
+++ b/src/kudu/fs/error_manager.cc
@@ -21,7 +21,6 @@
 #include <string>
 #include <utility>
 
-#include "kudu/gutil/bind.h"
 #include "kudu/gutil/map-util.h"
 
 using std::string;
@@ -33,9 +32,9 @@ namespace fs {
 static void DoNothingErrorNotification(const string& /* uuid */) {}
 
 FsErrorManager::FsErrorManager() {
-  InsertOrDie(&callbacks_, ErrorHandlerType::DISK_ERROR, Bind(DoNothingErrorNotification));
-  InsertOrDie(&callbacks_, ErrorHandlerType::NO_AVAILABLE_DISKS, Bind(DoNothingErrorNotification));
-  InsertOrDie(&callbacks_, ErrorHandlerType::CFILE_CORRUPTION, Bind(DoNothingErrorNotification));
+  InsertOrDie(&callbacks_, ErrorHandlerType::DISK_ERROR, &DoNothingErrorNotification);
+  InsertOrDie(&callbacks_, ErrorHandlerType::NO_AVAILABLE_DISKS, &DoNothingErrorNotification);
+  InsertOrDie(&callbacks_, ErrorHandlerType::CFILE_CORRUPTION, &DoNothingErrorNotification);
 }
 
 void FsErrorManager::SetErrorNotificationCb(ErrorHandlerType e, ErrorNotificationCb cb) {
@@ -45,12 +44,12 @@ void FsErrorManager::SetErrorNotificationCb(ErrorHandlerType e, ErrorNotificatio
 
 void FsErrorManager::UnsetErrorNotificationCb(ErrorHandlerType e) {
   std::lock_guard<Mutex> l(lock_);
-  EmplaceOrUpdate(&callbacks_, e, Bind(DoNothingErrorNotification));
+  EmplaceOrUpdate(&callbacks_, e, &DoNothingErrorNotification);
 }
 
 void FsErrorManager::RunErrorNotificationCb(ErrorHandlerType e, const string& uuid) const {
   std::lock_guard<Mutex> l(lock_);
-  FindOrDie(callbacks_, e).Run(uuid);
+  FindOrDie(callbacks_, e)(uuid);
 }
 
 }  // namespace fs
diff --git a/src/kudu/fs/error_manager.h b/src/kudu/fs/error_manager.h
index 6348971..b045223 100644
--- a/src/kudu/fs/error_manager.h
+++ b/src/kudu/fs/error_manager.h
@@ -14,9 +14,9 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-
 #pragma once
 
+#include <functional>
 #include <string>
 #include <unordered_map>
 #include <utility>
@@ -25,7 +25,6 @@
 
 #include "kudu/fs/dir_manager.h"
 #include "kudu/fs/dir_util.h"
-#include "kudu/gutil/callback.h"
 #include "kudu/gutil/port.h"
 #include "kudu/util/mutex.h"
 
@@ -37,7 +36,7 @@ namespace fs {
 //
 // e.g. the ErrorNotificationCb for disk failure handling takes the UUID of a
 // directory, marks it failed, and shuts down the tablets in that directory.
-typedef Callback<void(const std::string&)> ErrorNotificationCb;
+typedef std::function<void(const std::string&)> ErrorNotificationCb;
 
 // Evaluates the expression and handles it if it results in an error.
 // Returns if the status is an error.
diff --git a/src/kudu/fs/fs_manager.cc b/src/kudu/fs/fs_manager.cc
index 09f623a..3b866f8 100644
--- a/src/kudu/fs/fs_manager.cc
+++ b/src/kudu/fs/fs_manager.cc
@@ -19,6 +19,7 @@
 
 #include <cinttypes>
 #include <ctime>
+#include <functional>
 #include <initializer_list>
 #include <iostream>
 #include <unordered_map>
@@ -37,8 +38,6 @@
 #include "kudu/fs/fs.pb.h"
 #include "kudu/fs/fs_report.h"
 #include "kudu/fs/log_block_manager.h"
-#include "kudu/gutil/bind.h"
-#include "kudu/gutil/bind_helpers.h"
 #include "kudu/gutil/map-util.h"
 #include "kudu/gutil/port.h"
 #include "kudu/gutil/stringprintf.h"
@@ -423,8 +422,10 @@ Status FsManager::Open(FsReport* report) {
   }
 
   // Set an initial error handler to mark data directories as failed.
-  error_manager_->SetErrorNotificationCb(ErrorHandlerType::DISK_ERROR,
-      Bind(&DataDirManager::MarkDirFailedByUuid, Unretained(dd_manager_.get())));
+  error_manager_->SetErrorNotificationCb(
+      ErrorHandlerType::DISK_ERROR, [this](const string& uuid) {
+        this->dd_manager_->MarkDirFailedByUuid(uuid);
+      });
 
   // Finally, initialize and open the block manager if needed.
   if (!opts_.skip_block_manager) {
diff --git a/src/kudu/fs/log_block_manager-test.cc b/src/kudu/fs/log_block_manager-test.cc
index e1e2676..37c13ec 100644
--- a/src/kudu/fs/log_block_manager-test.cc
+++ b/src/kudu/fs/log_block_manager-test.cc
@@ -22,6 +22,7 @@
 #include <cstdlib>
 #include <cstring>
 #include <deque>
+#include <functional>
 #include <initializer_list>
 #include <memory>
 #include <ostream>
@@ -45,8 +46,6 @@
 #include "kudu/fs/fs.pb.h"
 #include "kudu/fs/fs_report.h"
 #include "kudu/fs/log_block_manager-test-util.h"
-#include "kudu/gutil/bind.h"
-#include "kudu/gutil/bind_helpers.h"
 #include "kudu/gutil/casts.h"
 #include "kudu/gutil/map-util.h"
 #include "kudu/gutil/ref_counted.h"
@@ -1689,8 +1688,10 @@ TEST_F(LogBlockManagerTest, TestOpenWithFailedDirectories) {
       DataDirManagerOptions(), &dd_manager_));
 
   // Wire in a callback to fail data directories.
-  error_manager_.SetErrorNotificationCb(ErrorHandlerType::DISK_ERROR,
-      Bind(&DataDirManager::MarkDirFailedByUuid, Unretained(dd_manager_.get())));
+  error_manager_.SetErrorNotificationCb(
+      ErrorHandlerType::DISK_ERROR, [this](const string& uuid) {
+        this->dd_manager_->MarkDirFailedByUuid(uuid);
+      });
   bm_.reset(CreateBlockManager(nullptr));
 
   // Fail one of the directories, chosen randomly.
diff --git a/src/kudu/master/master.cc b/src/kudu/master/master.cc
index 0226a72..f55cc6a 100644
--- a/src/kudu/master/master.cc
+++ b/src/kudu/master/master.cc
@@ -35,7 +35,6 @@
 #include "kudu/consensus/raft_consensus.h"
 #include "kudu/fs/error_manager.h"
 #include "kudu/fs/fs_manager.h"
-#include "kudu/gutil/bind.h"
 #include "kudu/gutil/ref_counted.h"
 #include "kudu/gutil/strings/substitute.h"
 #include "kudu/master/catalog_manager.h"
@@ -169,9 +168,9 @@ Status Master::Start() {
 Status Master::StartAsync() {
   CHECK_EQ(kInitialized, state_);
   fs_manager_->SetErrorNotificationCb(ErrorHandlerType::DISK_ERROR,
-                                      Bind(&Master::CrashMasterOnDiskError));
+                                      &CrashMasterOnDiskError);
   fs_manager_->SetErrorNotificationCb(ErrorHandlerType::CFILE_CORRUPTION,
-                                      Bind(&Master::CrashMasterOnCFileCorruption));
+                                      &CrashMasterOnCFileCorruption);
 
   RETURN_NOT_OK(maintenance_manager_->Start());
 
diff --git a/src/kudu/tserver/tablet_server.cc b/src/kudu/tserver/tablet_server.cc
index b82d359..dd33ecb 100644
--- a/src/kudu/tserver/tablet_server.cc
+++ b/src/kudu/tserver/tablet_server.cc
@@ -17,6 +17,7 @@
 
 #include "kudu/tserver/tablet_server.h"
 
+#include <functional>
 #include <memory>
 #include <ostream>
 #include <utility>
@@ -27,8 +28,6 @@
 #include "kudu/cfile/block_cache.h"
 #include "kudu/fs/error_manager.h"
 #include "kudu/fs/fs_manager.h"
-#include "kudu/gutil/bind.h"
-#include "kudu/gutil/bind_helpers.h"
 #include "kudu/gutil/strings/substitute.h"
 #include "kudu/rpc/service_if.h"
 #include "kudu/server/rpc_server.h"
@@ -122,10 +121,14 @@ Status TabletServer::WaitInited() {
 Status TabletServer::Start() {
   CHECK_EQ(kInitialized, state_);
 
-  fs_manager_->SetErrorNotificationCb(ErrorHandlerType::DISK_ERROR,
-      Bind(&TSTabletManager::FailTabletsInDataDir, Unretained(tablet_manager_.get())));
-  fs_manager_->SetErrorNotificationCb(ErrorHandlerType::CFILE_CORRUPTION,
-      Bind(&TSTabletManager::FailTabletAndScheduleShutdown, Unretained(tablet_manager_.get())));
+  fs_manager_->SetErrorNotificationCb(
+      ErrorHandlerType::DISK_ERROR, [this](const string& uuid) {
+        this->tablet_manager_->FailTabletsInDataDir(uuid);
+      });
+  fs_manager_->SetErrorNotificationCb(
+      ErrorHandlerType::CFILE_CORRUPTION, [this](const string& uuid) {
+        this->tablet_manager_->FailTabletAndScheduleShutdown(uuid);
+      });
 
   unique_ptr<ServiceIf> ts_service(new TabletServiceImpl(this));
   unique_ptr<ServiceIf> admin_service(new TabletServiceAdminImpl(this));


[kudu] 02/07: gutil: remove BASE_EXPORT

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

adar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 5db82975fd9729d90551b7a4c8f4b28b5375deef
Author: Adar Dembo <ad...@cloudera.com>
AuthorDate: Sat Mar 28 01:22:31 2020 -0700

    gutil: remove BASE_EXPORT
    
    The various definitions of BASE_EXPORT cause IWYU to recommend the inclusion
    of thread_collision_warner.h as a means of satisfying them. Since it serves
    no purpose in Kudu, let's remove the macro altogether.
    
    Change-Id: I8e1650f3a18b17898ab8082923fc2fb9c8471946
    Reviewed-on: http://gerrit.cloudera.org:8080/15576
    Tested-by: Kudu Jenkins
    Reviewed-by: Alexey Serbin <as...@cloudera.com>
    Reviewed-by: Andrew Wong <aw...@cloudera.com>
---
 src/kudu/gutil/atomicops-internals-tsan.h          | 11 +++--------
 src/kudu/gutil/bind_helpers.h                      |  4 ----
 src/kudu/gutil/ref_counted_memory.h                | 18 +++++++-----------
 src/kudu/gutil/threading/thread_collision_warner.h | 16 ++++++----------
 src/kudu/util/debug/trace_event.h                  | 12 ++++--------
 src/kudu/util/debug/trace_event_impl.cc            |  3 ++-
 src/kudu/util/debug/trace_event_impl.h             | 13 ++++++-------
 src/kudu/util/debug/trace_event_synthetic_delay.h  | 10 +++++-----
 8 files changed, 33 insertions(+), 54 deletions(-)

diff --git a/src/kudu/gutil/atomicops-internals-tsan.h b/src/kudu/gutil/atomicops-internals-tsan.h
index dea45b0..1dd1c75 100644
--- a/src/kudu/gutil/atomicops-internals-tsan.h
+++ b/src/kudu/gutil/atomicops-internals-tsan.h
@@ -9,20 +9,15 @@
 #ifndef BASE_ATOMICOPS_INTERNALS_TSAN_H_
 #define BASE_ATOMICOPS_INTERNALS_TSAN_H_
 
-// Workaround for Chromium BASE_EXPORT definition
-#ifndef BASE_EXPORT
-#define BASE_EXPORT
-#endif
-
 // This struct is not part of the public API of this module; clients may not
-// use it.  (However, it's exported via BASE_EXPORT because clients implicitly
-// do use it at link time by inlining these functions.)
+// use it.
+//
 // Features of this x86.  Values may not be correct before main() is run,
 // but are set conservatively.
 struct AtomicOps_x86CPUFeatureStruct {
   bool has_sse2;             // Processor has SSE2.
 };
-BASE_EXPORT extern struct AtomicOps_x86CPUFeatureStruct
+extern struct AtomicOps_x86CPUFeatureStruct
     AtomicOps_Internalx86CPUFeatures;
 
 #define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("" : : : "memory")
diff --git a/src/kudu/gutil/bind_helpers.h b/src/kudu/gutil/bind_helpers.h
index 8a106a6..f8dabe6 100644
--- a/src/kudu/gutil/bind_helpers.h
+++ b/src/kudu/gutil/bind_helpers.h
@@ -149,10 +149,6 @@
 #include "kudu/gutil/callback.h"
 #include "kudu/gutil/template_util.h"
 
-// Unneeded define from Chromium
-#define BASE_EXPORT
-
-
 namespace kudu {
 namespace internal {
 
diff --git a/src/kudu/gutil/ref_counted_memory.h b/src/kudu/gutil/ref_counted_memory.h
index d180db9..23ced27 100644
--- a/src/kudu/gutil/ref_counted_memory.h
+++ b/src/kudu/gutil/ref_counted_memory.h
@@ -15,16 +15,12 @@
 #include "kudu/gutil/port.h"
 #include "kudu/gutil/threading/thread_collision_warner.h"
 
-#ifndef BASE_EXPORT
-#define BASE_EXPORT
-#endif
-
 namespace kudu {
 
 // A generic interface to memory. This object is reference counted because one
 // of its two subclasses own the data they carry, and we need to have
 // heterogeneous containers of these two types of memory.
-class BASE_EXPORT RefCountedMemory
+class RefCountedMemory
     : public RefCountedThreadSafe<RefCountedMemory> {
  public:
   // Retrieves a pointer to the beginning of the data we point to. If the data
@@ -50,12 +46,12 @@ class BASE_EXPORT RefCountedMemory
 
 // An implementation of RefCountedMemory, where the ref counting does not
 // matter.
-class BASE_EXPORT RefCountedStaticMemory : public RefCountedMemory {
+class RefCountedStaticMemory : public RefCountedMemory {
  public:
   RefCountedStaticMemory()
-      : data_(NULL), length_(0) {}
+      : data_(nullptr), length_(0) {}
   RefCountedStaticMemory(const void* data, size_t length)
-      : data_(static_cast<const unsigned char*>(length ? data : NULL)),
+      : data_(static_cast<const unsigned char*>(length ? data : nullptr)),
         length_(length) {}
 
   // Overridden from RefCountedMemory:
@@ -72,7 +68,7 @@ class BASE_EXPORT RefCountedStaticMemory : public RefCountedMemory {
 };
 
 // An implementation of RefCountedMemory, where we own the data in a vector.
-class BASE_EXPORT RefCountedBytes : public RefCountedMemory {
+class RefCountedBytes : public RefCountedMemory {
  public:
   RefCountedBytes();
 
@@ -104,7 +100,7 @@ class BASE_EXPORT RefCountedBytes : public RefCountedMemory {
 
 // An implementation of RefCountedMemory, where the bytes are stored in an STL
 // string. Use this if your data naturally arrives in that format.
-class BASE_EXPORT RefCountedString : public RefCountedMemory {
+class RefCountedString : public RefCountedMemory {
  public:
   RefCountedString();
 
@@ -131,7 +127,7 @@ class BASE_EXPORT RefCountedString : public RefCountedMemory {
 // An implementation of RefCountedMemory that holds a chunk of memory
 // previously allocated with malloc or calloc, and that therefore must be freed
 // using free().
-class BASE_EXPORT RefCountedMallocedMemory : public RefCountedMemory {
+class RefCountedMallocedMemory : public RefCountedMemory {
  public:
   RefCountedMallocedMemory(void* data, size_t length);
 
diff --git a/src/kudu/gutil/threading/thread_collision_warner.h b/src/kudu/gutil/threading/thread_collision_warner.h
index 9cad17f..d042b33 100644
--- a/src/kudu/gutil/threading/thread_collision_warner.h
+++ b/src/kudu/gutil/threading/thread_collision_warner.h
@@ -10,10 +10,6 @@
 #include "kudu/gutil/atomicops.h"
 #include "kudu/gutil/macros.h"
 
-#ifndef BASE_EXPORT
-#define BASE_EXPORT
-#endif
-
 // A helper class alongside macros to be used to verify assumptions about thread
 // safety of a class.
 //
@@ -134,17 +130,17 @@ namespace base {
 // AsserterBase is the interfaces and DCheckAsserter is the default asserter
 // used. During the unit tests is used another class that doesn't "DCHECK"
 // in case of collision (check thread_collision_warner_unittests.cc)
-struct BASE_EXPORT AsserterBase {
+struct AsserterBase {
   virtual ~AsserterBase() {}
   virtual void warn(int64_t previous_thread_id, int64_t current_thread_id) = 0;
 };
 
-struct BASE_EXPORT DCheckAsserter : public AsserterBase {
+struct DCheckAsserter : public AsserterBase {
   virtual ~DCheckAsserter() {}
   void warn(int64_t previous_thread_id, int64_t current_thread_id) override;
 };
 
-class BASE_EXPORT ThreadCollisionWarner {
+class ThreadCollisionWarner {
  public:
   // The parameter asserter is there only for test purpose
   explicit ThreadCollisionWarner(AsserterBase* asserter = new DCheckAsserter())
@@ -161,7 +157,7 @@ class BASE_EXPORT ThreadCollisionWarner {
   // it doesn't leave the critical section, as opposed to ScopedCheck,
   // because the critical section being pinned is allowed to be used only
   // from one thread
-  class BASE_EXPORT Check {
+  class Check {
    public:
     explicit Check(ThreadCollisionWarner* warner)
         : warner_(warner) {
@@ -178,7 +174,7 @@ class BASE_EXPORT ThreadCollisionWarner {
 
   // This class is meant to be used through the macro
   // DFAKE_SCOPED_LOCK
-  class BASE_EXPORT ScopedCheck {
+  class ScopedCheck {
    public:
     explicit ScopedCheck(ThreadCollisionWarner* warner)
         : warner_(warner) {
@@ -197,7 +193,7 @@ class BASE_EXPORT ThreadCollisionWarner {
 
   // This class is meant to be used through the macro
   // DFAKE_SCOPED_RECURSIVE_LOCK
-  class BASE_EXPORT ScopedRecursiveCheck {
+  class ScopedRecursiveCheck {
    public:
     explicit ScopedRecursiveCheck(ThreadCollisionWarner* warner)
         : warner_(warner) {
diff --git a/src/kudu/util/debug/trace_event.h b/src/kudu/util/debug/trace_event.h
index 2c51309..7bfc1a9 100644
--- a/src/kudu/util/debug/trace_event.h
+++ b/src/kudu/util/debug/trace_event.h
@@ -823,12 +823,8 @@
 #define TRACE_EVENT_API_ATOMIC_STORE(var, value) \
     base::subtle::NoBarrier_Store(&(var), (value))
 
-// Defines visibility for classes in trace_event.h
-#define TRACE_EVENT_API_CLASS_EXPORT BASE_EXPORT
-
 // The thread buckets for the sampling profiler.
-TRACE_EVENT_API_CLASS_EXPORT extern \
-    TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3];
+extern TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3];
 
 #define TRACE_EVENT_API_THREAD_BUCKET(thread_bucket)                           \
     g_trace_state[thread_bucket]
@@ -1377,10 +1373,10 @@ static inline kudu::debug::TraceEventHandle AddTraceEvent(
 }
 
 // Used by TRACE_EVENTx macros. Do not use directly.
-class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer {
+class ScopedTracer {
  public:
   // Note: members of data_ intentionally left uninitialized. See Initialize.
-  ScopedTracer() : p_data_(NULL) {}
+  ScopedTracer() : p_data_(nullptr) {}
 
   ~ScopedTracer() {
     if (p_data_ && *data_.category_group_enabled)
@@ -1413,7 +1409,7 @@ class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer {
 };
 
 // Used by TRACE_EVENT_BINARY_EFFICIENTx macro. Do not use directly.
-class TRACE_EVENT_API_CLASS_EXPORT ScopedTraceBinaryEfficient {
+class ScopedTraceBinaryEfficient {
  public:
   ScopedTraceBinaryEfficient(const char* category_group, const char* name);
   ~ScopedTraceBinaryEfficient();
diff --git a/src/kudu/util/debug/trace_event_impl.cc b/src/kudu/util/debug/trace_event_impl.cc
index f642657..6388243 100644
--- a/src/kudu/util/debug/trace_event_impl.cc
+++ b/src/kudu/util/debug/trace_event_impl.cc
@@ -22,6 +22,7 @@
 #include <gflags/gflags.h>
 
 #include "kudu/gutil/bind.h"
+#include "kudu/gutil/bind_helpers.h"
 #include "kudu/gutil/dynamic_annotations.h"
 #include "kudu/gutil/map-util.h"
 #include "kudu/gutil/mathlimits.h"
@@ -52,7 +53,7 @@ DEFINE_string(trace_to_console, "",
 TAG_FLAG(trace_to_console, experimental);
 
 // The thread buckets for the sampling profiler.
-BASE_EXPORT TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3];
+TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3];
 
 using base::SpinLockHolder;
 using strings::SubstituteAndAppend;
diff --git a/src/kudu/util/debug/trace_event_impl.h b/src/kudu/util/debug/trace_event_impl.h
index f0eb4c2..4503e0e 100644
--- a/src/kudu/util/debug/trace_event_impl.h
+++ b/src/kudu/util/debug/trace_event_impl.h
@@ -16,7 +16,6 @@
 #include <gtest/gtest_prod.h>
 
 #include "kudu/gutil/atomicops.h"
-#include "kudu/gutil/bind_helpers.h"
 #include "kudu/gutil/callback.h"
 #include "kudu/gutil/macros.h"
 #include "kudu/gutil/ref_counted.h"
@@ -87,7 +86,7 @@ struct TraceEventHandle {
 
 const int kTraceMaxNumArgs = 2;
 
-class BASE_EXPORT TraceEvent {
+class TraceEvent {
  public:
   union TraceValue {
     bool as_bool;
@@ -180,7 +179,7 @@ class BASE_EXPORT TraceEvent {
 };
 
 // TraceBufferChunk is the basic unit of TraceBuffer.
-class BASE_EXPORT TraceBufferChunk {
+class TraceBufferChunk {
  public:
   explicit TraceBufferChunk(uint32_t seq)
       : next_free_(0),
@@ -215,7 +214,7 @@ class BASE_EXPORT TraceBufferChunk {
 };
 
 // TraceBuffer holds the events as they are collected.
-class BASE_EXPORT TraceBuffer {
+class TraceBuffer {
  public:
   virtual ~TraceBuffer() {}
 
@@ -255,7 +254,7 @@ class TraceResultBuffer {
   std::string json_;
 };
 
-class BASE_EXPORT CategoryFilter {
+class CategoryFilter {
  public:
   typedef std::vector<std::string> StringList;
 
@@ -342,7 +341,7 @@ class BASE_EXPORT CategoryFilter {
 
 class TraceSamplingThread;
 
-class BASE_EXPORT TraceLog {
+class TraceLog {
  public:
   enum Mode {
     DISABLED = 0,
@@ -589,9 +588,9 @@ class BASE_EXPORT TraceLog {
   // category filter.
   void UpdateSyntheticDelaysFromCategoryFilter();
 
-  struct PerThreadInfo;
   class OptionalAutoLock;
   class ThreadLocalEventBuffer;
+  struct PerThreadInfo;
 
   TraceLog();
   ~TraceLog();
diff --git a/src/kudu/util/debug/trace_event_synthetic_delay.h b/src/kudu/util/debug/trace_event_synthetic_delay.h
index 5866814..12acec4 100644
--- a/src/kudu/util/debug/trace_event_synthetic_delay.h
+++ b/src/kudu/util/debug/trace_event_synthetic_delay.h
@@ -68,7 +68,7 @@ namespace kudu {
 namespace debug {
 
 // Time source for computing delay durations. Used for testing.
-class TRACE_EVENT_API_CLASS_EXPORT TraceEventSyntheticDelayClock {
+class TraceEventSyntheticDelayClock {
  public:
   TraceEventSyntheticDelayClock();
   virtual ~TraceEventSyntheticDelayClock();
@@ -79,7 +79,7 @@ class TRACE_EVENT_API_CLASS_EXPORT TraceEventSyntheticDelayClock {
 };
 
 // Single delay point instance.
-class TRACE_EVENT_API_CLASS_EXPORT TraceEventSyntheticDelay {
+class TraceEventSyntheticDelay {
  public:
   enum Mode {
     STATIC,      // Apply the configured delay every time.
@@ -136,7 +136,7 @@ class TRACE_EVENT_API_CLASS_EXPORT TraceEventSyntheticDelay {
 };
 
 // Set the target durations of all registered synthetic delay points to zero.
-TRACE_EVENT_API_CLASS_EXPORT void ResetTraceEventSyntheticDelays();
+void ResetTraceEventSyntheticDelays();
 
 }  // namespace debug
 }  // namespace kudu
@@ -144,7 +144,7 @@ TRACE_EVENT_API_CLASS_EXPORT void ResetTraceEventSyntheticDelays();
 namespace trace_event_internal {
 
 // Helper class for scoped delays. Do not use directly.
-class TRACE_EVENT_API_CLASS_EXPORT ScopedSyntheticDelay {
+class ScopedSyntheticDelay {
  public:
   explicit ScopedSyntheticDelay(const char* name,
                                 AtomicWord* impl_ptr);
@@ -158,7 +158,7 @@ class TRACE_EVENT_API_CLASS_EXPORT ScopedSyntheticDelay {
 };
 
 // Helper for registering delays. Do not use directly.
-TRACE_EVENT_API_CLASS_EXPORT kudu::debug::TraceEventSyntheticDelay*
+kudu::debug::TraceEventSyntheticDelay*
     GetOrCreateDelay(const char* name, AtomicWord* impl_ptr);
 
 }  // namespace trace_event_internal