mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-23 00:02:37 +00:00
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:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 {};
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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" }};
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user