diff --git a/locator/abstract_replication_strategy.cc b/locator/abstract_replication_strategy.cc index 5c72befb7a..d96ef93f73 100644 --- a/locator/abstract_replication_strategy.cc +++ b/locator/abstract_replication_strategy.cc @@ -210,22 +210,6 @@ effective_replication_map::get_primary_ranges_within_dc(inet_address ep) const { }); } -future> -abstract_replication_strategy::get_address_ranges(const token_metadata& tm) const { - std::unordered_multimap ret; - for (auto& t : tm.sorted_tokens()) { - dht::token_range_vector r = tm.get_primary_ranges_for(t); - auto eps = co_await calculate_natural_endpoints(t, tm); - rslogger.debug("token={}, primary_range={}, address={}", t, r, eps); - for (auto ep : eps) { - for (auto&& rng : r) { - ret.emplace(ep, rng); - } - } - } - co_return ret; -} - future> abstract_replication_strategy::get_address_ranges(const token_metadata& tm, inet_address endpoint) const { std::unordered_multimap ret; diff --git a/locator/abstract_replication_strategy.hh b/locator/abstract_replication_strategy.hh index 5a7e7bce3f..6cf1c73f10 100644 --- a/locator/abstract_replication_strategy.hh +++ b/locator/abstract_replication_strategy.hh @@ -118,7 +118,6 @@ public: future get_ranges(inet_address ep, token_metadata_ptr tmptr) const; public: - future> get_address_ranges(const token_metadata& tm) const; future> get_address_ranges(const token_metadata& tm, inet_address endpoint) const; // Caller must ensure that token_metadata will not change throughout the call. diff --git a/locator/token_metadata.cc b/locator/token_metadata.cc index 7f24815c93..661002a631 100644 --- a/locator/token_metadata.cc +++ b/locator/token_metadata.cc @@ -779,13 +779,12 @@ void token_metadata_impl::calculate_pending_ranges_for_leaving( if (_leaving_endpoints.empty()) { return; } - std::unordered_multimap address_ranges = strategy.get_address_ranges(unpimplified_this).get0(); // get all ranges that will be affected by leaving nodes std::unordered_set> affected_ranges; for (auto endpoint : _leaving_endpoints) { - auto r = address_ranges.equal_range(endpoint); - for (auto x = r.first; x != r.second; x++) { - affected_ranges.emplace(x->second); + auto r = strategy.get_address_ranges(unpimplified_this, endpoint).get0(); + for (const auto& x : r) { + affected_ranges.emplace(x.second); } } // for each of those ranges, find what new nodes will be responsible for the range when @@ -816,16 +815,14 @@ void token_metadata_impl::calculate_pending_ranges_for_replacing( if (_replacing_endpoints.empty()) { return; } - auto address_ranges = strategy.get_address_ranges(unpimplified_this).get0(); for (const auto& node : _replacing_endpoints) { auto existing_node = node.first; auto replacing_node = node.second; + auto address_ranges = strategy.get_address_ranges(unpimplified_this, existing_node).get0(); for (const auto& x : address_ranges) { seastar::thread::maybe_yield(); - if (x.first == existing_node) { - tlogger.debug("Node {} replaces {} for range {}", replacing_node, existing_node, x.second); - new_pending_ranges.emplace(x.second, replacing_node); - } + tlogger.debug("Node {} replaces {} for range {}", replacing_node, existing_node, x.second); + new_pending_ranges.emplace(x.second, replacing_node); } } }