]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
9f95a23c | 2 | // vim: ts=8 sw=2 smarttab ft=cpp |
7c673cae | 3 | |
1e59de90 | 4 | #pragma once |
7c673cae FG |
5 | |
6 | #include "rgw_realm_watcher.h" | |
7 | #include "common/Cond.h" | |
1e59de90 | 8 | #include "rgw_sal_fwd.h" |
7c673cae | 9 | |
1e59de90 TL |
10 | struct RGWProcessEnv; |
11 | namespace rgw::auth { class ImplicitTenants; } | |
7c673cae FG |
12 | |
13 | /** | |
14 | * RGWRealmReloader responds to new period notifications by recreating RGWRados | |
15 | * with the updated realm configuration. | |
16 | */ | |
17 | class RGWRealmReloader : public RGWRealmWatcher::Watcher { | |
18 | public: | |
19 | /** | |
20 | * Pauser is an interface to pause/resume frontends. Frontend cooperation | |
21 | * is required to ensure that they stop issuing requests on the old | |
22 | * RGWRados instance, and restart with the updated configuration. | |
23 | * | |
11fdf7f2 | 24 | * This abstraction avoids a dependency on class RGWFrontend. |
7c673cae FG |
25 | */ |
26 | class Pauser { | |
27 | public: | |
28 | virtual ~Pauser() = default; | |
29 | ||
30 | /// pause all frontends while realm reconfiguration is in progress | |
31 | virtual void pause() = 0; | |
32 | /// resume all frontends with the given RGWRados instance | |
1e59de90 | 33 | virtual void resume(rgw::sal::Driver* driver) = 0; |
7c673cae FG |
34 | }; |
35 | ||
1e59de90 TL |
36 | RGWRealmReloader(RGWProcessEnv& env, |
37 | const rgw::auth::ImplicitTenants& implicit_tenants, | |
38 | std::map<std::string, std::string>& service_map_meta, | |
224ce89b | 39 | Pauser* frontends); |
7c673cae FG |
40 | ~RGWRealmReloader() override; |
41 | ||
42 | /// respond to realm notifications by scheduling a reload() | |
11fdf7f2 | 43 | void handle_notify(RGWRealmNotify type, bufferlist::const_iterator& p) override; |
7c673cae FG |
44 | |
45 | private: | |
46 | /// pause frontends and replace the RGWRados instance | |
47 | void reload(); | |
48 | ||
49 | class C_Reload; //< Context that calls reload() | |
50 | ||
1e59de90 TL |
51 | RGWProcessEnv& env; |
52 | const rgw::auth::ImplicitTenants& implicit_tenants; | |
224ce89b | 53 | std::map<std::string, std::string>& service_map_meta; |
7c673cae FG |
54 | Pauser *const frontends; |
55 | ||
56 | /// reload() takes a significant amount of time, so we don't want to run | |
57 | /// it in the handle_notify() thread. we choose a timer thread instead of a | |
58 | /// Finisher because it allows us to cancel events that were scheduled while | |
59 | /// reload() is still running | |
60 | SafeTimer timer; | |
9f95a23c TL |
61 | ceph::mutex mutex; //< protects access to timer and reload_scheduled |
62 | ceph::condition_variable cond; //< to signal reload() after an invalid realm config | |
7c673cae FG |
63 | C_Reload* reload_scheduled; //< reload() context if scheduled |
64 | }; |