1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_LIBRBD_MIRRORING_WATCHER_H
5 #define CEPH_LIBRBD_MIRRORING_WATCHER_H
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"
21 template <typename
> struct HandlePayloadVisitor
;
25 template <typename ImageCtxT
= librbd::ImageCtx
>
26 class MirroringWatcher
: public Watcher
{
27 friend struct watcher::util::HandlePayloadVisitor
<MirroringWatcher
<ImageCtxT
>>;
30 MirroringWatcher(librados::IoCtx
&io_ctx
, ContextWQ
*work_queue
);
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
,
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
,
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;
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
);
61 void handle_notify(uint64_t notify_id
, uint64_t handle
,
62 uint64_t notifier_id
, bufferlist
&bl
) override
;
67 extern template class librbd::MirroringWatcher
<librbd::ImageCtx
>;
69 #endif // CEPH_LIBRBD_MIRRORING_WATCHER_H