@@ -140,9 +140,6 @@ void Host::set(const Row* row, bool use_tokens) {
140140 if (dse_server_version_ < VersionNumber (6 , 7 , 0 )) {
141141 server_version_ = VersionNumber (3 , 11 , 0 );
142142 }
143- } else {
144- LOG_WARN (" Invalid DSE version string \" %s\" on host %s" , dse_version_str.c_str (),
145- address ().to_string ().c_str ());
146143 }
147144 }
148145
@@ -170,6 +167,18 @@ void Host::set(const Row* row, bool use_tokens) {
170167 " If this is incorrect you should configure a specific interface for rpc_address on "
171168 " the server." ,
172169 address_string_.c_str ());
170+ v = row->get_by_name (" listen_address" ); // Available in system.local
171+ if (v && !v->is_null ()) {
172+ v->decoder ().as_inet (v->size (), address_.port (), &rpc_address_);
173+ } else {
174+ v = row->get_by_name (" peer" ); // Available in system.peers
175+ if (v && !v->is_null ()) {
176+ v->decoder ().as_inet (v->size (), address_.port (), &rpc_address_);
177+ }
178+ }
179+ if (!rpc_address_.is_valid ()) {
180+ LOG_WARN (" Unable to set rpc_address from either listen_address or peer" );
181+ }
173182 }
174183 } else {
175184 LOG_WARN (" No rpc_address for host %s in system.local or system.peers." ,
@@ -213,30 +222,32 @@ void Host::close_unpooled_connections(uv_loop_t *loop) {
213222 }
214223}
215224
225+ static CassInet to_inet (const Host::Ptr& host) {
226+ CassInet address;
227+ if (host->address ().is_resolved ()) {
228+ address.address_length = host->address ().to_inet (address.address );
229+ } else {
230+ address.address_length = host->rpc_address ().to_inet (&address.address );
231+ }
232+ return address;
233+ }
234+
216235ExternalHostListener::ExternalHostListener (const CassHostListenerCallback callback, void * data)
217236 : callback_(callback)
218237 , data_(data) {}
219238
220239void ExternalHostListener::on_host_up (const Host::Ptr& host) {
221- CassInet address;
222- address.address_length = host->address ().to_inet (address.address );
223- callback_ (CASS_HOST_LISTENER_EVENT_UP, address, data_);
240+ callback_ (CASS_HOST_LISTENER_EVENT_UP, to_inet (host), data_);
224241}
225242
226243void ExternalHostListener::on_host_down (const Host::Ptr& host) {
227- CassInet address;
228- address.address_length = host->address ().to_inet (address.address );
229- callback_ (CASS_HOST_LISTENER_EVENT_DOWN, address, data_);
244+ callback_ (CASS_HOST_LISTENER_EVENT_DOWN, to_inet (host), data_);
230245}
231246
232247void ExternalHostListener::on_host_added (const Host::Ptr& host) {
233- CassInet address;
234- address.address_length = host->address ().to_inet (address.address );
235- callback_ (CASS_HOST_LISTENER_EVENT_ADD, address, data_);
248+ callback_ (CASS_HOST_LISTENER_EVENT_ADD, to_inet (host), data_);
236249}
237250
238251void ExternalHostListener::on_host_removed (const Host::Ptr& host) {
239- CassInet address;
240- address.address_length = host->address ().to_inet (address.address );
241- callback_ (CASS_HOST_LISTENER_EVENT_REMOVE, address, data_);
252+ callback_ (CASS_HOST_LISTENER_EVENT_REMOVE, to_inet (host), data_);
242253}
0 commit comments