]>
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_PROMOTE_REQUEST_H | |
5 | #define CEPH_LIBRBD_MIRROR_PROMOTE_REQUEST_H | |
6 | ||
7 | #include "cls/rbd/cls_rbd_types.h" | |
8 | #include "librbd/mirror/Types.h" | |
9 | ||
10 | struct Context; | |
11 | ||
12 | namespace librbd { | |
13 | ||
14 | struct ImageCtx; | |
15 | ||
16 | namespace mirror { | |
17 | ||
18 | template <typename ImageCtxT = librbd::ImageCtx> | |
19 | class PromoteRequest { | |
20 | public: | |
21 | static PromoteRequest *create(ImageCtxT &image_ctx, bool force, | |
22 | Context *on_finish) { | |
23 | return new PromoteRequest(image_ctx, force, on_finish); | |
24 | } | |
25 | ||
26 | PromoteRequest(ImageCtxT &image_ctx, bool force, Context *on_finish) | |
27 | : m_image_ctx(image_ctx), m_force(force), m_on_finish(on_finish) { | |
28 | } | |
29 | ||
30 | void send(); | |
31 | ||
32 | private: | |
33 | /** | |
34 | * @verbatim | |
35 | * | |
36 | * <start> | |
37 | * | | |
38 | * v | |
39 | * GET_INFO | |
40 | * | | |
41 | * v | |
42 | * GET_TAG_OWNER | |
43 | * | | |
44 | * v | |
45 | * PROMOTE | |
46 | * | | |
47 | * v | |
48 | * <finish> | |
49 | * | |
50 | * @endverbatim | |
51 | */ | |
52 | ||
53 | ImageCtxT &m_image_ctx; | |
54 | bool m_force; | |
55 | Context *m_on_finish; | |
56 | ||
57 | cls::rbd::MirrorImage m_mirror_image; | |
11fdf7f2 | 58 | PromotionState m_promotion_state = PROMOTION_STATE_PRIMARY; |
9f95a23c | 59 | std::string m_primary_mirror_uuid; |
7c673cae FG |
60 | |
61 | void get_info(); | |
62 | void handle_get_info(int r); | |
63 | ||
64 | void promote(); | |
65 | void handle_promote(int r); | |
66 | ||
67 | void finish(int r); | |
68 | ||
69 | }; | |
70 | ||
71 | } // namespace mirror | |
72 | } // namespace librbd | |
73 | ||
74 | extern template class librbd::mirror::PromoteRequest<librbd::ImageCtx>; | |
75 | ||
76 | #endif // CEPH_LIBRBD_MIRROR_PROMOTE_REQUEST_H |