@@ -123,9 +123,6 @@ void Host::set(const Row* row, bool use_tokens) {
123
123
if (dse_server_version_ < VersionNumber (6 , 7 , 0 )) {
124
124
server_version_ = VersionNumber (3 , 11 , 0 );
125
125
}
126
- } else {
127
- LOG_WARN (" Invalid DSE version string \" %s\" on host %s" , dse_version_str.c_str (),
128
- address ().to_string ().c_str ());
129
126
}
130
127
}
131
128
@@ -153,37 +150,51 @@ void Host::set(const Row* row, bool use_tokens) {
153
150
" If this is incorrect you should configure a specific interface for rpc_address on "
154
151
" the server." ,
155
152
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
+ }
156
165
}
157
166
} else {
158
167
LOG_WARN (" No rpc_address for host %s in system.local or system.peers." ,
159
168
address_string_.c_str ());
160
169
}
161
170
}
162
171
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
+
163
182
ExternalHostListener::ExternalHostListener (const CassHostListenerCallback callback, void * data)
164
183
: callback_(callback)
165
184
, data_(data) {}
166
185
167
186
void 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_);
171
188
}
172
189
173
190
void 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_);
177
192
}
178
193
179
194
void 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_);
183
196
}
184
197
185
198
void 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_);
189
200
}
0 commit comments