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 <xemul@scylladb.com>
This commit is contained in:
Pavel Emelyanov
2022-09-08 19:06:55 +03:00
parent 77bde21024
commit 66bc84d217
4 changed files with 9 additions and 2 deletions

View File

@@ -40,7 +40,9 @@ future<bool> 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<std::pair<gms::application_state, gms::versioned_value>> 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)},

View File

@@ -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

View File

@@ -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 = "";
};

View File

@@ -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<locator::snitch_ptr>& snitch = i_endpoint_snitch::snitch_instance();
snitch.start(snitch_cfg, std::ref(gossiper)).get();
auto stop_snitch = defer_verbose_shutdown("snitch", [&snitch] {