kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdcry...@apache.org
Subject [3/9] incubator-kudu git commit: ksck: report hostnames instead of IP addresses for tablet servers
Date Fri, 22 Jul 2016 22:02:23 GMT
ksck: report hostnames instead of IP addresses for tablet servers

Typically admins know their hosts by hostname instead of by IP address.
This rejiggers the code a bit to save the original host/port instead of
the resolved address, so that the output contains a hostname instead
of an IP.

Tested manually against a cluster (hard to add an assertion since we
don't have the ability to mock DNS).

Change-Id: I8164dca050fd1adcc034a91cebc241e6fff8a117
Reviewed-on: http://gerrit.cloudera.org:8080/3704
Tested-by: Kudu Jenkins
Reviewed-by: Jean-Daniel Cryans <jdcryans@apache.org>


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

Branch: refs/heads/master
Commit: 7ba9d994448dade702c959febe51abebce65920c
Parents: 513d6e9
Author: Todd Lipcon <todd@apache.org>
Authored: Wed Jul 20 14:29:51 2016 -0700
Committer: Jean-Daniel Cryans <jdcryans@apache.org>
Committed: Fri Jul 22 20:23:31 2016 +0000

----------------------------------------------------------------------
 src/kudu/tools/ksck-test.cc   |  2 +-
 src/kudu/tools/ksck.h         |  2 +-
 src/kudu/tools/ksck_remote.cc | 20 +++++++++++++++-----
 src/kudu/tools/ksck_remote.h  | 25 +++++++++++++------------
 4 files changed, 30 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/7ba9d994/src/kudu/tools/ksck-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tools/ksck-test.cc b/src/kudu/tools/ksck-test.cc
index a9184ab..44fcf69 100644
--- a/src/kudu/tools/ksck-test.cc
+++ b/src/kudu/tools/ksck-test.cc
@@ -64,7 +64,7 @@ class MockKsckTabletServer : public KsckTabletServer {
     callback.Run(Status::OK(), 0);
   }
 
-  virtual const std::string& address() const OVERRIDE {
+  virtual std::string address() const OVERRIDE {
     return address_;
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/7ba9d994/src/kudu/tools/ksck.h
----------------------------------------------------------------------
diff --git a/src/kudu/tools/ksck.h b/src/kudu/tools/ksck.h
index 502f68e..80bc63d 100644
--- a/src/kudu/tools/ksck.h
+++ b/src/kudu/tools/ksck.h
@@ -197,7 +197,7 @@ class KsckTabletServer {
     return strings::Substitute("$0 ($1)", uuid(), address());
   }
 
-  virtual const std::string& address() const = 0;
+  virtual std::string address() const = 0;
 
   bool is_healthy() const {
     CHECK_NE(state_, kUninitialized);

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/7ba9d994/src/kudu/tools/ksck_remote.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tools/ksck_remote.cc b/src/kudu/tools/ksck_remote.cc
index 325865a..66a495a 100644
--- a/src/kudu/tools/ksck_remote.cc
+++ b/src/kudu/tools/ksck_remote.cc
@@ -45,6 +45,16 @@ MonoDelta GetDefaultTimeout() {
   return MonoDelta::FromMilliseconds(FLAGS_timeout_ms);
 }
 
+Status RemoteKsckTabletServer::Init() {
+  vector<Sockaddr> addresses;
+  RETURN_NOT_OK(ParseAddressList(
+      host_port_.ToString(),
+      tserver::TabletServer::kDefaultPort, &addresses));
+  generic_proxy_.reset(new server::GenericServiceProxy(messenger_, addresses[0]));
+  ts_proxy_.reset(new tserver::TabletServerServiceProxy(messenger_, addresses[0]));
+  return Status::OK();
+}
+
 Status RemoteKsckTabletServer::FetchInfo() {
   state_ = kFetchFailed;
 
@@ -262,11 +272,11 @@ Status RemoteKsckMaster::RetrieveTabletServers(TSMap* tablet_servers)
{
   tablet_servers->clear();
   for (const master::ListTabletServersResponsePB_Entry& e : resp.servers()) {
     HostPortPB addr = e.registration().rpc_addresses(0);
-    vector<Sockaddr> addresses;
-    RETURN_NOT_OK(ParseAddressList(HostPort(addr.host(), addr.port()).ToString(),
-                                   tserver::TabletServer::kDefaultPort, &addresses));
-    shared_ptr<KsckTabletServer> ts(
-        new RemoteKsckTabletServer(e.instance_id().permanent_uuid(), addresses[0], messenger_));
+    shared_ptr<RemoteKsckTabletServer> ts(
+        new RemoteKsckTabletServer(e.instance_id().permanent_uuid(),
+                                   HostPort(addr.host(), addr.port()),
+                                   messenger_));
+    RETURN_NOT_OK(ts->Init());
     InsertOrDie(tablet_servers, ts->uuid(), ts);
   }
   return Status::OK();

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/7ba9d994/src/kudu/tools/ksck_remote.h
----------------------------------------------------------------------
diff --git a/src/kudu/tools/ksck_remote.h b/src/kudu/tools/ksck_remote.h
index 5ca2a3b..9ba4e99 100644
--- a/src/kudu/tools/ksck_remote.h
+++ b/src/kudu/tools/ksck_remote.h
@@ -42,15 +42,17 @@ namespace tools {
 class RemoteKsckTabletServer : public KsckTabletServer {
  public:
   explicit RemoteKsckTabletServer(const std::string& id,
-                                  const Sockaddr& address,
-                                  const std::shared_ptr<rpc::Messenger>& messenger)
+                                  const HostPort host_port,
+                                  std::shared_ptr<rpc::Messenger> messenger)
       : KsckTabletServer(id),
-        address_(address.ToString()),
-        messenger_(messenger),
-        generic_proxy_(new server::GenericServiceProxy(messenger, address)),
-        ts_proxy_(new tserver::TabletServerServiceProxy(messenger, address)) {
+        host_port_(host_port),
+        messenger_(std::move(messenger)) {
   }
 
+  // Resolves the host/port and sets up proxies.
+  // Must be called after constructing.
+  Status Init();
+
   virtual Status FetchInfo() OVERRIDE;
 
   virtual void RunTabletChecksumScanAsync(
@@ -60,16 +62,15 @@ class RemoteKsckTabletServer : public KsckTabletServer {
       const ReportResultCallback& callback) OVERRIDE;
 
 
-  virtual const std::string& address() const OVERRIDE {
-    return address_;
+  virtual std::string address() const OVERRIDE {
+    return host_port_.ToString();
   }
 
  private:
-  const std::string address_;
+  const HostPort host_port_;
   const std::shared_ptr<rpc::Messenger> messenger_;
-  const std::shared_ptr<server::GenericServiceProxy> generic_proxy_;
-  const std::shared_ptr<tserver::TabletServerServiceProxy> ts_proxy_;
-
+  std::shared_ptr<server::GenericServiceProxy> generic_proxy_;
+  std::shared_ptr<tserver::TabletServerServiceProxy> ts_proxy_;
 };
 
 // This implementation connects to a Master via RPC.


Mime
View raw message