From e9bd912f7906471ca5414e77c533b5ce391d9996 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Thu, 25 Aug 2022 16:48:31 +0300 Subject: [PATCH] snitch: Drop some dead dependency knots After previous patches and merged branches snitch no longer needs its method that gets dc/rack for endpoints from gossiper, system keyspace and its internal caches. This cuts the last but the biggest snitch->gossiper dependency. Also this removes implicit snitch->system_keyspace dependency loop Signed-off-by: Pavel Emelyanov --- locator/production_snitch_base.cc | 33 ------------------------------- locator/production_snitch_base.hh | 4 ---- 2 files changed, 37 deletions(-) diff --git a/locator/production_snitch_base.cc b/locator/production_snitch_base.cc index af2b18ad38..e249b0df07 100644 --- a/locator/production_snitch_base.cc +++ b/locator/production_snitch_base.cc @@ -45,39 +45,6 @@ void production_snitch_base::set_backreference(snitch_ptr& d) { _backreference = &d; } -std::optional production_snitch_base::get_endpoint_info(inet_address endpoint, gms::application_state key) { - gms::gossiper& local_gossiper = local().get_local_gossiper(); - auto* ep_state = local_gossiper.get_application_state_ptr(endpoint, key); - return ep_state ? std::optional(ep_state->value) : std::nullopt; -} - -sstring production_snitch_base::get_endpoint_info(inet_address endpoint, gms::application_state key, - const sstring& default_val) { - auto val = get_endpoint_info(endpoint, key); - auto& gossiper = local().get_local_gossiper(); - - if (val) { - return *val; - } - // ...if not found - look in the SystemTable... - if (!_saved_endpoints) { - _saved_endpoints = gossiper.get_system_keyspace().local().load_dc_rack_info(); - } - - auto it = _saved_endpoints->find(endpoint); - - if (it != _saved_endpoints->end()) { - if (key == gms::application_state::RACK) { - return it->second.rack; - } else { // gms::application_state::DC - return it->second.dc; - } - } - - // ...if still not found - return a default value - return default_val; -} - void production_snitch_base::set_my_dc_and_rack(const sstring& new_dc, const sstring& new_rack) { if (!new_dc.empty()) { _my_dc = new_dc; diff --git a/locator/production_snitch_base.hh b/locator/production_snitch_base.hh index 436af18a7f..dfc5741e53 100644 --- a/locator/production_snitch_base.hh +++ b/locator/production_snitch_base.hh @@ -47,9 +47,6 @@ public: virtual void set_backreference(snitch_ptr& d) override; private: - std::optional get_endpoint_info(inet_address endpoint, gms::application_state key); - sstring get_endpoint_info(inet_address endpoint, gms::application_state key, - const sstring& default_val); virtual void set_my_dc_and_rack(const sstring& new_dc, const sstring& new_rack) override; virtual void set_prefer_local(bool prefer_local) override; void parse_property_file(); @@ -76,7 +73,6 @@ protected: void throw_incomplete_file() const; protected: - std::optional _saved_endpoints; std::string _prop_file_contents; sstring _prop_file_name; std::unordered_map _prop_values;