]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_period_pusher.h
add subtree-ish sources for 12.0.3
[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
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
13 class RGWRados;
14 class RGWPeriod;
15
16 // RGWRealmNotify payload for push coordination
17 using RGWZonesNeedPeriod = RGWPeriod;
18
19 /**
20 * RGWPeriodPusher coordinates with other nodes via the realm watcher to manage
21 * the responsibility for pushing period updates to other zones or zonegroups.
22 */
23 class RGWPeriodPusher final : public RGWRealmWatcher::Watcher,
24 public RGWRealmReloader::Pauser {
25 public:
26 RGWPeriodPusher(RGWRados* store);
27 ~RGWPeriodPusher() override;
28
29 /// respond to realm notifications by pushing new periods to other zones
30 void handle_notify(RGWRealmNotify type, bufferlist::iterator& p) override;
31
32 /// avoid accessing RGWRados while dynamic reconfiguration is in progress.
33 /// notifications will be enqueued until resume()
34 void pause() override;
35
36 /// continue processing notifications with a new RGWRados instance
37 void resume(RGWRados* store) override;
38
39 private:
40 void handle_notify(RGWZonesNeedPeriod&& period);
41
42 CephContext *const cct;
43 RGWRados* store;
44
45 std::mutex mutex;
46 epoch_t realm_epoch{0}; //< the current realm epoch being sent
47 epoch_t period_epoch{0}; //< the current period epoch being sent
48
49 /// while paused for reconfiguration, we need to queue up notifications
50 std::vector<RGWZonesNeedPeriod> pending_periods;
51
52 class CRThread; //< contains thread, coroutine manager, http manager
53 std::unique_ptr<CRThread> cr_thread; //< thread to run the push coroutines
54 };
55
56 #endif // RGW_PERIOD_PUSHER_H