]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #ifndef RGW_REALM_RELOADER_H | |
5 | #define RGW_REALM_RELOADER_H | |
6 | ||
7 | #include "rgw_realm_watcher.h" | |
8 | #include "common/Cond.h" | |
9 | ||
10 | class RGWRados; | |
11 | ||
12 | /** | |
13 | * RGWRealmReloader responds to new period notifications by recreating RGWRados | |
14 | * with the updated realm configuration. | |
15 | */ | |
16 | class RGWRealmReloader : public RGWRealmWatcher::Watcher { | |
17 | public: | |
18 | /** | |
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. | |
22 | * | |
23 | * This abstraction avoids a depency on class RGWFrontend. | |
24 | */ | |
25 | class Pauser { | |
26 | public: | |
27 | virtual ~Pauser() = default; | |
28 | ||
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; | |
33 | }; | |
34 | ||
224ce89b WB |
35 | RGWRealmReloader(RGWRados*& store, std::map<std::string, std::string>& service_map_meta, |
36 | Pauser* frontends); | |
7c673cae FG |
37 | ~RGWRealmReloader() override; |
38 | ||
39 | /// respond to realm notifications by scheduling a reload() | |
40 | void handle_notify(RGWRealmNotify type, bufferlist::iterator& p) override; | |
41 | ||
42 | private: | |
43 | /// pause frontends and replace the RGWRados instance | |
44 | void reload(); | |
45 | ||
46 | class C_Reload; //< Context that calls reload() | |
47 | ||
48 | /// main()'s RGWRados pointer as a reference, modified by reload() | |
49 | RGWRados*& store; | |
224ce89b | 50 | std::map<std::string, std::string>& service_map_meta; |
7c673cae FG |
51 | Pauser *const frontends; |
52 | ||
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 | |
57 | SafeTimer timer; | |
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 | |
61 | }; | |
62 | ||
63 | #endif // RGW_REALM_RELOADER_H |