abstract_replication_strategy: add has_uniform_natural_endpoints

So that using calaculate_natural_endpoints can be optimized
for strategies that return the same endpoints for all tokens,
namely everywhere_replication_strategy and local_strategy.

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
This commit is contained in:
Benny Halevy
2022-08-10 23:09:49 +03:00
parent e9cbc9ee85
commit eb678e723b
3 changed files with 8 additions and 0 deletions

View File

@@ -78,6 +78,10 @@ public:
const replication_strategy_config_options& config_options,
replication_strategy_type my_type);
// Evaluates to true iff calculate_natural_endpoints
// returns different results for different tokens.
virtual bool natural_endpoints_depend_on_token() const noexcept { return true; }
// The returned vector has size O(number of normal token owners), which is O(number of nodes in the cluster).
// Note: it is not guaranteed that the function will actually yield. If the complexity of a particular implementation
// is small, that implementation may not yield since by itself it won't cause a reactor stall (assuming practical

View File

@@ -18,6 +18,8 @@ class everywhere_replication_strategy : public abstract_replication_strategy {
public:
everywhere_replication_strategy(const replication_strategy_config_options& config_options);
virtual bool natural_endpoints_depend_on_token() const noexcept override { return false; }
virtual future<endpoint_set> calculate_natural_endpoints(const token& search_token, const token_metadata& tm) const override;
virtual void validate_options() const override { /* noop */ }

View File

@@ -27,6 +27,8 @@ public:
virtual ~local_strategy() {};
virtual size_t get_replication_factor(const token_metadata&) const override;
virtual bool natural_endpoints_depend_on_token() const noexcept override { return false; }
virtual future<endpoint_set> calculate_natural_endpoints(const token& search_token, const token_metadata& tm) const override;
virtual void validate_options() const override;