@@ -123,9 +123,6 @@ void Host::set(const Row* row, bool use_tokens) {
123123 if (dse_server_version_ < VersionNumber (6 , 7 , 0 )) {
124124 server_version_ = VersionNumber (3 , 11 , 0 );
125125 }
126- } else {
127- LOG_WARN (" Invalid DSE version string \" %s\" on host %s" , dse_version_str.c_str (),
128- address ().to_string ().c_str ());
129126 }
130127 }
131128
@@ -153,37 +150,51 @@ void Host::set(const Row* row, bool use_tokens) {
153150 " If this is incorrect you should configure a specific interface for rpc_address on "
154151 " the server." ,
155152 address_string_.c_str ());
153+ v = row->get_by_name (" listen_address" ); // Available in system.local
154+ if (v && !v->is_null ()) {
155+ v->decoder ().as_inet (v->size (), address_.port (), &rpc_address_);
156+ } else {
157+ v = row->get_by_name (" peer" ); // Available in system.peers
158+ if (v && !v->is_null ()) {
159+ v->decoder ().as_inet (v->size (), address_.port (), &rpc_address_);
160+ }
161+ }
162+ if (!rpc_address_.is_valid ()) {
163+ LOG_WARN (" Unable to set rpc_address from either listen_address or peer" );
164+ }
156165 }
157166 } else {
158167 LOG_WARN (" No rpc_address for host %s in system.local or system.peers." ,
159168 address_string_.c_str ());
160169 }
161170}
162171
172+ static CassInet to_inet (const Host::Ptr& host) {
173+ CassInet address;
174+ if (host->address ().is_resolved ()) {
175+ address.address_length = host->address ().to_inet (address.address );
176+ } else {
177+ address.address_length = host->rpc_address ().to_inet (&address.address );
178+ }
179+ return address;
180+ }
181+
163182ExternalHostListener::ExternalHostListener (const CassHostListenerCallback callback, void * data)
164183 : callback_(callback)
165184 , data_(data) {}
166185
167186void ExternalHostListener::on_host_up (const Host::Ptr& host) {
168- CassInet address;
169- address.address_length = host->address ().to_inet (address.address );
170- callback_ (CASS_HOST_LISTENER_EVENT_UP, address, data_);
187+ callback_ (CASS_HOST_LISTENER_EVENT_UP, to_inet (host), data_);
171188}
172189
173190void ExternalHostListener::on_host_down (const Host::Ptr& host) {
174- CassInet address;
175- address.address_length = host->address ().to_inet (address.address );
176- callback_ (CASS_HOST_LISTENER_EVENT_DOWN, address, data_);
191+ callback_ (CASS_HOST_LISTENER_EVENT_DOWN, to_inet (host), data_);
177192}
178193
179194void ExternalHostListener::on_host_added (const Host::Ptr& host) {
180- CassInet address;
181- address.address_length = host->address ().to_inet (address.address );
182- callback_ (CASS_HOST_LISTENER_EVENT_ADD, address, data_);
195+ callback_ (CASS_HOST_LISTENER_EVENT_ADD, to_inet (host), data_);
183196}
184197
185198void ExternalHostListener::on_host_removed (const Host::Ptr& host) {
186- CassInet address;
187- address.address_length = host->address ().to_inet (address.address );
188- callback_ (CASS_HOST_LISTENER_EVENT_REMOVE, address, data_);
199+ callback_ (CASS_HOST_LISTENER_EVENT_REMOVE, to_inet (host), data_);
189200}
0 commit comments