storage_service: make is_joined() an immediate function
Commitd41cd48amade 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 commitd41cd48a, 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:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user