diff --git a/locator/abstract_replication_strategy.cc b/locator/abstract_replication_strategy.cc index 64f2e45db8..3dfb28b25b 100644 --- a/locator/abstract_replication_strategy.cc +++ b/locator/abstract_replication_strategy.cc @@ -73,4 +73,22 @@ abstract_replication_strategy::get_cached_endpoints() { return _cached_endpoints; } +std::vector> +abstract_replication_strategy::get_ranges(inet_address ep) { + std::vector> ret; + auto prev_tok = _token_metadata.sorted_tokens().back(); + for (auto tok : _token_metadata.sorted_tokens()) { + for (inet_address a : calculate_natural_endpoints(tok)) { + if (a == ep) { + ret.emplace_back( + range::bound(prev_tok, false), + range::bound(tok, true)); + break; + } + } + prev_tok = tok; + } + return ret; +} + } // namespace locator diff --git a/locator/abstract_replication_strategy.hh b/locator/abstract_replication_strategy.hh index d72c34e45a..1c599972ba 100644 --- a/locator/abstract_replication_strategy.hh +++ b/locator/abstract_replication_strategy.hh @@ -77,6 +77,11 @@ public: virtual size_t get_replication_factor() const = 0; uint64_t get_cache_hits_count() const { return _cache_hits_count; } replication_strategy_type get_type() const { return _my_type; } + + // get_ranges() returns the list of ranges held by the given endpoint. + // It the analogue of Origin's getAddressRanges().get(endpoint). + // This function is not efficient, and not meant for the fast path. + std::vector> get_ranges(inet_address ep); }; }