calculate_natural_endpoints: fix formatting

This commit is contained in:
Petr Gusev
2023-10-24 12:16:54 +04:00
parent d5b4b02b28
commit fe3c543c4e
3 changed files with 35 additions and 35 deletions

View File

@@ -22,12 +22,12 @@ everywhere_replication_strategy::everywhere_replication_strategy(const replicati
future<natural_ep_type> everywhere_replication_strategy::calculate_natural_endpoints(const token& search_token, const token_metadata& tm, bool use_host_id) const {
return select_tm([this]<typename NodeId>(const generic_token_metadata<NodeId>& tm) -> future<natural_ep_type> {
if (tm.sorted_tokens().empty()) {
if (tm.sorted_tokens().empty()) {
set_type<NodeId> result{vector_type<NodeId>({this->get_self_id<NodeId>(tm)})};
return make_ready_future<natural_ep_type>(std::move(result));
}
const auto& all_endpoints = tm.get_all_endpoints();
return make_ready_future<natural_ep_type>(set_type<NodeId>(all_endpoints.begin(), all_endpoints.end()));
return make_ready_future<natural_ep_type>(std::move(result));
}
const auto& all_endpoints = tm.get_all_endpoints();
return make_ready_future<natural_ep_type>(set_type<NodeId>(all_endpoints.begin(), all_endpoints.end()));
}, tm, use_host_id);
}

View File

@@ -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([&]<typename NodeId>(const generic_token_metadata<NodeId>& tm) -> future<natural_ep_type> {
natural_endpoints_tracker<NodeId> tracker(tm, _dc_rep_factor);
natural_endpoints_tracker<NodeId> 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);
}

View File

@@ -35,33 +35,33 @@ simple_strategy::simple_strategy(const replication_strategy_config_options& conf
future<natural_ep_type> simple_strategy::calculate_natural_endpoints(const token& t, const token_metadata& tm, bool use_host_id) const {
return select_tm([&]<typename NodeId>(const generic_token_metadata<NodeId>& tm) -> future<natural_ep_type> {
const std::vector<token>& tokens = tm.sorted_tokens();
const std::vector<token>& tokens = tm.sorted_tokens();
if (tokens.empty()) {
co_return set_type<NodeId>{};
}
size_t replicas = _replication_factor;
set_type<NodeId> 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<NodeId>{};
}
auto ep = tm.get_endpoint(token);
assert(ep);
size_t replicas = _replication_factor;
set_type<NodeId> 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);
}