token_metadata expose the token and token mapping
This adds an API that expose the token to endpoint mapping and the token that are associate with an address. Both method will be used by the API to expose the tokens. Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
This commit is contained in:
@@ -27,6 +27,15 @@ const std::vector<token>& token_metadata::sorted_tokens() const {
|
||||
return _sorted_tokens;
|
||||
}
|
||||
|
||||
std::vector<token> token_metadata::get_tokens(const inet_address& addr) const {
|
||||
std::vector<token> res;
|
||||
for (auto&& i : _token_to_endpoint_map) {
|
||||
if (i.second == addr) {
|
||||
res.push_back(i.first);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
/**
|
||||
* Update token map with a single token/endpoint pair in normal state.
|
||||
*/
|
||||
|
||||
@@ -49,6 +49,10 @@ public:
|
||||
const token& first_token(const token& start);
|
||||
size_t first_token_index(const token& start);
|
||||
std::experimental::optional<inet_address> get_endpoint(const token& token) const;
|
||||
std::vector<token> get_tokens(const inet_address& addr) const;
|
||||
const std::map<token, inet_address>& get_token_to_endpoint() const {
|
||||
return _token_to_endpoint_map;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user