]> git.proxmox.com Git - ceph.git/blame - ceph/src/librbd/MirroringWatcher.h
update sources to ceph Nautilus 14.2.1
[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
16namespace watcher {
17namespace util {
18template <typename> struct HandlePayloadVisitor;
19}
20}
21
22template <typename ImageCtxT = librbd::ImageCtx>
23class MirroringWatcher : public Watcher {
24 friend struct watcher::util::HandlePayloadVisitor<MirroringWatcher<ImageCtxT>>;
25
26public:
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
50private:
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
64extern template class librbd::MirroringWatcher<librbd::ImageCtx>;
65
66#endif // CEPH_LIBRBD_MIRRORING_WATCHER_H