]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab ft=cpp | |
11fdf7f2 | 3 | |
9f95a23c | 4 | #pragma once |
11fdf7f2 TL |
5 | |
6 | #include "rgw/rgw_service.h" | |
7 | ||
8 | #include "svc_rados.h" | |
9 | ||
10 | ||
9f95a23c TL |
11 | class Context; |
12 | ||
11fdf7f2 TL |
13 | class RGWSI_Zone; |
14 | class RGWSI_Finisher; | |
15 | ||
16 | class RGWWatcher; | |
17 | class RGWSI_Notify_ShutdownCB; | |
522d829b | 18 | struct RGWCacheNotifyInfo; |
11fdf7f2 TL |
19 | |
20 | class RGWSI_Notify : public RGWServiceInstance | |
21 | { | |
22 | friend class RGWWatcher; | |
23 | friend class RGWSI_Notify_ShutdownCB; | |
24 | friend class RGWServices_Def; | |
25 | ||
26 | public: | |
27 | class CB; | |
28 | ||
29 | private: | |
30 | RGWSI_Zone *zone_svc{nullptr}; | |
31 | RGWSI_RADOS *rados_svc{nullptr}; | |
32 | RGWSI_Finisher *finisher_svc{nullptr}; | |
33 | ||
9f95a23c | 34 | ceph::shared_mutex watchers_lock = ceph::make_shared_mutex("watchers_lock"); |
11fdf7f2 TL |
35 | rgw_pool control_pool; |
36 | ||
37 | int num_watchers{0}; | |
38 | RGWWatcher **watchers{nullptr}; | |
39 | std::set<int> watchers_set; | |
40 | vector<RGWSI_RADOS::Obj> notify_objs; | |
41 | ||
42 | bool enabled{false}; | |
43 | ||
44 | double inject_notify_timeout_probability{0}; | |
522d829b | 45 | static constexpr unsigned max_notify_retries = 10; |
11fdf7f2 TL |
46 | |
47 | string get_control_oid(int i); | |
48 | RGWSI_RADOS::Obj pick_control_obj(const string& key); | |
49 | ||
50 | CB *cb{nullptr}; | |
51 | ||
52 | std::optional<int> finisher_handle; | |
53 | RGWSI_Notify_ShutdownCB *shutdown_cb{nullptr}; | |
54 | ||
55 | bool finalized{false}; | |
56 | ||
b3b6e05e | 57 | int init_watch(const DoutPrefixProvider *dpp, optional_yield y); |
11fdf7f2 TL |
58 | void finalize_watch(); |
59 | ||
60 | void init(RGWSI_Zone *_zone_svc, | |
61 | RGWSI_RADOS *_rados_svc, | |
62 | RGWSI_Finisher *_finisher_svc) { | |
63 | zone_svc = _zone_svc; | |
64 | rados_svc = _rados_svc; | |
65 | finisher_svc = _finisher_svc; | |
66 | } | |
b3b6e05e | 67 | int do_start(optional_yield, const DoutPrefixProvider *dpp) override; |
11fdf7f2 TL |
68 | void shutdown() override; |
69 | ||
70 | int unwatch(RGWSI_RADOS::Obj& obj, uint64_t watch_handle); | |
71 | void add_watcher(int i); | |
72 | void remove_watcher(int i); | |
73 | ||
b3b6e05e TL |
74 | int watch_cb(const DoutPrefixProvider *dpp, |
75 | uint64_t notify_id, | |
11fdf7f2 TL |
76 | uint64_t cookie, |
77 | uint64_t notifier_id, | |
78 | bufferlist& bl); | |
79 | void _set_enabled(bool status); | |
80 | void set_enabled(bool status); | |
81 | ||
522d829b TL |
82 | int robust_notify(const DoutPrefixProvider *dpp, RGWSI_RADOS::Obj& notify_obj, |
83 | const RGWCacheNotifyInfo& bl, optional_yield y); | |
11fdf7f2 TL |
84 | |
85 | void schedule_context(Context *c); | |
86 | public: | |
87 | RGWSI_Notify(CephContext *cct): RGWServiceInstance(cct) {} | |
88 | ~RGWSI_Notify(); | |
89 | ||
90 | class CB { | |
91 | public: | |
92 | virtual ~CB() {} | |
b3b6e05e TL |
93 | virtual int watch_cb(const DoutPrefixProvider *dpp, |
94 | uint64_t notify_id, | |
11fdf7f2 TL |
95 | uint64_t cookie, |
96 | uint64_t notifier_id, | |
97 | bufferlist& bl) = 0; | |
98 | virtual void set_enabled(bool status) = 0; | |
99 | }; | |
100 | ||
522d829b TL |
101 | int distribute(const DoutPrefixProvider *dpp, const string& key, const RGWCacheNotifyInfo& bl, |
102 | optional_yield y); | |
11fdf7f2 TL |
103 | |
104 | void register_watch_cb(CB *cb); | |
105 | }; |