]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/MirroringWatcher.h
import ceph 15.2.10
[ceph.git] / ceph / src / librbd / MirroringWatcher.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 CEPH_LIBRBD_MIRRORING_WATCHER_H
5 #define CEPH_LIBRBD_MIRRORING_WATCHER_H
6
7 #include "include/int_types.h"
8 #include "include/rados/librados_fwd.hpp"
9 #include "cls/rbd/cls_rbd_types.h"
10 #include "librbd/ImageCtx.h"
11 #include "librbd/Watcher.h"
12 #include "librbd/mirroring_watcher/Types.h"
13
14 namespace librbd {
15
16 namespace watcher {
17 namespace util {
18 template <typename> struct HandlePayloadVisitor;
19 }
20 }
21
22 template <typename ImageCtxT = librbd::ImageCtx>
23 class MirroringWatcher : public Watcher {
24 friend struct watcher::util::HandlePayloadVisitor<MirroringWatcher<ImageCtxT>>;
25
26 public:
27 MirroringWatcher(librados::IoCtx &io_ctx, ContextWQ *work_queue);
28
29 static int notify_mode_updated(librados::IoCtx &io_ctx,
30 cls::rbd::MirrorMode mirror_mode);
31 static void notify_mode_updated(librados::IoCtx &io_ctx,
32 cls::rbd::MirrorMode mirror_mode,
33 Context *on_finish);
34
35 static int notify_image_updated(librados::IoCtx &io_ctx,
36 cls::rbd::MirrorImageState mirror_image_state,
37 const std::string &image_id,
38 const std::string &global_image_id);
39 static void notify_image_updated(librados::IoCtx &io_ctx,
40 cls::rbd::MirrorImageState mirror_image_state,
41 const std::string &image_id,
42 const std::string &global_image_id,
43 Context *on_finish);
44
45 virtual void handle_mode_updated(cls::rbd::MirrorMode mirror_mode) = 0;
46 virtual void handle_image_updated(cls::rbd::MirrorImageState state,
47 const std::string &image_id,
48 const std::string &global_image_id) = 0;
49
50 private:
51 bool handle_payload(const mirroring_watcher::ModeUpdatedPayload &payload,
52 Context *on_notify_ack);
53 bool handle_payload(const mirroring_watcher::ImageUpdatedPayload &payload,
54 Context *on_notify_ack);
55 bool handle_payload(const mirroring_watcher::UnknownPayload &payload,
56 Context *on_notify_ack);
57
58 void handle_notify(uint64_t notify_id, uint64_t handle,
59 uint64_t notifier_id, bufferlist &bl) override;
60 };
61
62 } // namespace librbd
63
64 extern template class librbd::MirroringWatcher<librbd::ImageCtx>;
65
66 #endif // CEPH_LIBRBD_MIRRORING_WATCHER_H