locator: topology: add helpers to retrieve this host_id and address

And respective `is_me()` predicates,
to prepare for getting rid of fb_utilities.

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
This commit is contained in:
Benny Halevy
2023-11-29 16:14:49 +02:00
parent 52412087b7
commit 86716b2048
9 changed files with 32 additions and 15 deletions

View File

@@ -22,7 +22,6 @@
#include <boost/range/adaptors.hpp>
#include <seastar/core/smp.hh>
#include "utils/stall_free.hh"
#include "utils/fb_utilities.hh"
namespace locator {

View File

@@ -15,7 +15,6 @@
#include "locator/topology.hh"
#include "locator/production_snitch_base.hh"
#include "utils/stall_free.hh"
#include "utils/fb_utilities.hh"
namespace locator {

View File

@@ -161,6 +161,7 @@ class topology {
public:
struct config {
inet_address this_endpoint;
inet_address this_cql_address; // corresponds to broadcast_rpc_address
host_id this_host_id;
endpoint_dc_rack local_dc_rack;
bool disable_proximity_sorting = false;
@@ -336,6 +337,26 @@ public:
void for_each_node(std::function<void(const node*)> func) const;
host_id my_host_id() const noexcept {
return _cfg.this_host_id;
}
inet_address my_address() const noexcept {
return _cfg.this_endpoint;
}
inet_address my_cql_address() const noexcept {
return _cfg.this_cql_address;
}
bool is_me(const locator::host_id& id) const noexcept {
return id == my_host_id();
}
bool is_me(const inet_address& addr) const noexcept {
return addr == my_address();
}
private:
bool is_configured_this_node(const node&) const;
const node* add_node(node_holder node);