1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef RGW_REALM_RELOADER_H
5 #define RGW_REALM_RELOADER_H
7 #include "rgw_realm_watcher.h"
8 #include "common/Cond.h"
13 * RGWRealmReloader responds to new period notifications by recreating RGWRados
14 * with the updated realm configuration.
16 class RGWRealmReloader : public RGWRealmWatcher::Watcher {
19 * Pauser is an interface to pause/resume frontends. Frontend cooperation
20 * is required to ensure that they stop issuing requests on the old
21 * RGWRados instance, and restart with the updated configuration.
23 * This abstraction avoids a depency on class RGWFrontend.
27 virtual ~Pauser() = default;
29 /// pause all frontends while realm reconfiguration is in progress
30 virtual void pause() = 0;
31 /// resume all frontends with the given RGWRados instance
32 virtual void resume(RGWRados* store) = 0;
35 RGWRealmReloader(RGWRados*& store, std::map<std::string, std::string>& service_map_meta,
37 ~RGWRealmReloader() override;
39 /// respond to realm notifications by scheduling a reload()
40 void handle_notify(RGWRealmNotify type, bufferlist::iterator& p) override;
43 /// pause frontends and replace the RGWRados instance
46 class C_Reload; //< Context that calls reload()
48 /// main()'s RGWRados pointer as a reference, modified by reload()
50 std::map<std::string, std::string>& service_map_meta;
51 Pauser *const frontends;
53 /// reload() takes a significant amount of time, so we don't want to run
54 /// it in the handle_notify() thread. we choose a timer thread instead of a
55 /// Finisher because it allows us to cancel events that were scheduled while
56 /// reload() is still running
58 Mutex mutex; //< protects access to timer and reload_scheduled
59 Cond cond; //< to signal reload() after an invalid realm config
60 C_Reload* reload_scheduled; //< reload() context if scheduled
63 #endif // RGW_REALM_RELOADER_H