From 91f2fd5f2cdaad103fbbdfee9140dc407670e097 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Sun, 26 Sep 2021 16:29:28 +0300 Subject: [PATCH] abstract_replication_strategy: recognized_options: pass const topology& Prepare for deleting the _shared_token_metadata member. All we need for recognized_options is the topology (for network_topology_strategy). Signed-off-by: Benny Halevy --- locator/abstract_replication_strategy.cc | 2 +- locator/abstract_replication_strategy.hh | 2 +- locator/everywhere_replication_strategy.hh | 2 +- locator/local_strategy.cc | 2 +- locator/local_strategy.hh | 2 +- locator/network_topology_strategy.cc | 4 ++-- locator/network_topology_strategy.hh | 2 +- locator/simple_strategy.cc | 2 +- locator/simple_strategy.hh | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/locator/abstract_replication_strategy.cc b/locator/abstract_replication_strategy.cc index 90996f00b7..26ab29a044 100644 --- a/locator/abstract_replication_strategy.cc +++ b/locator/abstract_replication_strategy.cc @@ -62,7 +62,7 @@ void abstract_replication_strategy::validate_replication_strategy(const sstring& { auto strategy = create_replication_strategy(strategy_name, stm, config_options); strategy->validate_options(); - auto expected = strategy->recognized_options(); + auto expected = strategy->recognized_options(stm.get()->get_topology()); if (expected) { for (auto&& item : config_options) { sstring key = item.first; diff --git a/locator/abstract_replication_strategy.hh b/locator/abstract_replication_strategy.hh index d74b06b520..63a46c5d7a 100644 --- a/locator/abstract_replication_strategy.hh +++ b/locator/abstract_replication_strategy.hh @@ -105,7 +105,7 @@ public: static void validate_replication_factor(sstring rf); virtual inet_address_vector_replica_set get_natural_endpoints(const token& search_token, const effective_replication_map& erm) const; virtual void validate_options() const = 0; - virtual std::optional> recognized_options() const = 0; + virtual std::optional> recognized_options(const topology&) const = 0; virtual size_t get_replication_factor(const token_metadata& tm) const = 0; // Decide if the replication strategy allow removing the node being // replaced from the natural endpoints when a node is being replaced in the diff --git a/locator/everywhere_replication_strategy.hh b/locator/everywhere_replication_strategy.hh index b8f5669c8e..b39f9abcb9 100644 --- a/locator/everywhere_replication_strategy.hh +++ b/locator/everywhere_replication_strategy.hh @@ -50,7 +50,7 @@ public: virtual void validate_options() const override { /* noop */ } - std::optional> recognized_options() const override { + std::optional> recognized_options(const topology&) const override { // We explicitely allow all options return std::nullopt; } diff --git a/locator/local_strategy.cc b/locator/local_strategy.cc index c217648072..7c0d92f956 100644 --- a/locator/local_strategy.cc +++ b/locator/local_strategy.cc @@ -37,7 +37,7 @@ future local_strategy::calculate_natural_endpoi void local_strategy::validate_options() const { } -std::optional> local_strategy::recognized_options() const { +std::optional> local_strategy::recognized_options(const topology&) const { // LocalStrategy doesn't expect any options. return {}; } diff --git a/locator/local_strategy.hh b/locator/local_strategy.hh index 06700b4af1..e96bcac03f 100644 --- a/locator/local_strategy.hh +++ b/locator/local_strategy.hh @@ -44,7 +44,7 @@ public: virtual void validate_options() const override; - virtual std::optional> recognized_options() const override; + virtual std::optional> recognized_options(const topology&) const override; virtual bool allow_remove_node_being_replaced_from_natural_endpoints() const override { return false; diff --git a/locator/network_topology_strategy.cc b/locator/network_topology_strategy.cc index 7bc14b5fe1..7381c8508b 100644 --- a/locator/network_topology_strategy.cc +++ b/locator/network_topology_strategy.cc @@ -300,9 +300,9 @@ void network_topology_strategy::validate_options() const { } } -std::optional> network_topology_strategy::recognized_options() const { +std::optional> network_topology_strategy::recognized_options(const topology& topology) const { std::set datacenters; - for (const auto& [dc_name, endpoints] : _shared_token_metadata.get()->get_topology().get_datacenter_endpoints()) { + for (const auto& [dc_name, endpoints] : topology.get_datacenter_endpoints()) { datacenters.insert(dc_name); } // We only allow datacenter names as options diff --git a/locator/network_topology_strategy.hh b/locator/network_topology_strategy.hh index 15f028c026..d569849f2b 100644 --- a/locator/network_topology_strategy.hh +++ b/locator/network_topology_strategy.hh @@ -79,7 +79,7 @@ protected: virtual void validate_options() const override; - virtual std::optional> recognized_options() const override; + virtual std::optional> recognized_options(const topology&) const override; private: // map: data centers -> replication factor diff --git a/locator/simple_strategy.cc b/locator/simple_strategy.cc index d499167e62..59172cdc04 100644 --- a/locator/simple_strategy.cc +++ b/locator/simple_strategy.cc @@ -84,7 +84,7 @@ void simple_strategy::validate_options() const { validate_replication_factor(it->second); } -std::optional>simple_strategy::recognized_options() const { +std::optional>simple_strategy::recognized_options(const topology&) const { return {{ "replication_factor" }}; } diff --git a/locator/simple_strategy.hh b/locator/simple_strategy.hh index 6658f5e6bd..930433b4bb 100644 --- a/locator/simple_strategy.hh +++ b/locator/simple_strategy.hh @@ -34,7 +34,7 @@ public: virtual ~simple_strategy() {}; virtual size_t get_replication_factor(const token_metadata& tm) const override; virtual void validate_options() const override; - virtual std::optional> recognized_options() const override; + virtual std::optional> recognized_options(const topology&) const override; virtual bool allow_remove_node_being_replaced_from_natural_endpoints() const override { return true; }