token_metadata: Add this_host_id to topology config

The motivation is that token_metadata::get_my_id() is not available
early in the bootstrap process, as raft topology is pulled later
than new tables are registered and created, and this node is added
to topology even later.

To allow creation of compaction groups to retrieve "my id" from
token metadata early, initialization will now feed local id
into topology config which is immutable for each node anyway.

Signed-off-by: Raphael S. Carvalho <raphaelsc@scylladb.com>
This commit is contained in:
Raphael S. Carvalho
2023-08-14 17:11:52 -03:00
parent d3f71ae4ee
commit 5d1f60439a
5 changed files with 20 additions and 7 deletions

View File

@@ -334,7 +334,7 @@ token_metadata::tokens_iterator& token_metadata::tokens_iterator::operator++() {
}
host_id token_metadata::get_my_id() const {
return get_host_id(utils::fb_utilities::get_broadcast_address());
return get_topology().get_config().this_host_id;
}
inline

View File

@@ -161,6 +161,7 @@ class topology {
public:
struct config {
inet_address this_endpoint;
host_id this_host_id;
endpoint_dc_rack local_dc_rack;
bool disable_proximity_sorting = false;
@@ -177,6 +178,10 @@ public:
public:
const config& get_config() const noexcept { return _cfg; }
void set_host_id_cfg(host_id this_host_id) {
_cfg.this_host_id = this_host_id;
}
const node* this_node() const noexcept {
return _this_node;
}