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 <xemul@scylladb.com>
This commit is contained in:
Pavel Emelyanov
2022-08-25 16:48:31 +03:00
parent 4206b1f98f
commit e9bd912f79
2 changed files with 0 additions and 37 deletions

View File

@@ -45,39 +45,6 @@ void production_snitch_base::set_backreference(snitch_ptr& d) {
_backreference = &d;
}
std::optional<sstring> 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;

View File

@@ -47,9 +47,6 @@ public:
virtual void set_backreference(snitch_ptr& d) override;
private:
std::optional<sstring> 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<addr2dc_rack_map> _saved_endpoints;
std::string _prop_file_contents;
sstring _prop_file_name;
std::unordered_map<sstring, sstring> _prop_values;