]>
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 FG |
3 | |
4 | #ifndef RGW_PERIOD_PUSHER_H | |
5 | #define RGW_PERIOD_PUSHER_H | |
6 | ||
7 | #include <memory> | |
8 | #include <mutex> | |
9 | #include <vector> | |
10 | ||
11 | #include "rgw_realm_reloader.h" | |
12 | ||
9f95a23c TL |
13 | namespace rgw { |
14 | namespace sal { | |
15 | class RGWRadosStore; | |
16 | } | |
17 | } | |
18 | ||
7c673cae FG |
19 | class RGWPeriod; |
20 | ||
21 | // RGWRealmNotify payload for push coordination | |
22 | using RGWZonesNeedPeriod = RGWPeriod; | |
23 | ||
24 | /** | |
25 | * RGWPeriodPusher coordinates with other nodes via the realm watcher to manage | |
26 | * the responsibility for pushing period updates to other zones or zonegroups. | |
27 | */ | |
28 | class RGWPeriodPusher final : public RGWRealmWatcher::Watcher, | |
29 | public RGWRealmReloader::Pauser { | |
30 | public: | |
9f95a23c | 31 | explicit RGWPeriodPusher(rgw::sal::RGWRadosStore* store); |
7c673cae FG |
32 | ~RGWPeriodPusher() override; |
33 | ||
34 | /// respond to realm notifications by pushing new periods to other zones | |
11fdf7f2 | 35 | void handle_notify(RGWRealmNotify type, bufferlist::const_iterator& p) override; |
7c673cae FG |
36 | |
37 | /// avoid accessing RGWRados while dynamic reconfiguration is in progress. | |
38 | /// notifications will be enqueued until resume() | |
39 | void pause() override; | |
40 | ||
41 | /// continue processing notifications with a new RGWRados instance | |
9f95a23c | 42 | void resume(rgw::sal::RGWRadosStore* store) override; |
7c673cae FG |
43 | |
44 | private: | |
45 | void handle_notify(RGWZonesNeedPeriod&& period); | |
46 | ||
47 | CephContext *const cct; | |
9f95a23c | 48 | rgw::sal::RGWRadosStore* store; |
7c673cae FG |
49 | |
50 | std::mutex mutex; | |
51 | epoch_t realm_epoch{0}; //< the current realm epoch being sent | |
52 | epoch_t period_epoch{0}; //< the current period epoch being sent | |
53 | ||
54 | /// while paused for reconfiguration, we need to queue up notifications | |
55 | std::vector<RGWZonesNeedPeriod> pending_periods; | |
56 | ||
57 | class CRThread; //< contains thread, coroutine manager, http manager | |
58 | std::unique_ptr<CRThread> cr_thread; //< thread to run the push coroutines | |
59 | }; | |
60 | ||
61 | #endif // RGW_PERIOD_PUSHER_H |