You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by al...@apache.org on 2018/10/25 20:54:54 UTC
kudu git commit: [client] expose location via internal API
Repository: kudu
Updated Branches:
refs/heads/master 9042eda2c -> eb6f4e8a8
[client] expose location via internal API
I added location info to client::KuduTabletServer and
client::internal::RemoteTabletServer to enable the future work on
location-aware C++ and Java clients.
Change-Id: Ib92cc6806073d32c859ae44ff803abb37cac99ac
Reviewed-on: http://gerrit.cloudera.org:8080/11679
Reviewed-by: Adar Dembo <ad...@cloudera.com>
Tested-by: Alexey Serbin <as...@cloudera.com>
Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/eb6f4e8a
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/eb6f4e8a
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/eb6f4e8a
Branch: refs/heads/master
Commit: eb6f4e8a8c56ca4e39de5e265e7de20a2e12263e
Parents: 9042eda
Author: fwang29 <fw...@cloudera.com>
Authored: Fri Oct 12 23:01:21 2018 -0700
Committer: Alexey Serbin <as...@cloudera.com>
Committed: Thu Oct 25 20:54:04 2018 +0000
----------------------------------------------------------------------
src/kudu/client/client.cc | 11 ++++++++---
src/kudu/client/client.h | 9 +++++++++
src/kudu/client/meta_cache.cc | 7 ++++++-
src/kudu/client/meta_cache.h | 4 ++++
src/kudu/client/scan_token-internal.cc | 3 ++-
src/kudu/client/tablet_server-internal.cc | 3 ++-
src/kudu/client/tablet_server-internal.h | 4 +++-
7 files changed, 34 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kudu/blob/eb6f4e8a/src/kudu/client/client.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/client.cc b/src/kudu/client/client.cc
index d301105..44f6b93 100644
--- a/src/kudu/client/client.cc
+++ b/src/kudu/client/client.cc
@@ -457,7 +457,7 @@ Status KuduClient::ListTabletServers(vector<KuduTabletServer*>* tablet_servers)
HostPort hp;
RETURN_NOT_OK(HostPortFromPB(e.registration().rpc_addresses(0), &hp));
unique_ptr<KuduTabletServer> ts(new KuduTabletServer);
- ts->data_ = new KuduTabletServer::Data(e.instance_id().permanent_uuid(), hp);
+ ts->data_ = new KuduTabletServer::Data(e.instance_id().permanent_uuid(), hp, e.location());
tablet_servers->push_back(ts.release());
}
return Status::OK();
@@ -580,7 +580,7 @@ Status KuduClient::GetTablet(const string& tablet_id, KuduTablet** tablet) {
HostPort hp;
RETURN_NOT_OK(HostPortFromPB(ts_info.rpc_addresses(0), &hp));
unique_ptr<KuduTabletServer> ts(new KuduTabletServer);
- ts->data_ = new KuduTabletServer::Data(ts_info.permanent_uuid(), hp);
+ ts->data_ = new KuduTabletServer::Data(ts_info.permanent_uuid(), hp, ts_info.location());
// TODO(aserbin): try to use member_type instead of role for metacache.
bool is_leader = r.role() == consensus::RaftPeerPB::LEADER;
@@ -1647,7 +1647,8 @@ Status KuduScanner::GetCurrentServer(KuduTabletServer** server) {
}
unique_ptr<KuduTabletServer> client_server(new KuduTabletServer);
client_server->data_ = new KuduTabletServer::Data(rts->permanent_uuid(),
- host_ports[0]);
+ host_ports[0],
+ rts->location());
*server = client_server.release();
return Status::OK();
}
@@ -1821,6 +1822,10 @@ uint16_t KuduTabletServer::port() const {
return data_->hp_.port();
}
+const string& KuduTabletServer::location() const {
+ return data_->location_;
+}
+
////////////////////////////////////////////////////////////
// KuduPartitionerBuilder
////////////////////////////////////////////////////////////
http://git-wip-us.apache.org/repos/asf/kudu/blob/eb6f4e8a/src/kudu/client/client.h
----------------------------------------------------------------------
diff --git a/src/kudu/client/client.h b/src/kudu/client/client.h
index d759a26..56c3f50 100644
--- a/src/kudu/client/client.h
+++ b/src/kudu/client/client.h
@@ -649,6 +649,15 @@ class KUDU_EXPORT KuduTabletServer {
/// is listening on.
uint16_t port() const;
+ /// @cond PRIVATE_API
+ ///
+ /// Private API.
+ ///
+ /// @return The location of the tablet server.
+ /// An empty string will be returned if the location is not assigned.
+ const std::string& location() const KUDU_NO_EXPORT;
+ /// @endcond
+
private:
class KUDU_NO_EXPORT Data;
http://git-wip-us.apache.org/repos/asf/kudu/blob/eb6f4e8a/src/kudu/client/meta_cache.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/meta_cache.cc b/src/kudu/client/meta_cache.cc
index b2f8b3a..636a802 100644
--- a/src/kudu/client/meta_cache.cc
+++ b/src/kudu/client/meta_cache.cc
@@ -87,7 +87,8 @@ namespace client {
namespace internal {
RemoteTabletServer::RemoteTabletServer(const master::TSInfoPB& pb)
- : uuid_(pb.permanent_uuid()) {
+ : uuid_(pb.permanent_uuid()),
+ location_(pb.location()) {
Update(pb);
}
@@ -161,6 +162,10 @@ const string& RemoteTabletServer::permanent_uuid() const {
return uuid_;
}
+const string& RemoteTabletServer::location() const {
+ return location_;
+}
+
shared_ptr<TabletServerServiceProxy> RemoteTabletServer::proxy() const {
std::lock_guard<simple_spinlock> l(lock_);
CHECK(proxy_);
http://git-wip-us.apache.org/repos/asf/kudu/blob/eb6f4e8a/src/kudu/client/meta_cache.h
----------------------------------------------------------------------
diff --git a/src/kudu/client/meta_cache.h b/src/kudu/client/meta_cache.h
index 5e9dd6d..a23165d 100644
--- a/src/kudu/client/meta_cache.h
+++ b/src/kudu/client/meta_cache.h
@@ -106,6 +106,8 @@ class RemoteTabletServer {
// Returns the remote server's uuid.
const std::string& permanent_uuid() const;
+ const std::string& location() const;
+
private:
// Internal callback for DNS resolution.
void DnsResolutionFinished(const HostPort& hp,
@@ -116,6 +118,8 @@ class RemoteTabletServer {
mutable simple_spinlock lock_;
const std::string uuid_;
+ // If not assigned, location_ will be an empty string.
+ const std::string location_;
std::vector<HostPort> rpc_hostports_;
std::shared_ptr<tserver::TabletServerServiceProxy> proxy_;
http://git-wip-us.apache.org/repos/asf/kudu/blob/eb6f4e8a/src/kudu/client/scan_token-internal.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/scan_token-internal.cc b/src/kudu/client/scan_token-internal.cc
index 2ce965f..2bfc445 100644
--- a/src/kudu/client/scan_token-internal.cc
+++ b/src/kudu/client/scan_token-internal.cc
@@ -331,7 +331,8 @@ Status KuduScanTokenBuilder::Data::Build(vector<KuduScanToken*>* tokens) {
}
unique_ptr<KuduTabletServer> client_ts(new KuduTabletServer);
client_ts->data_ = new KuduTabletServer::Data(r.ts->permanent_uuid(),
- host_ports[0]);
+ host_ports[0],
+ r.ts->location());
bool is_leader = r.role == consensus::RaftPeerPB::LEADER;
bool is_voter = is_leader || r.role == consensus::RaftPeerPB::FOLLOWER;
unique_ptr<KuduReplica> client_replica(new KuduReplica);
http://git-wip-us.apache.org/repos/asf/kudu/blob/eb6f4e8a/src/kudu/client/tablet_server-internal.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/tablet_server-internal.cc b/src/kudu/client/tablet_server-internal.cc
index bd3b30b..ec52c02 100644
--- a/src/kudu/client/tablet_server-internal.cc
+++ b/src/kudu/client/tablet_server-internal.cc
@@ -27,8 +27,9 @@ using std::string;
namespace kudu {
namespace client {
-KuduTabletServer::Data::Data(string uuid, HostPort hp)
+KuduTabletServer::Data::Data(string uuid, HostPort hp, string location)
: uuid_(std::move(uuid)),
+ location_(std::move(location)),
hp_(std::move(hp)) {
}
http://git-wip-us.apache.org/repos/asf/kudu/blob/eb6f4e8a/src/kudu/client/tablet_server-internal.h
----------------------------------------------------------------------
diff --git a/src/kudu/client/tablet_server-internal.h b/src/kudu/client/tablet_server-internal.h
index d0ad3ba..7435e71 100644
--- a/src/kudu/client/tablet_server-internal.h
+++ b/src/kudu/client/tablet_server-internal.h
@@ -28,10 +28,12 @@ namespace client {
class KuduTabletServer::Data {
public:
- Data(std::string uuid, HostPort hp);
+ Data(std::string uuid, HostPort hp, std::string location);
~Data();
const std::string uuid_;
+ // If not assigned, location_ will be an empty string.
+ const std::string location_;
const HostPort hp_;
private: