]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #ifndef CEPH_LIBRBD_MIRRORING_WATCHER_H | |
5 | #define CEPH_LIBRBD_MIRRORING_WATCHER_H | |
6 | ||
7 | #include "include/int_types.h" | |
8 | #include "cls/rbd/cls_rbd_types.h" | |
9 | #include "librbd/ImageCtx.h" | |
10 | #include "librbd/Watcher.h" | |
11 | #include "librbd/mirroring_watcher/Types.h" | |
12 | ||
13 | namespace librados { | |
14 | class IoCtx; | |
15 | } | |
16 | ||
17 | namespace librbd { | |
18 | ||
19 | namespace watcher { | |
20 | namespace util { | |
21 | template <typename> struct HandlePayloadVisitor; | |
22 | } | |
23 | } | |
24 | ||
25 | template <typename ImageCtxT = librbd::ImageCtx> | |
26 | class MirroringWatcher : public Watcher { | |
27 | friend struct watcher::util::HandlePayloadVisitor<MirroringWatcher<ImageCtxT>>; | |
28 | ||
29 | public: | |
30 | MirroringWatcher(librados::IoCtx &io_ctx, ContextWQ *work_queue); | |
31 | ||
32 | static int notify_mode_updated(librados::IoCtx &io_ctx, | |
33 | cls::rbd::MirrorMode mirror_mode); | |
34 | static void notify_mode_updated(librados::IoCtx &io_ctx, | |
35 | cls::rbd::MirrorMode mirror_mode, | |
36 | Context *on_finish); | |
37 | ||
38 | static int notify_image_updated(librados::IoCtx &io_ctx, | |
39 | cls::rbd::MirrorImageState mirror_image_state, | |
40 | const std::string &image_id, | |
41 | const std::string &global_image_id); | |
42 | static void notify_image_updated(librados::IoCtx &io_ctx, | |
43 | cls::rbd::MirrorImageState mirror_image_state, | |
44 | const std::string &image_id, | |
45 | const std::string &global_image_id, | |
46 | Context *on_finish); | |
47 | ||
48 | virtual void handle_mode_updated(cls::rbd::MirrorMode mirror_mode) = 0; | |
49 | virtual void handle_image_updated(cls::rbd::MirrorImageState state, | |
50 | const std::string &image_id, | |
51 | const std::string &global_image_id) = 0; | |
52 | ||
53 | private: | |
54 | bool handle_payload(const mirroring_watcher::ModeUpdatedPayload &payload, | |
55 | Context *on_notify_ack); | |
56 | bool handle_payload(const mirroring_watcher::ImageUpdatedPayload &payload, | |
57 | Context *on_notify_ack); | |
58 | bool handle_payload(const mirroring_watcher::UnknownPayload &payload, | |
59 | Context *on_notify_ack); | |
60 | ||
61 | void handle_notify(uint64_t notify_id, uint64_t handle, | |
62 | uint64_t notifier_id, bufferlist &bl) override; | |
63 | }; | |
64 | ||
65 | } // namespace librbd | |
66 | ||
67 | extern template class librbd::MirroringWatcher<librbd::ImageCtx>; | |
68 | ||
69 | #endif // CEPH_LIBRBD_MIRRORING_WATCHER_H |