diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/rgw/rgw_realm_reloader.h | |
parent | Initial commit. (diff) | |
download | ceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/rgw/rgw_realm_reloader.h')
-rw-r--r-- | src/rgw/rgw_realm_reloader.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/rgw/rgw_realm_reloader.h b/src/rgw/rgw_realm_reloader.h new file mode 100644 index 000000000..25082a2e4 --- /dev/null +++ b/src/rgw/rgw_realm_reloader.h @@ -0,0 +1,64 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab ft=cpp + +#pragma once + +#include "rgw_realm_watcher.h" +#include "common/Cond.h" +#include "rgw_sal_fwd.h" + +struct RGWProcessEnv; +namespace rgw::auth { class ImplicitTenants; } + +/** + * RGWRealmReloader responds to new period notifications by recreating RGWRados + * with the updated realm configuration. + */ +class RGWRealmReloader : public RGWRealmWatcher::Watcher { + public: + /** + * Pauser is an interface to pause/resume frontends. Frontend cooperation + * is required to ensure that they stop issuing requests on the old + * RGWRados instance, and restart with the updated configuration. + * + * This abstraction avoids a dependency on class RGWFrontend. + */ + class Pauser { + public: + virtual ~Pauser() = default; + + /// pause all frontends while realm reconfiguration is in progress + virtual void pause() = 0; + /// resume all frontends with the given RGWRados instance + virtual void resume(rgw::sal::Driver* driver) = 0; + }; + + RGWRealmReloader(RGWProcessEnv& env, + const rgw::auth::ImplicitTenants& implicit_tenants, + std::map<std::string, std::string>& service_map_meta, + Pauser* frontends); + ~RGWRealmReloader() override; + + /// respond to realm notifications by scheduling a reload() + void handle_notify(RGWRealmNotify type, bufferlist::const_iterator& p) override; + + private: + /// pause frontends and replace the RGWRados instance + void reload(); + + class C_Reload; //< Context that calls reload() + + RGWProcessEnv& env; + const rgw::auth::ImplicitTenants& implicit_tenants; + std::map<std::string, std::string>& service_map_meta; + Pauser *const frontends; + + /// reload() takes a significant amount of time, so we don't want to run + /// it in the handle_notify() thread. we choose a timer thread instead of a + /// Finisher because it allows us to cancel events that were scheduled while + /// reload() is still running + SafeTimer timer; + ceph::mutex mutex; //< protects access to timer and reload_scheduled + ceph::condition_variable cond; //< to signal reload() after an invalid realm config + C_Reload* reload_scheduled; //< reload() context if scheduled +}; |