Skip to content

Commit

Permalink
abstract_replication_strategy: recognized_options: pass const topology&
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bhalevy committed Oct 13, 2021
1 parent 4d2561f commit 91f2fd5
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion locator/abstract_replication_strategy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion locator/abstract_replication_strategy.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion locator/everywhere_replication_strategy.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion locator/local_strategy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
}
Expand Down
2 changes: 1 addition & 1 deletion locator/local_strategy.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions locator/network_topology_strategy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion locator/network_topology_strategy.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion locator/simple_strategy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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" }};
}

Expand Down
2 changes: 1 addition & 1 deletion locator/simple_strategy.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 91f2fd5

Please sign in to comment.