diff --git a/src/yb/util/net/inetaddress.cc b/src/yb/util/net/inetaddress.cc index 4082476a8328..fb5740887927 100644 --- a/src/yb/util/net/inetaddress.cc +++ b/src/yb/util/net/inetaddress.cc @@ -25,7 +25,7 @@ namespace yb { InetAddress::InetAddress() { } -InetAddress::InetAddress(const address& address) +InetAddress::InetAddress(const boost::asio::ip::address& address) : boost_addr_(address) { } @@ -52,7 +52,7 @@ CHECKED_STATUS ResolveInternal(const std::string& host, CHECKED_STATUS InetAddress::Resolve(const std::string& host, std::vector* 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; diff --git a/src/yb/util/net/inetaddress.h b/src/yb/util/net/inetaddress.h index f11f53844184..691376d7b5f0 100644 --- a/src/yb/util/net/inetaddress.h +++ b/src/yb/util/net/inetaddress.h @@ -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(); diff --git a/src/yb/yql/cql/cqlserver/cql_server.cc b/src/yb/yql/cql/cqlserver/cql_server.cc index 9f4624cb65ce..04770d712256 100644 --- a/src/yb/yql/cql/cqlserver/cql_server.cc +++ b/src/yb/yql/cql/cqlserver/cql_server.cc @@ -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()))); } }