topology: Make update_endpoint() accept dc-rack info
The method in question populates topology's internal maps with endpoint vs dc/rack relations. As for today the dc/rack values are taken from the global snitch object (which, in turn, goes to gossiper, system keyspace and its internal non-updateable cache for that). This patch prepares the ground for providing the dc/rack externally via argument. By now it's just and argument with empty strings, but next patches will populate it with real values (spoiler: in 99% it's storage service that calls this method and each call will know where to get it from for sure) Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
@@ -96,8 +96,8 @@ public:
|
||||
return _bootstrap_tokens;
|
||||
}
|
||||
|
||||
void update_topology(inet_address ep) {
|
||||
_topology.update_endpoint(ep);
|
||||
void update_topology(inet_address ep, endpoint_dc_rack dr) {
|
||||
_topology.update_endpoint(ep, std::move(dr));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -446,7 +446,7 @@ future<> token_metadata_impl::update_normal_tokens(std::unordered_set<token> tok
|
||||
// b. update pending _bootstrap_tokens and _leaving_endpoints
|
||||
// c. update _token_to_endpoint_map with the new endpoint->token mappings
|
||||
// - set `should_sort_tokens` if new tokens were added
|
||||
_topology.add_endpoint(endpoint);
|
||||
_topology.add_endpoint(endpoint, {});
|
||||
remove_by_value(_bootstrap_tokens, endpoint);
|
||||
_leaving_endpoints.erase(endpoint);
|
||||
invalidate_cached_rings();
|
||||
@@ -1022,8 +1022,8 @@ token_metadata::get_bootstrap_tokens() const {
|
||||
}
|
||||
|
||||
void
|
||||
token_metadata::update_topology(inet_address ep) {
|
||||
_impl->update_topology(ep);
|
||||
token_metadata::update_topology(inet_address ep, endpoint_dc_rack dr) {
|
||||
_impl->update_topology(ep, std::move(dr));
|
||||
}
|
||||
|
||||
boost::iterator_range<token_metadata::tokens_iterator>
|
||||
@@ -1243,7 +1243,7 @@ topology::topology(const topology& other) {
|
||||
_current_locations = other._current_locations;
|
||||
}
|
||||
|
||||
void topology::add_endpoint(const inet_address& ep)
|
||||
void topology::add_endpoint(const inet_address& ep, endpoint_dc_rack dr)
|
||||
{
|
||||
auto& snitch = i_endpoint_snitch::get_local_snitch_ptr();
|
||||
sstring dc = snitch->get_datacenter(ep);
|
||||
@@ -1262,12 +1262,12 @@ void topology::add_endpoint(const inet_address& ep)
|
||||
_current_locations[ep] = {dc, rack};
|
||||
}
|
||||
|
||||
void topology::update_endpoint(inet_address ep) {
|
||||
void topology::update_endpoint(inet_address ep, endpoint_dc_rack dr) {
|
||||
if (!_current_locations.contains(ep) || !locator::i_endpoint_snitch::snitch_instance().local_is_initialized()) {
|
||||
return;
|
||||
}
|
||||
|
||||
add_endpoint(ep);
|
||||
add_endpoint(ep, std::move(dr));
|
||||
}
|
||||
|
||||
void topology::remove_endpoint(inet_address ep)
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
/**
|
||||
* Stores current DC/rack assignment for ep
|
||||
*/
|
||||
void add_endpoint(const inet_address& ep);
|
||||
void add_endpoint(const inet_address& ep, endpoint_dc_rack dr);
|
||||
|
||||
/**
|
||||
* Removes current DC/rack assignment for ep
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
* Re-reads the DC/rack info for the given endpoint
|
||||
* @param ep endpoint in question
|
||||
*/
|
||||
void update_endpoint(inet_address ep);
|
||||
void update_endpoint(inet_address ep, endpoint_dc_rack dr);
|
||||
|
||||
/**
|
||||
* Returns true iff contains given endpoint
|
||||
@@ -174,7 +174,7 @@ public:
|
||||
const std::unordered_map<token, inet_address>& get_token_to_endpoint() const;
|
||||
const std::unordered_set<inet_address>& get_leaving_endpoints() const;
|
||||
const std::unordered_map<token, inet_address>& get_bootstrap_tokens() const;
|
||||
void update_topology(inet_address ep);
|
||||
void update_topology(inet_address ep, endpoint_dc_rack dr);
|
||||
/**
|
||||
* Creates an iterable range of the sorted tokens starting at the token next
|
||||
* after the given one.
|
||||
|
||||
@@ -3228,7 +3228,7 @@ future<> storage_service::update_topology(inet_address endpoint) {
|
||||
return container().invoke_on(0, [endpoint] (auto& ss) {
|
||||
return ss.mutate_token_metadata([&ss, endpoint] (mutable_token_metadata_ptr tmptr) mutable {
|
||||
// re-read local rack and DC info
|
||||
tmptr->update_topology(endpoint);
|
||||
tmptr->update_topology(endpoint, {});
|
||||
return make_ready_future<>();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user