]>
Commit | Line | Data |
---|---|---|
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_MIRROR_ENABLE_REQUEST_H | |
5 | #define CEPH_LIBRBD_MIRROR_ENABLE_REQUEST_H | |
6 | ||
7 | #include "include/buffer.h" | |
8 | #include "cls/rbd/cls_rbd_types.h" | |
9 | #include <map> | |
10 | #include <string> | |
11 | ||
12 | class Context; | |
13 | class ContextWQ; | |
14 | ||
15 | namespace librados { class IoCtx; } | |
16 | ||
17 | namespace librbd { | |
18 | ||
19 | class ImageCtx; | |
20 | ||
21 | namespace mirror { | |
22 | ||
23 | template <typename ImageCtxT = ImageCtx> | |
24 | class EnableRequest { | |
25 | public: | |
26 | static EnableRequest *create(ImageCtxT *image_ctx, Context *on_finish) { | |
27 | return create(image_ctx->md_ctx, image_ctx->id, "", | |
28 | image_ctx->op_work_queue, on_finish); | |
29 | } | |
30 | static EnableRequest *create(librados::IoCtx &io_ctx, | |
31 | const std::string &image_id, | |
32 | const std::string &non_primary_global_image_id, | |
33 | ContextWQ *op_work_queue, Context *on_finish) { | |
34 | return new EnableRequest(io_ctx, image_id, non_primary_global_image_id, | |
35 | op_work_queue, on_finish); | |
36 | } | |
37 | ||
38 | void send(); | |
39 | ||
40 | private: | |
41 | /** | |
42 | * @verbatim | |
43 | * | |
44 | * <start> | |
45 | * | | |
46 | * v | |
47 | * GET_MIRROR_MODE * * * * * * * | |
48 | * | * | |
49 | * v * | |
50 | * GET_TAG_OWNER * * * * * * * * | |
51 | * | * | |
52 | * v * | |
53 | * GET_MIRROR_IMAGE * * * * * * * | |
54 | * | * (on error) | |
55 | * v * | |
56 | * SET_MIRROR_IMAGE * * * * * * * | |
57 | * | * | |
58 | * v * | |
59 | * NOTIFY_MIRRORING_WATCHER * * * | |
60 | * | * | |
61 | * v * | |
62 | * <finish> < * * * * * * * * * | |
63 | * | |
64 | * @endverbatim | |
65 | */ | |
66 | ||
67 | EnableRequest(librados::IoCtx &io_ctx, const std::string &image_id, | |
68 | const std::string &non_primary_global_image_id, | |
69 | ContextWQ *op_work_queue, Context *on_finish); | |
70 | ||
71 | librados::IoCtx &m_io_ctx; | |
72 | std::string m_image_id; | |
73 | std::string m_non_primary_global_image_id; | |
74 | ContextWQ *m_op_work_queue; | |
75 | Context *m_on_finish; | |
76 | ||
77 | CephContext *m_cct = nullptr; | |
78 | bool m_is_primary = false; | |
79 | bufferlist m_out_bl; | |
80 | cls::rbd::MirrorImage m_mirror_image; | |
81 | ||
82 | void send_get_tag_owner(); | |
83 | Context *handle_get_tag_owner(int *result); | |
84 | ||
85 | void send_get_mirror_image(); | |
86 | Context *handle_get_mirror_image(int *result); | |
87 | ||
88 | void send_set_mirror_image(); | |
89 | Context *handle_set_mirror_image(int *result); | |
90 | ||
91 | void send_notify_mirroring_watcher(); | |
92 | Context *handle_notify_mirroring_watcher(int *result); | |
93 | }; | |
94 | ||
95 | } // namespace mirror | |
96 | } // namespace librbd | |
97 | ||
98 | extern template class librbd::mirror::EnableRequest<librbd::ImageCtx>; | |
99 | ||
100 | #endif // CEPH_LIBRBD_MIRROR_ENABLE_REQUEST_H |