replication_strategy: calculate_natural_endpoints: make token_metadata& param const

No replication strategy needs to change token_metadata
when calculating natural endpoints.

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
This commit is contained in:
Benny Halevy
2020-08-13 12:41:48 +03:00
parent 78f40cac8d
commit b4f76cbb8a
8 changed files with 11 additions and 11 deletions

View File

@@ -87,7 +87,7 @@ public:
snitch_ptr& snitch,
const std::map<sstring, sstring>& config_options,
replication_strategy_type my_type);
virtual std::vector<inet_address> calculate_natural_endpoints(const token& search_token, token_metadata& tm) const = 0;
virtual std::vector<inet_address> calculate_natural_endpoints(const token& search_token, const token_metadata& tm) const = 0;
virtual ~abstract_replication_strategy() {}
static std::unique_ptr<abstract_replication_strategy> create_replication_strategy(const sstring& ks_name, const sstring& strategy_name, token_metadata& token_metadata, const std::map<sstring, sstring>& config_options);
static void validate_replication_strategy(const sstring& ks_name,

View File

@@ -46,7 +46,7 @@ class everywhere_replication_strategy : public abstract_replication_strategy {
public:
everywhere_replication_strategy(const sstring& keyspace_name, token_metadata& token_metadata, snitch_ptr& snitch, const std::map<sstring,sstring>& config_options);
virtual std::vector<inet_address> calculate_natural_endpoints(const token& search_token, token_metadata& tm) const override {
virtual std::vector<inet_address> calculate_natural_endpoints(const token& search_token, const token_metadata& tm) const override {
return tm.get_all_endpoints();
}
std::vector<inet_address> get_natural_endpoints(const token& search_token) override;

View File

@@ -34,7 +34,7 @@ std::vector<inet_address> local_strategy::get_natural_endpoints(const token& t)
return calculate_natural_endpoints(t, _token_metadata);
}
std::vector<inet_address> local_strategy::calculate_natural_endpoints(const token& t, token_metadata& tm) const {
std::vector<inet_address> local_strategy::calculate_natural_endpoints(const token& t, const token_metadata& tm) const {
return std::vector<inet_address>({utils::fb_utilities::get_broadcast_address()});
}

View File

@@ -36,7 +36,7 @@ using token = dht::token;
class local_strategy : public abstract_replication_strategy {
protected:
virtual std::vector<inet_address> calculate_natural_endpoints(const token& search_token, token_metadata& tm) const override;
virtual std::vector<inet_address> calculate_natural_endpoints(const token& search_token, const token_metadata& tm) const override;
public:
local_strategy(const sstring& keyspace_name, token_metadata& token_metadata, snitch_ptr& snitch, const std::map<sstring, sstring>& config_options);
virtual ~local_strategy() {};

View File

@@ -104,7 +104,7 @@ network_topology_strategy::network_topology_strategy(
std::vector<inet_address>
network_topology_strategy::calculate_natural_endpoints(
const token& search_token, token_metadata& tm) const {
const token& search_token, const token_metadata& tm) const {
using endpoint_set = utils::sequenced_set<inet_address>;
using endpoint_dc_rack_set = std::unordered_set<endpoint_dc_rack>;
@@ -200,20 +200,20 @@ network_topology_strategy::calculate_natural_endpoints(
// tracks the racks we have already placed replicas in
endpoint_dc_rack_set seen_racks;
topology& tp = tm.get_topology();
const topology& tp = tm.get_topology();
//
// all endpoints in each DC, so we can check when we have exhausted all
// the members of a DC
//
std::unordered_map<sstring,
const std::unordered_map<sstring,
std::unordered_set<inet_address>>&
all_endpoints = tp.get_datacenter_endpoints();
//
// all racks in a DC so we can check when we have exhausted all racks in a
// DC
//
std::unordered_map<sstring,
const std::unordered_map<sstring,
std::unordered_map<sstring,
std::unordered_set<inet_address>>>&
racks = tp.get_datacenter_racks();

View File

@@ -76,7 +76,7 @@ protected:
* progress in each DC, rack etc.
*/
virtual std::vector<inet_address> calculate_natural_endpoints(
const token& search_token, token_metadata& tm) const override;
const token& search_token, const token_metadata& tm) const override;
virtual void validate_options() const override;

View File

@@ -42,7 +42,7 @@ simple_strategy::simple_strategy(const sstring& keyspace_name, token_metadata& t
}
}
std::vector<inet_address> simple_strategy::calculate_natural_endpoints(const token& t, token_metadata& tm) const {
std::vector<inet_address> simple_strategy::calculate_natural_endpoints(const token& t, const token_metadata& tm) const {
const std::vector<token>& tokens = tm.sorted_tokens();
if (tokens.empty()) {

View File

@@ -30,7 +30,7 @@ namespace locator {
class simple_strategy : public abstract_replication_strategy {
protected:
virtual std::vector<inet_address> calculate_natural_endpoints(const token& search_token, token_metadata& tm) const override;
virtual std::vector<inet_address> calculate_natural_endpoints(const token& search_token, const token_metadata& tm) const override;
public:
simple_strategy(const sstring& keyspace_name, token_metadata& token_metadata, snitch_ptr& snitch, const std::map<sstring, sstring>& config_options);
virtual ~simple_strategy() {};