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