From 645700d261cc9afd0f8aa3142fd0e5a27168da7e Mon Sep 17 00:00:00 2001 From: Asias He Date: Tue, 11 Aug 2015 10:51:54 +0800 Subject: [PATCH] storage_service: Implement join_ring Join the ring by operator request. --- service/storage_service.cc | 31 ++++++++++++------------------- service/storage_service.hh | 2 +- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/service/storage_service.cc b/service/storage_service.cc index a458e00368..467fa7c866 100644 --- a/service/storage_service.cc +++ b/service/storage_service.cc @@ -314,28 +314,21 @@ future<> storage_service::join_token_ring(int delay) { }); } -void storage_service::join_ring() { -#if 0 - if (!joined) { +future<> storage_service::join_ring() { + if (!_joined) { logger.info("Joining ring by operator request"); - try - { - joinTokenRing(0); - } - catch (ConfigurationException e) - { - throw new IOException(e.getMessage()); - } + return join_token_ring(0); } else if (_is_survey_mode) { - set_tokens(SystemKeyspace.getSavedTokens()); - SystemKeyspace.setBootstrapState(SystemKeyspace.BootstrapState.COMPLETED); - _is_survey_mode = false; - logger.info("Leaving write survey mode and joining ring at operator request"); - assert _token_metadata.sortedTokens().size() > 0; - - Auth.setup(); + return set_tokens(db::system_keyspace::get_saved_tokens()).then([this] { + //SystemKeyspace.setBootstrapState(SystemKeyspace.BootstrapState.COMPLETED); + _is_survey_mode = false; + logger.info("Leaving write survey mode and joining ring at operator request"); + assert(_token_metadata.sorted_tokens().size() > 0); + //Auth.setup(); + return make_ready_future<>(); + }); } -#endif + return make_ready_future<>(); } future<> storage_service::bootstrap(std::unordered_set tokens) { diff --git a/service/storage_service.hh b/service/storage_service.hh index fce933d7da..81f3cf38e6 100644 --- a/service/storage_service.hh +++ b/service/storage_service.hh @@ -371,7 +371,7 @@ private: future<> prepare_to_join(); future<> join_token_ring(int delay); public: - void join_ring(); + future<> join_ring(); bool is_joined() { return _joined; }