From ba47ef039789a537e2f4ebbbd9075f5ffceddf01 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Tue, 24 Dec 2019 13:13:39 +0300 Subject: [PATCH] snapshots: Move ops gate from storage_service Signed-off-by: Pavel Emelyanov --- db/snapshot-ctl.cc | 7 ++----- db/snapshot-ctl.hh | 5 +++++ main.cc | 3 --- service/storage_service.hh | 7 ------- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/db/snapshot-ctl.cc b/db/snapshot-ctl.cc index b7af0e41f4..6901ea0454 100644 --- a/db/snapshot-ctl.cc +++ b/db/snapshot-ctl.cc @@ -40,7 +40,6 @@ #include #include "db/snapshot-ctl.hh" -#include "service/storage_service.hh" namespace db { @@ -58,8 +57,7 @@ future<> check_snapshot_not_exist(database& db, sstring ks_name, sstring name) { template std::result_of_t snapshot_ctl::run_snapshot_modify_operation(Func&& f) { - auto& ss = service::get_storage_service(); - return with_gate(ss.local()._snapshot_ops, [f = std::move(f), this] () { + return with_gate(_ops, [f = std::move(f), this] () { return container().invoke_on(0, [f = std::move(f)] (snapshot_ctl& snap) mutable { return with_lock(snap._lock.for_write(), std::move(f)); }); @@ -68,8 +66,7 @@ std::result_of_t snapshot_ctl::run_snapshot_modify_operation(Func&& f) { template std::result_of_t snapshot_ctl::run_snapshot_list_operation(Func&& f) { - auto& ss = service::get_storage_service(); - return with_gate(ss.local()._snapshot_ops, [f = std::move(f), this] () { + return with_gate(_ops, [f = std::move(f), this] () { return container().invoke_on(0, [f = std::move(f)] (snapshot_ctl& snap) mutable { return with_lock(snap._lock.for_read(), std::move(f)); }); diff --git a/db/snapshot-ctl.hh b/db/snapshot-ctl.hh index e553c3e0cb..3ee56348d5 100644 --- a/db/snapshot-ctl.hh +++ b/db/snapshot-ctl.hh @@ -58,6 +58,10 @@ public: }; explicit snapshot_ctl(sharded& db) : _db(db) {} + future<> stop() { + return _ops.close(); + } + /** * Takes the snapshot for all keyspaces. A snapshot name must be specified. * @@ -106,6 +110,7 @@ public: private: sharded& _db; seastar::rwlock _lock; + seastar::gate _ops; template std::result_of_t run_snapshot_modify_operation(Func&&); diff --git a/main.cc b/main.cc index 465b538f1d..52192549da 100644 --- a/main.cc +++ b/main.cc @@ -1060,9 +1060,6 @@ int main(int ac, char** av) { auth_service.stop().get(); }); - auto stop_snapshots = defer_verbose_shutdown("snapshots", [] { - service::get_storage_service().invoke_on_all(&service::storage_service::snapshots_close).get(); - }); snapshot_ctl.start(std::ref(db)).get(); auto stop_snapshot_ctl = defer_verbose_shutdown("snapshots", [&snapshot_ctl] { diff --git a/service/storage_service.hh b/service/storage_service.hh index 750ed45165..715e2282d3 100644 --- a/service/storage_service.hh +++ b/service/storage_service.hh @@ -233,14 +233,7 @@ private: bool _joined = false; public: - seastar::gate _snapshot_ops; - enum class mode { STARTING, NORMAL, JOINING, LEAVING, DECOMMISSIONED, MOVING, DRAINING, DRAINED }; - - future<> snapshots_close() { - return _snapshot_ops.close(); - } - private: mode _operation_mode = mode::STARTING; friend std::ostream& operator<<(std::ostream& os, const mode& mode);