From 66bc84d217d37799499f8e932c6fcf4c032094cd Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Thu, 8 Sep 2022 19:06:55 +0300 Subject: [PATCH] snitch: Get local address to gossip via config The property-file snitch gossips listen_address as internal-IP state. To get this value it gets it from snitch->gossiper->messaging_service chain. This change provides the needed value via config thus cutting yet another snitch->gossiper dependency and allowing gossiper not to export messaging service in the future Signed-off-by: Pavel Emelyanov --- locator/gossiping_property_file_snitch.cc | 6 ++++-- locator/gossiping_property_file_snitch.hh | 1 + locator/snitch_base.hh | 3 +++ main.cc | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/locator/gossiping_property_file_snitch.cc b/locator/gossiping_property_file_snitch.cc index e43a910103..c1b70d420a 100644 --- a/locator/gossiping_property_file_snitch.cc +++ b/locator/gossiping_property_file_snitch.cc @@ -40,7 +40,9 @@ future gossiping_property_file_snitch::property_file_was_modified() { } gossiping_property_file_snitch::gossiping_property_file_snitch(const snitch_config& cfg) - : production_snitch_base(cfg), _file_reader_cpu_id(cfg.io_cpu_id) { + : production_snitch_base(cfg) + , _file_reader_cpu_id(cfg.io_cpu_id) + , _listen_address(cfg.listen_address) { if (this_shard_id() == _file_reader_cpu_id) { io_cpu_id() = _file_reader_cpu_id; } @@ -102,7 +104,7 @@ void gossiping_property_file_snitch::periodic_reader_callback() { } std::list> gossiping_property_file_snitch::get_app_states() const { - sstring ip = format("{}", local().get_local_gossiper().get_local_messaging().listen_address()); + sstring ip = format("{}", _listen_address); return { {gms::application_state::DC, gms::versioned_value::datacenter(_my_dc)}, {gms::application_state::RACK, gms::versioned_value::rack(_my_rack)}, diff --git a/locator/gossiping_property_file_snitch.hh b/locator/gossiping_property_file_snitch.hh index 0f9a1009e4..0de0be6da7 100644 --- a/locator/gossiping_property_file_snitch.hh +++ b/locator/gossiping_property_file_snitch.hh @@ -93,6 +93,7 @@ private: unsigned _file_reader_cpu_id; snitch_signal_t _reconfigured; promise<> _io_is_stopped; + gms::inet_address _listen_address; void reset_io_state() { // Reset the promise to allow repeating diff --git a/locator/snitch_base.hh b/locator/snitch_base.hh index 79d228d203..d13f64eb4a 100644 --- a/locator/snitch_base.hh +++ b/locator/snitch_base.hh @@ -47,6 +47,9 @@ struct snitch_config { unsigned io_cpu_id = 0; bool broadcast_rpc_address_specified_by_user = false; + // Gossiping-property-file specific + gms::inet_address listen_address; + // GCE-specific sstring gce_meta_server_url = ""; }; diff --git a/main.cc b/main.cc index 9bc75913a8..c3eeaa39a9 100644 --- a/main.cc +++ b/main.cc @@ -892,6 +892,7 @@ To start the scylla server proper, simply invoke as: scylla server (or just scyl snitch_config snitch_cfg; snitch_cfg.name = cfg->endpoint_snitch(); snitch_cfg.broadcast_rpc_address_specified_by_user = !cfg->broadcast_rpc_address().empty(); + snitch_cfg.listen_address = utils::resolve(cfg->listen_address, family).get0(); sharded& snitch = i_endpoint_snitch::snitch_instance(); snitch.start(snitch_cfg, std::ref(gossiper)).get(); auto stop_snitch = defer_verbose_shutdown("snitch", [&snitch] {