From e4e4b269c71198ec585903a7183402159f75b044 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Wed, 19 Aug 2020 13:16:48 +0300 Subject: [PATCH] everywhere_replication_strategy: move methods out of line Move methods depending on token_metadata to source file so we can avoid including token_metadata.hh in header files where spossible. Signed-off-by: Benny Halevy --- locator/everywhere_replication_strategy.cc | 9 +++++++++ locator/everywhere_replication_strategy.hh | 8 ++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/locator/everywhere_replication_strategy.cc b/locator/everywhere_replication_strategy.cc index 78757f92f5..b0bca67b25 100644 --- a/locator/everywhere_replication_strategy.cc +++ b/locator/everywhere_replication_strategy.cc @@ -40,12 +40,17 @@ #include "locator/everywhere_replication_strategy.hh" #include "utils/class_registrator.hh" #include "utils/fb_utilities.hh" +#include "locator/token_metadata.hh" namespace locator { everywhere_replication_strategy::everywhere_replication_strategy(const sstring& keyspace_name, const token_metadata& token_metadata, snitch_ptr& snitch, const std::map& config_options) : abstract_replication_strategy(keyspace_name, token_metadata, snitch, config_options, replication_strategy_type::everywhere_topology) {} +std::vector everywhere_replication_strategy::calculate_natural_endpoints(const token& search_token, const token_metadata& tm) const { + return tm.get_all_endpoints(); +} + std::vector everywhere_replication_strategy::get_natural_endpoints(const token& search_token) { if (_token_metadata.sorted_tokens().empty()) { return std::vector({utils::fb_utilities::get_broadcast_address()}); @@ -53,6 +58,10 @@ std::vector everywhere_replication_strategy::get_natural_endpoints return calculate_natural_endpoints(search_token, _token_metadata); } +size_t everywhere_replication_strategy::get_replication_factor() const { + return _token_metadata.get_all_endpoints_count(); +} + using registry = class_registrator&>; static registry registrator("org.apache.cassandra.locator.EverywhereStrategy"); static registry registrator_short_name("EverywhereStrategy"); diff --git a/locator/everywhere_replication_strategy.hh b/locator/everywhere_replication_strategy.hh index 8f0520edf3..11f9be2227 100644 --- a/locator/everywhere_replication_strategy.hh +++ b/locator/everywhere_replication_strategy.hh @@ -46,9 +46,7 @@ class everywhere_replication_strategy : public abstract_replication_strategy { public: everywhere_replication_strategy(const sstring& keyspace_name, const token_metadata& token_metadata, snitch_ptr& snitch, const std::map& config_options); - virtual std::vector calculate_natural_endpoints(const token& search_token, const token_metadata& tm) const override { - return tm.get_all_endpoints(); - } + virtual std::vector calculate_natural_endpoints(const token& search_token, const token_metadata& tm) const override; std::vector get_natural_endpoints(const token& search_token) override; virtual void validate_options() const override { /* noop */ } @@ -58,9 +56,7 @@ public: return std::nullopt; } - virtual size_t get_replication_factor() const override { - return _token_metadata.get_all_endpoints_count(); - } + virtual size_t get_replication_factor() const override; virtual bool allow_remove_node_being_replaced_from_natural_endpoints() const override { return true;