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