]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/image/ListWatchersRequest.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / librbd / image / ListWatchersRequest.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_IMAGE_LIST_WATCHERS_REQUEST_H
5 #define CEPH_LIBRBD_IMAGE_LIST_WATCHERS_REQUEST_H
6
7 #include "include/rados/rados_types.hpp"
8
9 #include <list>
10
11 class Context;
12
13 namespace librbd {
14
15 class ImageCtx;
16
17 namespace image {
18
19 enum {
20 LIST_WATCHERS_FILTER_OUT_MY_INSTANCE = 1 << 0,
21 LIST_WATCHERS_FILTER_OUT_MIRROR_INSTANCES = 1 << 1,
22 LIST_WATCHERS_MIRROR_INSTANCES_ONLY = 1 << 3,
23 };
24
25 template<typename ImageCtxT = ImageCtx>
26 class ListWatchersRequest {
27 public:
28 static ListWatchersRequest *create(ImageCtxT &image_ctx, int flags,
29 std::list<obj_watch_t> *watchers,
30 Context *on_finish) {
31 return new ListWatchersRequest(image_ctx, flags, watchers, on_finish);
32 }
33
34 void send();
35
36 private:
37 /**
38 * @verbatim
39 *
40 * <start>
41 * |
42 * v
43 * LIST_IMAGE_WATCHERS
44 * |
45 * v
46 * LIST_MIRROR_WATCHERS (skip if not needed)
47 * |
48 * v
49 * <finish>
50 *
51 * @endverbatim
52 */
53
54 ListWatchersRequest(ImageCtxT &image_ctx, int flags, std::list<obj_watch_t> *watchers,
55 Context *on_finish);
56
57 ImageCtxT& m_image_ctx;
58 int m_flags;
59 std::list<obj_watch_t> *m_watchers;
60 Context *m_on_finish;
61
62 CephContext *m_cct;
63 int m_ret_val;
64 bufferlist m_out_bl;
65 std::list<obj_watch_t> m_object_watchers;
66 std::list<obj_watch_t> m_mirror_watchers;
67
68 void list_image_watchers();
69 void handle_list_image_watchers(int r);
70
71 void list_mirror_watchers();
72 void handle_list_mirror_watchers(int r);
73
74 void finish(int r);
75 };
76
77 } // namespace image
78 } // namespace librbd
79
80 extern template class librbd::image::ListWatchersRequest<librbd::ImageCtx>;
81
82 #endif // CEPH_LIBRBD_IMAGE_LIST_WATCHERS_REQUEST_H