locator::token_metadata: added topology::update_endpoint(ep) and update_topology(ep)

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
This commit is contained in:
Vlad Zolotarov
2015-10-29 14:40:36 +02:00
parent a3d55ba882
commit b3504f9b1f
2 changed files with 18 additions and 0 deletions

View File

@@ -502,6 +502,14 @@ void topology::add_endpoint(const inet_address& ep)
_current_locations[ep] = {dc, rack};
}
void topology::update_endpoint(inet_address ep) {
if (!_current_locations.count(ep) || !locator::i_endpoint_snitch::snitch_instance().local_is_initialized()) {
return;
}
add_endpoint(ep);
}
void topology::remove_endpoint(inet_address ep)
{
auto cur_dc_rack = _current_locations.find(ep);

View File

@@ -82,6 +82,12 @@ public:
*/
void remove_endpoint(inet_address ep);
/**
* Re-reads the DC/rack info for the given endpoint
* @param ep endpoint in question
*/
void update_endpoint(inet_address ep);
std::unordered_map<sstring,
std::unordered_set<inet_address>>&
get_datacenter_endpoints() {
@@ -239,6 +245,10 @@ public:
return _bootstrap_tokens;
}
void update_topology(inet_address ep) {
_topology.update_endpoint(ep);
}
tokens_iterator tokens_end() const {
return tokens_iterator(sorted_tokens().end(), sorted_tokens().size());
}