diff --git a/locator/everywhere_replication_strategy.cc b/locator/everywhere_replication_strategy.cc index 1b88258d41..1105ff3b2c 100644 --- a/locator/everywhere_replication_strategy.cc +++ b/locator/everywhere_replication_strategy.cc @@ -22,12 +22,12 @@ everywhere_replication_strategy::everywhere_replication_strategy(const replicati future everywhere_replication_strategy::calculate_natural_endpoints(const token& search_token, const token_metadata& tm, bool use_host_id) const { return select_tm([this](const generic_token_metadata& tm) -> future { - if (tm.sorted_tokens().empty()) { + if (tm.sorted_tokens().empty()) { set_type result{vector_type({this->get_self_id(tm)})}; - return make_ready_future(std::move(result)); - } - const auto& all_endpoints = tm.get_all_endpoints(); - return make_ready_future(set_type(all_endpoints.begin(), all_endpoints.end())); + return make_ready_future(std::move(result)); + } + const auto& all_endpoints = tm.get_all_endpoints(); + return make_ready_future(set_type(all_endpoints.begin(), all_endpoints.end())); }, tm, use_host_id); } diff --git a/locator/network_topology_strategy.cc b/locator/network_topology_strategy.cc index 7dbf89e866..b2f7cc31ac 100644 --- a/locator/network_topology_strategy.cc +++ b/locator/network_topology_strategy.cc @@ -243,18 +243,18 @@ network_topology_strategy::calculate_natural_endpoints( const token& search_token, const token_metadata& tm, bool use_host_id) const { return select_tm([&](const generic_token_metadata& tm) -> future { - natural_endpoints_tracker tracker(tm, _dc_rep_factor); + natural_endpoints_tracker tracker(tm, _dc_rep_factor); - for (auto& next : tm.ring_range(search_token)) { - co_await coroutine::maybe_yield(); + for (auto& next : tm.ring_range(search_token)) { + co_await coroutine::maybe_yield(); - NodeId ep = *tm.get_endpoint(next); - if (tracker.add_endpoint_and_check_if_done(ep)) { - break; + NodeId ep = *tm.get_endpoint(next); + if (tracker.add_endpoint_and_check_if_done(ep)) { + break; + } } - } - co_return std::move(tracker.replicas()); + co_return std::move(tracker.replicas()); }, tm, use_host_id); } diff --git a/locator/simple_strategy.cc b/locator/simple_strategy.cc index af40382c28..dfbc0d7dad 100644 --- a/locator/simple_strategy.cc +++ b/locator/simple_strategy.cc @@ -35,33 +35,33 @@ simple_strategy::simple_strategy(const replication_strategy_config_options& conf future simple_strategy::calculate_natural_endpoints(const token& t, const token_metadata& tm, bool use_host_id) const { return select_tm([&](const generic_token_metadata& tm) -> future { - const std::vector& tokens = tm.sorted_tokens(); + const std::vector& tokens = tm.sorted_tokens(); - if (tokens.empty()) { - co_return set_type{}; - } - - size_t replicas = _replication_factor; - set_type endpoints; - endpoints.reserve(replicas); - - for (auto& token : tm.ring_range(t)) { - // If the number of nodes in the cluster is smaller than the desired - // replication factor we should return the loop when endpoints already - // contains all the nodes in the cluster because no more nodes could be - // added to endpoints lists. - if (endpoints.size() == replicas || endpoints.size() == tm.count_normal_token_owners()) { - break; + if (tokens.empty()) { + co_return set_type{}; } - auto ep = tm.get_endpoint(token); - assert(ep); + size_t replicas = _replication_factor; + set_type endpoints; + endpoints.reserve(replicas); - endpoints.push_back(*ep); - co_await coroutine::maybe_yield(); - } + for (auto& token : tm.ring_range(t)) { + // If the number of nodes in the cluster is smaller than the desired + // replication factor we should return the loop when endpoints already + // contains all the nodes in the cluster because no more nodes could be + // added to endpoints lists. + if (endpoints.size() == replicas || endpoints.size() == tm.count_normal_token_owners()) { + break; + } - co_return endpoints; + auto ep = tm.get_endpoint(token); + assert(ep); + + endpoints.push_back(*ep); + co_await coroutine::maybe_yield(); + } + + co_return endpoints; }, tm, use_host_id); }