database: Introduce get_initial_tokens

Get initial tokens specified by the initial_token in scylla.conf.

E.g.,

   --initial-token "-1112521204969569328,1117992399013959838"
   --initial-token "1117992399013959838"

It can be multiple tokens split by comma.
This commit is contained in:
Asias He
2015-10-29 16:40:23 +08:00
parent 16596385ee
commit 20ecb0bede
2 changed files with 14 additions and 0 deletions

View File

@@ -1471,6 +1471,18 @@ database::query_mutations(const query::read_command& cmd, const query::partition
}
}
std::unordered_set<sstring> database::get_initial_tokens() {
std::unordered_set<sstring> tokens;
sstring tokens_string = get_config().initial_token();
try {
boost::split(tokens, tokens_string, boost::is_any_of(sstring(",")));
} catch (...) {
throw std::runtime_error(sprint("Unable to parse initial_token=%s", tokens_string));
}
tokens.erase("");
return tokens;
}
std::ostream& operator<<(std::ostream& out, const atomic_cell_or_collection& c) {
return out << to_hex(c._data);
}

View File

@@ -633,6 +633,8 @@ public:
const logalloc::region_group& dirty_memory_region_group() const {
return _dirty_memory_region_group;
}
std::unordered_set<sstring> get_initial_tokens();
};
// FIXME: stub