From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/rgw/rgw_realm_reloader.h | 67 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/rgw/rgw_realm_reloader.h (limited to 'src/rgw/rgw_realm_reloader.h') diff --git a/src/rgw/rgw_realm_reloader.h b/src/rgw/rgw_realm_reloader.h new file mode 100644 index 000000000..ac14eec2b --- /dev/null +++ b/src/rgw/rgw_realm_reloader.h @@ -0,0 +1,67 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab ft=cpp + +#ifndef RGW_REALM_RELOADER_H +#define RGW_REALM_RELOADER_H + +#include "rgw_realm_watcher.h" +#include "common/Cond.h" + +namespace rgw { +namespace sal { +class RGWRadosStore; +} +} + +/** + * 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::RGWRadosStore* store) = 0; + }; + + RGWRealmReloader(rgw::sal::RGWRadosStore*& store, std::map& 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() + + /// main()'s RGWRadosStore pointer as a reference, modified by reload() + rgw::sal::RGWRadosStore*& store; + std::map& 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 +}; + +#endif // RGW_REALM_RELOADER_H -- cgit v1.2.3