system_keyspaces: implement remove_endpoint

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
This commit is contained in:
Glauber Costa
2015-07-09 11:32:46 -04:00
parent e559959632
commit afee9ab72a
2 changed files with 14 additions and 9 deletions

View File

@@ -683,16 +683,19 @@ future<> update_schema_version(utils::UUID version) {
return tokens;
}
/**
* Remove stored tokens being used by another node
*/
public static synchronized void removeEndpoint(InetAddress ep)
{
String req = "DELETE FROM system.%s WHERE peer = ?";
executeInternal(String.format(req, PEERS), ep);
}
#endif
/**
* Remove stored tokens being used by another node
*/
future<> remove_endpoint(gms::inet_address ep) {
return _local_cache.invoke_on_all([ep] (local_cache& lc) {
lc._cached_dc_rack_info.erase(ep);
}).then([ep] {
sstring req = "DELETE FROM system.%s WHERE peer = ?";
return execute_cql(req, PEERS, ep).discard_result();
});
}
/**
* This method is used to update the System Keyspace with the new tokens for this node
*/

View File

@@ -72,6 +72,8 @@ future<> update_tokens(std::unordered_set<dht::token> tokens);
template <typename Value>
future<> update_peer_info(gms::inet_address ep, sstring column_name, Value value);
future<> remove_endpoint(gms::inet_address ep);
std::vector<schema_ptr> all_tables();
void make(database& db, bool durable);