diff --git a/locator/token_metadata.cc b/locator/token_metadata.cc index 293f3822a0..3107d3a26e 100644 --- a/locator/token_metadata.cc +++ b/locator/token_metadata.cc @@ -502,6 +502,14 @@ void topology::add_endpoint(const inet_address& ep) _current_locations[ep] = {dc, rack}; } +void topology::update_endpoint(inet_address ep) { + if (!_current_locations.count(ep) || !locator::i_endpoint_snitch::snitch_instance().local_is_initialized()) { + return; + } + + add_endpoint(ep); +} + void topology::remove_endpoint(inet_address ep) { auto cur_dc_rack = _current_locations.find(ep); diff --git a/locator/token_metadata.hh b/locator/token_metadata.hh index f794ba4239..6bcc8f1c8c 100644 --- a/locator/token_metadata.hh +++ b/locator/token_metadata.hh @@ -82,6 +82,12 @@ public: */ void remove_endpoint(inet_address ep); + /** + * Re-reads the DC/rack info for the given endpoint + * @param ep endpoint in question + */ + void update_endpoint(inet_address ep); + std::unordered_map>& get_datacenter_endpoints() { @@ -239,6 +245,10 @@ public: return _bootstrap_tokens; } + void update_topology(inet_address ep) { + _topology.update_endpoint(ep); + } + tokens_iterator tokens_end() const { return tokens_iterator(sorted_tokens().end(), sorted_tokens().size()); }