token_metadata: Enable remove_from_moving

This commit is contained in:
Asias He
2015-08-04 10:55:23 +08:00
parent 2250123654
commit c42df5b40d
2 changed files with 14 additions and 33 deletions

View File

@@ -76,8 +76,7 @@ void token_metadata::update_normal_tokens(std::unordered_map<inet_address, std::
}
bool should_sort_tokens = false;
for (auto&& i : endpoint_tokens)
{
for (auto&& i : endpoint_tokens) {
inet_address endpoint = i.first;
std::unordered_set<token>& tokens = i.second;
@@ -92,17 +91,15 @@ void token_metadata::update_normal_tokens(std::unordered_map<inet_address, std::
}
_topology.add_endpoint(endpoint);
#if 0
bootstrapTokens.removeValue(endpoint);
leavingEndpoints.remove(endpoint);
removeFromMoving(endpoint); // also removing this endpoint from moving
#endif
remove_by_value(_bootstrap_tokens, endpoint);
_leaving_endpoints.erase(endpoint);
remove_from_moving(endpoint); // also removing this endpoint from moving
for (const token& t : tokens)
{
auto prev = _token_to_endpoint_map.insert(std::pair<token, inet_address>(t, endpoint));
should_sort_tokens |= prev.second; // new token inserted -> sort
if (prev.first->second != endpoint) {
//logger.warn("Token {} changing ownership from {} to {}", token, prev.first->second, endpoint);
if (prev.first->second != endpoint) {
// logger.warn("Token {} changing ownership from {} to {}", t, prev.first->second, endpoint);
prev.first->second = endpoint;
}
}
@@ -283,6 +280,12 @@ void token_metadata::remove_endpoint(inet_address endpoint) {
invalidate_cached_rings();
}
void token_metadata::remove_from_moving(inet_address endpoint) {
remove_by_value(_moving_endpoints, endpoint);
invalidate_cached_rings();
}
/////////////////// class topology /////////////////////////////////////////////
inline void topology::clear() {
_dc_endpoints.clear();

View File

@@ -470,35 +470,13 @@ public:
#endif
public:
void remove_endpoint(inet_address endpoint);
#if 0
/**
* Remove pair of token/address from moving endpoints
* @param endpoint address of the moving node
*/
public void removeFromMoving(InetAddress endpoint)
{
assert endpoint != null;
lock.writeLock().lock();
try
{
for (Pair<Token, InetAddress> pair : _moving_endpoints)
{
if (pair.right.equals(endpoint))
{
_moving_endpoints.remove(pair);
break;
}
}
invalidateCachedRings();
}
finally
{
lock.writeLock().unlock();
}
}
void remove_from_moving(inet_address endpoint);
#if 0
public Collection<Token> getTokens(InetAddress endpoint)
{