token_metadata: Add is_member

This commit is contained in:
Asias He
2015-06-01 14:22:58 +08:00
parent 06a792d6be
commit 6b263e46eb
2 changed files with 10 additions and 14 deletions

View File

@@ -180,6 +180,12 @@ const auto& token_metadata::get_endpoint_to_host_id_map_for_reading() {
return _endpoint_to_host_id_map;
}
bool token_metadata::is_member(inet_address endpoint) {
auto beg = _token_to_endpoint_map.cbegin();
auto end = _token_to_endpoint_map.cend();
return end != std::find_if(beg, end, [endpoint] (const auto& x) {
return x.second == endpoint;
});
}
}

View File

@@ -426,21 +426,11 @@ public:
return getTokens(endpoint).iterator().next();
}
public boolean isMember(InetAddress endpoint)
{
assert endpoint != null;
#endif
lock.readLock().lock();
try
{
return tokenToEndpointMap.inverse().containsKey(endpoint);
}
finally
{
lock.readLock().unlock();
}
}
bool is_member(inet_address endpoint);
#if 0
public boolean isLeaving(InetAddress endpoint)
{
assert endpoint != null;