storage_service: Serialize is_joined with read api lock

This commit is contained in:
Asias He
2015-10-28 10:01:48 +08:00
parent 24a452133a
commit d41cd48a5f
3 changed files with 12 additions and 5 deletions

View File

@@ -495,8 +495,10 @@ void set_storage_service(http_context& ctx, routes& r) {
});
});
ss::is_joined.set(r, [](const_req req) {
return service::get_local_storage_service().is_joined();
ss::is_joined.set(r, [] (std::unique_ptr<request> req) {
return service::get_local_storage_service().is_joined().then([] (bool is_joined) {
return make_ready_future<json::json_return_type>(is_joined);
});
});
ss::set_stream_throughput_mb_per_sec.set(r, [](std::unique_ptr<request> req) {

View File

@@ -379,6 +379,13 @@ future<> storage_service::join_ring() {
});
}
future<bool> storage_service::is_joined() {
return run_with_read_api_lock([] (storage_service& ss) {
return ss._joined;
});
}
// Runs inside seastar::async context
void storage_service::bootstrap(std::unordered_set<token> tokens) {
_is_bootstrap_mode = true;

View File

@@ -361,9 +361,7 @@ private:
void join_token_ring(int delay);
public:
future<> join_ring();
bool is_joined() {
return _joined;
}
future<bool> is_joined();
future<> rebuild(sstring source_dc);