]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_period_pusher.h
import ceph pacific 16.2.5
[ceph.git] / ceph / src / rgw / rgw_period_pusher.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
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 "common/async/yield_context.h"
12 #include "rgw_realm_reloader.h"
13
14 namespace rgw {
15 namespace sal {
16 class RGWRadosStore;
17 }
18 }
19
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:
32 explicit RGWPeriodPusher(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore* store, optional_yield y);
33 ~RGWPeriodPusher() override;
34
35 /// respond to realm notifications by pushing new periods to other zones
36 void handle_notify(RGWRealmNotify type, bufferlist::const_iterator& p) override;
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
43 void resume(rgw::sal::RGWRadosStore* store) override;
44
45 private:
46 void handle_notify(RGWZonesNeedPeriod&& period);
47
48 CephContext *const cct;
49 rgw::sal::RGWRadosStore* store;
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