]>
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 | ||
35 | RGWRealmReloader(RGWRados*& store, Pauser* frontends); | |
36 | ~RGWRealmReloader() override; | |
37 | ||
38 | /// respond to realm notifications by scheduling a reload() | |
39 | void handle_notify(RGWRealmNotify type, bufferlist::iterator& p) override; | |
40 | ||
41 | private: | |
42 | /// pause frontends and replace the RGWRados instance | |
43 | void reload(); | |
44 | ||
45 | class C_Reload; //< Context that calls reload() | |
46 | ||
47 | /// main()'s RGWRados pointer as a reference, modified by reload() | |
48 | RGWRados*& store; | |
49 | Pauser *const frontends; | |
50 | ||
51 | /// reload() takes a significant amount of time, so we don't want to run | |
52 | /// it in the handle_notify() thread. we choose a timer thread instead of a | |
53 | /// Finisher because it allows us to cancel events that were scheduled while | |
54 | /// reload() is still running | |
55 | SafeTimer timer; | |
56 | Mutex mutex; //< protects access to timer and reload_scheduled | |
57 | Cond cond; //< to signal reload() after an invalid realm config | |
58 | C_Reload* reload_scheduled; //< reload() context if scheduled | |
59 | }; | |
60 | ||
61 | #endif // RGW_REALM_RELOADER_H |