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 "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"
18 template <typename
> struct HandlePayloadVisitor
;
22 template <typename ImageCtxT
= librbd::ImageCtx
>
23 class MirroringWatcher
: public Watcher
{
24 friend struct watcher::util::HandlePayloadVisitor
<MirroringWatcher
<ImageCtxT
>>;
27 MirroringWatcher(librados::IoCtx
&io_ctx
, ContextWQ
*work_queue
);
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
,
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
,
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;
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
);
58 void handle_notify(uint64_t notify_id
, uint64_t handle
,
59 uint64_t notifier_id
, bufferlist
&bl
) override
;
64 extern template class librbd::MirroringWatcher
<librbd::ImageCtx
>;
66 #endif // CEPH_LIBRBD_MIRRORING_WATCHER_H