kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [kudu] 04/07: rpc: remove kudu::Bind usage from ServerPicker
Date Mon, 30 Mar 2020 18:56:38 GMT
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 <adar@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 <adar@cloudera.com>
    Reviewed-by: Alexey Serbin <aserbin@cloudera.com>
    Reviewed-by: Andrew Wong <awong@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


Mime
View raw message