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 <bhalevy@scylladb.com>
This commit is contained in:
Benny Halevy
2021-09-26 16:29:28 +03:00
parent 4d2561ff75
commit 91f2fd5f2c
9 changed files with 10 additions and 10 deletions

View File

@@ -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;

View File

@@ -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<std::set<sstring>> recognized_options() const = 0;
virtual std::optional<std::set<sstring>> 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

View File

@@ -50,7 +50,7 @@ public:
virtual void validate_options() const override { /* noop */ }
std::optional<std::set<sstring>> recognized_options() const override {
std::optional<std::set<sstring>> recognized_options(const topology&) const override {
// We explicitely allow all options
return std::nullopt;
}

View File

@@ -37,7 +37,7 @@ future<inet_address_vector_replica_set> local_strategy::calculate_natural_endpoi
void local_strategy::validate_options() const {
}
std::optional<std::set<sstring>> local_strategy::recognized_options() const {
std::optional<std::set<sstring>> local_strategy::recognized_options(const topology&) const {
// LocalStrategy doesn't expect any options.
return {};
}

View File

@@ -44,7 +44,7 @@ public:
virtual void validate_options() const override;
virtual std::optional<std::set<sstring>> recognized_options() const override;
virtual std::optional<std::set<sstring>> recognized_options(const topology&) const override;
virtual bool allow_remove_node_being_replaced_from_natural_endpoints() const override {
return false;

View File

@@ -300,9 +300,9 @@ void network_topology_strategy::validate_options() const {
}
}
std::optional<std::set<sstring>> network_topology_strategy::recognized_options() const {
std::optional<std::set<sstring>> network_topology_strategy::recognized_options(const topology& topology) const {
std::set<sstring> 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

View File

@@ -79,7 +79,7 @@ protected:
virtual void validate_options() const override;
virtual std::optional<std::set<sstring>> recognized_options() const override;
virtual std::optional<std::set<sstring>> recognized_options(const topology&) const override;
private:
// map: data centers -> replication factor

View File

@@ -84,7 +84,7 @@ void simple_strategy::validate_options() const {
validate_replication_factor(it->second);
}
std::optional<std::set<sstring>>simple_strategy::recognized_options() const {
std::optional<std::set<sstring>>simple_strategy::recognized_options(const topology&) const {
return {{ "replication_factor" }};
}

View File

@@ -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<std::set<sstring>> recognized_options() const override;
virtual std::optional<std::set<sstring>> recognized_options(const topology&) const override;
virtual bool allow_remove_node_being_replaced_from_natural_endpoints() const override {
return true;
}