token_metadata: add get_all_ips method

This is convenient for migrating code that uses
get_all_endpoints.
This commit is contained in:
Petr Gusev
2023-11-28 11:41:42 +04:00
parent 9edf0709e6
commit 39bbe5f457
2 changed files with 18 additions and 0 deletions

View File

@@ -1278,6 +1278,19 @@ generic_token_metadata<NodeId>::get_all_endpoints() const {
return _impl->get_all_endpoints();
}
template <typename NodeId>
template <typename T>
requires std::is_same_v<T, locator::host_id>
std::unordered_set<gms::inet_address> generic_token_metadata<NodeId>::get_all_ips() const {
const auto& host_ids = _impl->get_all_endpoints();
std::unordered_set<gms::inet_address> result;
result.reserve(host_ids.size());
for (const auto& id: host_ids) {
result.insert(_impl->get_endpoint_for_host_id(id));
}
return result;
}
template <typename NodeId>
size_t
generic_token_metadata<NodeId>::count_normal_token_owners() const {
@@ -1455,5 +1468,6 @@ template const token_metadata2* generic_token_metadata<gms::inet_address>::get_n
template lw_shared_ptr<const token_metadata2> generic_token_metadata<gms::inet_address>::get_new_strong<>() const;
template generic_token_metadata<gms::inet_address>::generic_token_metadata(std::unique_ptr<token_metadata_impl<gms::inet_address>>, token_metadata2);
template generic_token_metadata<gms::inet_address>::generic_token_metadata(token_metadata2_ptr);
template std::unordered_set<gms::inet_address> generic_token_metadata<locator::host_id>::get_all_ips<>() const;
} // namespace locator

View File

@@ -309,6 +309,10 @@ public:
const std::unordered_set<NodeId>& get_all_endpoints() const;
template <typename T = NodeId>
requires std::is_same_v<T, locator::host_id>
std::unordered_set<gms::inet_address> get_all_ips() const;
/* Returns the number of different endpoints that own tokens in the ring.
* Bootstrapping tokens are not taken into account. */
size_t count_normal_token_owners() const;