kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From granthe...@apache.org
Subject [kudu] 01/02: [consensus] simplify RpcPeerProxy a bit
Date Thu, 16 Jan 2020 17:12:00 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 50ac527ec1b046884eade2216f28dc3893eef95d
Author: Alexey Serbin <alexey@apache.org>
AuthorDate: Wed Jan 15 19:31:40 2020 -0800

    [consensus] simplify RpcPeerProxy a bit
    
    It's a small clean-up on the RpcPeerProxy class to avoid
    an extra call to operator new while preparing its HostPort
    parameter at call sites.
    
    Change-Id: Ie3185142ee16130f66609e88bcd3439956961c2e
    Reviewed-on: http://gerrit.cloudera.org:8080/15049
    Reviewed-by: Adar Dembo <adar@cloudera.com>
    Tested-by: Kudu Jenkins
---
 src/kudu/consensus/consensus_peers.cc | 13 ++++++-------
 src/kudu/consensus/consensus_peers.h  |  4 ++--
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/kudu/consensus/consensus_peers.cc b/src/kudu/consensus/consensus_peers.cc
index 5cd12f0..554ff4d 100644
--- a/src/kudu/consensus/consensus_peers.cc
+++ b/src/kudu/consensus/consensus_peers.cc
@@ -27,7 +27,6 @@
 #include <vector>
 
 #include <gflags/gflags.h>
-#include <gflags/gflags_declare.h>
 #include <glog/logging.h>
 
 #include "kudu/common/common.pb.h"
@@ -510,9 +509,9 @@ Peer::~Peer() {
   request_.mutable_ops()->ExtractSubrange(0, request_.ops_size(), nullptr);
 }
 
-RpcPeerProxy::RpcPeerProxy(gscoped_ptr<HostPort> hostport,
+RpcPeerProxy::RpcPeerProxy(HostPort hostport,
                            gscoped_ptr<ConsensusServiceProxy> consensus_proxy)
-    : hostport_(std::move(DCHECK_NOTNULL(hostport))),
+    : hostport_(std::move(hostport)),
       consensus_proxy_(std::move(DCHECK_NOTNULL(consensus_proxy))) {
 }
 
@@ -548,7 +547,7 @@ void RpcPeerProxy::StartTabletCopyAsync(const StartTabletCopyRequestPB&
request,
 }
 
 string RpcPeerProxy::PeerName() const {
-  return hostport_->ToString();
+  return hostport_.ToString();
 }
 
 namespace {
@@ -579,11 +578,11 @@ RpcPeerProxyFactory::RpcPeerProxyFactory(shared_ptr<Messenger>
messenger,
 
 Status RpcPeerProxyFactory::NewProxy(const RaftPeerPB& peer_pb,
                                      gscoped_ptr<PeerProxy>* proxy) {
-  gscoped_ptr<HostPort> hostport(new HostPort);
-  RETURN_NOT_OK(HostPortFromPB(peer_pb.last_known_addr(), hostport.get()));
+  HostPort hostport;
+  RETURN_NOT_OK(HostPortFromPB(peer_pb.last_known_addr(), &hostport));
   gscoped_ptr<ConsensusServiceProxy> new_proxy;
   RETURN_NOT_OK(CreateConsensusServiceProxyForHost(
-      *hostport, messenger_, dns_resolver_, &new_proxy));
+      hostport, messenger_, dns_resolver_, &new_proxy));
   proxy->reset(new RpcPeerProxy(std::move(hostport), std::move(new_proxy)));
   return Status::OK();
 }
diff --git a/src/kudu/consensus/consensus_peers.h b/src/kudu/consensus/consensus_peers.h
index acfdd8a..0b4f24b 100644
--- a/src/kudu/consensus/consensus_peers.h
+++ b/src/kudu/consensus/consensus_peers.h
@@ -251,7 +251,7 @@ class PeerProxyFactory {
 // PeerProxy implementation that does RPC calls
 class RpcPeerProxy : public PeerProxy {
  public:
-  RpcPeerProxy(gscoped_ptr<HostPort> hostport,
+  RpcPeerProxy(HostPort hostport,
                gscoped_ptr<ConsensusServiceProxy> consensus_proxy);
 
   void UpdateAsync(const ConsensusRequestPB& request,
@@ -277,7 +277,7 @@ class RpcPeerProxy : public PeerProxy {
   std::string PeerName() const override;
 
  private:
-  gscoped_ptr<HostPort> hostport_;
+  const HostPort hostport_;
   gscoped_ptr<ConsensusServiceProxy> consensus_proxy_;
 };
 


Mime
View raw message