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