Skip to content

Commit

Permalink
ENG-2686: Handle host names in CQL node-list refresh.
Browse files Browse the repository at this point in the history
Summary: Handle host names in CQL node-list refresh in CQLServer::CQLNodeListRefresh().

Test Plan: Start a cluster with rpc bind addresses specified as host names. Connect to the cluster using cqlsh and verify no more warning is issued in the node-list refresh.

Reviewers: pritam.damania

Reviewed By: pritam.damania

Subscribers: yql

Differential Revision: https://phabricator.dev.yugabyte.com/D3852
  • Loading branch information
robertpang committed Jan 11, 2018
1 parent 22faad8 commit 9ad424d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/yb/util/net/inetaddress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace yb {
InetAddress::InetAddress() {
}

InetAddress::InetAddress(const address& address)
InetAddress::InetAddress(const boost::asio::ip::address& address)
: boost_addr_(address) {
}

Expand All @@ -52,7 +52,7 @@ CHECKED_STATUS ResolveInternal(const std::string& host,
CHECKED_STATUS InetAddress::Resolve(const std::string& host, std::vector<InetAddress>* addresses) {
// Try to see if we already have an IP address.
boost::system::error_code ec;
address addr = address::from_string(host, ec);
boost::asio::ip::address addr = address::from_string(host, ec);
if (ec.value()) {
// Resolve the host if we don't have a valid IP addr notation string.
tcp::resolver::iterator iter;
Expand Down
4 changes: 4 additions & 0 deletions src/yb/util/net/inetaddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ class InetAddress {
// object. If size_hint is specified, it indicates the number of bytes to decode from the slice.
CHECKED_STATUS FromSlice(const Slice& slice, size_t size_hint = 0);

const boost::asio::ip::address& address() const {
return boost_addr_;
}

bool isV4() const {
CHECK(!boost_addr_.is_unspecified());
return boost_addr_.is_v4();
Expand Down
11 changes: 5 additions & 6 deletions src/yb/yql/cql/cqlserver/cql_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,17 @@ void CQLServer::CQLNodeListRefresh(const boost::system::error_code &e) {
}

// Use only the first rpc address.
InetAddress addr;
const yb::HostPortPB& hostport_pb = ts_info.registration().common().rpc_addresses(0);
boost::system::error_code ec;
Endpoint addr(IpAddress::from_string(hostport_pb.host(), ec), hostport_pb.port());
if (ec) {
LOG(WARNING) << strings::Substitute("Couldn't parse host $0, error: $1",
hostport_pb.host(), ec.message());
if (PREDICT_FALSE(!addr.FromString(hostport_pb.host()).ok())) {
LOG(WARNING) << strings::Substitute("Couldn't parse host $0", hostport_pb.host());
continue;
}

// Queue event for all clients to add a node.
cqlserver_event_list->AddEvent(
BuildTopologyChangeEvent(TopologyChangeEventResponse::kNewNode, addr));
BuildTopologyChangeEvent(TopologyChangeEventResponse::kNewNode,
Endpoint(addr.address(), hostport_pb.port())));
}
}

Expand Down

0 comments on commit 9ad424d

Please sign in to comment.