From 20ecb0bede66f2fd4c6ec0faaddff456cd8d14ab Mon Sep 17 00:00:00 2001 From: Asias He Date: Thu, 29 Oct 2015 16:40:23 +0800 Subject: [PATCH] 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. --- database.cc | 12 ++++++++++++ database.hh | 2 ++ 2 files changed, 14 insertions(+) diff --git a/database.cc b/database.cc index b2e226f978..11ba21eebf 100644 --- a/database.cc +++ b/database.cc @@ -1471,6 +1471,18 @@ database::query_mutations(const query::read_command& cmd, const query::partition } } +std::unordered_set database::get_initial_tokens() { + std::unordered_set 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); } diff --git a/database.hh b/database.hh index 711f6d8de8..8c351f559d 100644 --- a/database.hh +++ b/database.hh @@ -633,6 +633,8 @@ public: const logalloc::region_group& dirty_memory_region_group() const { return _dirty_memory_region_group; } + + std::unordered_set get_initial_tokens(); }; // FIXME: stub