storage_service: make is_joined() an immediate function

Commit d41cd48a made the is_joined() method a future<bool> because
only cpu 0 knows its real value. This makes this function inconvenient
to use. So this patch reverts commit d41cd48a, and instead sets this
flag's value on all shards, so each shard can read its value locally
(and immediately).

Signed-off-by: Nadav Har'El <nyh@scylladb.com>
Message-Id: <20161228160450.5831-1-nyh@scylladb.com>
This commit is contained in:
Nadav Har'El
2016-12-28 18:04:50 +02:00
committed by Avi Kivity
parent 2aee7f6334
commit d49aa7abd2
3 changed files with 11 additions and 9 deletions

View File

@@ -551,9 +551,7 @@ void set_storage_service(http_context& ctx, routes& r) {
});
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);
});
return make_ready_future<json::json_return_type>(service::get_local_storage_service().is_joined());
});
ss::set_stream_throughput_mb_per_sec.set(r, [](std::unique_ptr<request> req) {

View File

@@ -315,7 +315,11 @@ void storage_service::prepare_to_join(std::vector<inet_address> loaded_endpoints
// Runs inside seastar::async context
void storage_service::join_token_ring(int delay) {
_joined = true;
// This function only gets called on shard 0, but we want to set _joined
// on all shards, so this variable can be later read locally.
get_storage_service().invoke_on_all([] (auto&& ss) {
ss._joined = true;
}).get();
// We bootstrap if we haven't successfully bootstrapped before, as long as we are not a seed.
// If we are a seed, or if the user manually sets auto_bootstrap to false,
// we'll skip streaming data from other nodes and jump directly into the ring.
@@ -509,10 +513,10 @@ future<> storage_service::join_ring() {
});
}
future<bool> storage_service::is_joined() {
return run_with_no_api_lock([] (storage_service& ss) {
return ss._joined && !ss._is_survey_mode;
});
bool storage_service::is_joined() {
// Every time we set _joined, we do it on all shards, so we can read its
// value locally.
return _joined && !_is_survey_mode;
}
// Runs inside seastar::async context

View File

@@ -398,7 +398,7 @@ private:
void join_token_ring(int delay);
public:
future<> join_ring();
future<bool> is_joined();
bool is_joined();
future<> rebuild(sstring source_dc);