utils: sequenced_set: expose set and contains method
And use that in sights using the endpoint set returned by abstract_replication_strategy::calculate_natural_endpoints. Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
This commit is contained in:
@@ -174,11 +174,9 @@ abstract_replication_strategy::get_ranges(inet_address ep, token_metadata_ptr tm
|
||||
}
|
||||
auto prev_tok = sorted_tokens.back();
|
||||
for (auto tok : sorted_tokens) {
|
||||
for (inet_address a : co_await calculate_natural_endpoints(tok, tm)) {
|
||||
if (a == ep) {
|
||||
auto eps = co_await calculate_natural_endpoints(tok, tm);
|
||||
if (eps.contains(ep)) {
|
||||
insert_token_range_to_sorted_container_while_unwrapping(prev_tok, tok, ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
prev_tok = tok;
|
||||
}
|
||||
@@ -245,20 +243,13 @@ abstract_replication_strategy::get_address_ranges(const token_metadata& tm, inet
|
||||
continue;
|
||||
}
|
||||
auto eps = co_await calculate_natural_endpoints(t, tm);
|
||||
bool found = false;
|
||||
for (auto ep : eps) {
|
||||
if (ep != endpoint) {
|
||||
continue;
|
||||
}
|
||||
if (eps.contains(endpoint)) {
|
||||
dht::token_range_vector r = tm.get_primary_ranges_for(t);
|
||||
rslogger.debug("token={} primary_range={} endpoint={}", t, r, endpoint);
|
||||
for (auto&& rng : r) {
|
||||
ret.emplace(ep, rng);
|
||||
ret.emplace(endpoint, rng);
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
if (!found) {
|
||||
} else {
|
||||
rslogger.debug("token={} natural_endpoints={}: endpoint={} not found", t, eps, endpoint);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -816,13 +816,10 @@ void token_metadata_impl::calculate_pending_ranges_for_leaving(
|
||||
auto t = r.end() ? r.end()->value() : dht::maximum_token();
|
||||
auto current_endpoints = strategy.calculate_natural_endpoints(t, metadata).get0();
|
||||
auto new_endpoints = strategy.calculate_natural_endpoints(t, *all_left_metadata).get0();
|
||||
std::vector<inet_address> diff;
|
||||
std::sort(current_endpoints.begin(), current_endpoints.end());
|
||||
std::sort(new_endpoints.begin(), new_endpoints.end());
|
||||
std::set_difference(new_endpoints.begin(), new_endpoints.end(),
|
||||
current_endpoints.begin(), current_endpoints.end(), std::back_inserter(diff));
|
||||
for (auto& ep : diff) {
|
||||
for (auto ep : new_endpoints) {
|
||||
if (!current_endpoints.contains(ep)) {
|
||||
new_pending_ranges.emplace(r, ep);
|
||||
}
|
||||
}
|
||||
seastar::thread::maybe_yield();
|
||||
}
|
||||
|
||||
@@ -1585,7 +1585,7 @@ future<> repair_service::do_decommission_removenode_with_repair(locator::token_m
|
||||
auto end_token = r.end() ? r.end()->value() : dht::maximum_token();
|
||||
const auto new_eps = ks.get_replication_strategy().calculate_natural_endpoints(end_token, temp).get0();
|
||||
const auto& current_eps = current_replica_endpoints[r];
|
||||
std::unordered_set<inet_address> neighbors_set(new_eps.begin(), new_eps.end());
|
||||
std::unordered_set<inet_address> neighbors_set = new_eps.get_set();
|
||||
bool skip_this_range = false;
|
||||
auto new_owner = neighbors_set;
|
||||
for (const auto& node : current_eps) {
|
||||
|
||||
@@ -125,6 +125,14 @@ public:
|
||||
return _vec;
|
||||
}
|
||||
|
||||
const auto& get_set() const noexcept {
|
||||
return _set;
|
||||
}
|
||||
|
||||
bool contains(const T& t) const noexcept {
|
||||
return _set.contains(t);
|
||||
}
|
||||
|
||||
void reserve(size_type sz) {
|
||||
_set.reserve(sz);
|
||||
_vec.reserve(sz);
|
||||
|
||||
Reference in New Issue
Block a user