From fdaa891332b163d4a3de1310c55116040fe1333f Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Tue, 21 Sep 2021 13:44:58 +0300 Subject: [PATCH] storage_service, sstables_loader: use effective_replication_map to get_natural_endpoints Signed-off-by: Benny Halevy --- service/storage_service.cc | 14 ++++---------- sstables_loader.cc | 4 ++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/service/storage_service.cc b/service/storage_service.cc index e12dd789d4..f50da7cd19 100644 --- a/service/storage_service.cc +++ b/service/storage_service.cc @@ -2728,20 +2728,14 @@ std::unordered_multimap storage_service::get_cha std::unordered_map current_replica_endpoints; // Find (for each range) all nodes that store replicas for these ranges as well - auto tmptr = get_token_metadata_ptr(); for (auto& r : ranges) { auto& ks = _db.local().find_keyspace(keyspace_name); auto end_token = r.end() ? r.end()->value() : dht::maximum_token(); - auto eps = ks.get_replication_strategy().calculate_natural_endpoints(end_token, *tmptr).get0(); + auto eps = ks.get_effective_replication_map()->get_natural_endpoints(end_token); current_replica_endpoints.emplace(r, std::move(eps)); } - auto temp = tmptr->clone_after_all_left().get0(); - - // release the token_metadata_ptr - // as it's not needed from this point on - // after we got clone_after_all_left() - tmptr = nullptr; + auto temp = get_token_metadata_ptr()->clone_after_all_left().get0(); // endpoint might or might not be 'leaving'. If it was not leaving (that is, removenode // command was used), it is still present in temp and must be removed. @@ -3191,7 +3185,7 @@ storage_service::construct_range_to_endpoint_map( const dht::token_range_vector& ranges) const { std::unordered_map res; for (auto r : ranges) { - res[r] = _db.local().find_keyspace(keyspace).get_replication_strategy().get_natural_endpoints( + res[r] = _db.local().find_keyspace(keyspace).get_effective_replication_map()->get_natural_endpoints( r.end() ? r.end()->value() : dht::maximum_token()); } return res; @@ -3476,7 +3470,7 @@ storage_service::get_natural_endpoints(const sstring& keyspace, inet_address_vector_replica_set storage_service::get_natural_endpoints(const sstring& keyspace, const token& pos) const { - return _db.local().find_keyspace(keyspace).get_replication_strategy().get_natural_endpoints(pos); + return _db.local().find_keyspace(keyspace).get_effective_replication_map()->get_natural_endpoints(pos); } future<> endpoint_lifecycle_notifier::notify_down(gms::inet_address endpoint) { diff --git a/sstables_loader.cc b/sstables_loader.cc index 7558153509..ad515d0d66 100644 --- a/sstables_loader.cc +++ b/sstables_loader.cc @@ -130,7 +130,7 @@ future<> sstables_loader::load_and_stream(sstring ks_name, sstring cf_name, auto s = table.schema(); const auto cf_id = s->id(); const auto reason = streaming::stream_reason::repair; - auto& rs = _db.local().find_keyspace(ks_name).get_replication_strategy(); + auto erm = _db.local().find_keyspace(ks_name).get_effective_replication_map(); size_t nr_sst_total = sstables.size(); size_t nr_sst_current = 0; @@ -173,7 +173,7 @@ future<> sstables_loader::load_and_stream(sstring ks_name, sstring cf_name, auto& start = mf->as_partition_start(); const auto& current_dk = start.key(); - current_targets = rs.get_natural_endpoints(current_dk.token()); + current_targets = erm->get_natural_endpoints(current_dk.token()); if (primary_replica_only && current_targets.size() > 1) { current_targets.resize(1); }