]>
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 RBD_MIRROR_IMAGE_REPLAYER_PREPARE_LOCAL_IMAGE_REQUEST_H | |
5 | #define RBD_MIRROR_IMAGE_REPLAYER_PREPARE_LOCAL_IMAGE_REQUEST_H | |
6 | ||
7 | #include "include/buffer.h" | |
8 | #include <string> | |
9 | ||
10 | namespace librados { struct IoCtx; } | |
11 | namespace librbd { struct ImageCtx; } | |
12 | ||
13 | struct Context; | |
14 | struct ContextWQ; | |
15 | ||
16 | namespace rbd { | |
17 | namespace mirror { | |
18 | namespace image_replayer { | |
19 | ||
20 | template <typename ImageCtxT = librbd::ImageCtx> | |
21 | class PrepareLocalImageRequest { | |
22 | public: | |
23 | static PrepareLocalImageRequest *create(librados::IoCtx &io_ctx, | |
24 | const std::string &global_image_id, | |
25 | std::string *local_image_id, | |
28e407b8 | 26 | std::string *local_image_name, |
7c673cae FG |
27 | std::string *tag_owner, |
28 | ContextWQ *work_queue, | |
29 | Context *on_finish) { | |
30 | return new PrepareLocalImageRequest(io_ctx, global_image_id, local_image_id, | |
28e407b8 AA |
31 | local_image_name, tag_owner, work_queue, |
32 | on_finish); | |
7c673cae FG |
33 | } |
34 | ||
35 | PrepareLocalImageRequest(librados::IoCtx &io_ctx, | |
36 | const std::string &global_image_id, | |
37 | std::string *local_image_id, | |
28e407b8 | 38 | std::string *local_image_name, |
7c673cae FG |
39 | std::string *tag_owner, |
40 | ContextWQ *work_queue, | |
41 | Context *on_finish) | |
42 | : m_io_ctx(io_ctx), m_global_image_id(global_image_id), | |
28e407b8 AA |
43 | m_local_image_id(local_image_id), m_local_image_name(local_image_name), |
44 | m_tag_owner(tag_owner), m_work_queue(work_queue), m_on_finish(on_finish) { | |
7c673cae FG |
45 | } |
46 | ||
47 | void send(); | |
48 | ||
49 | private: | |
50 | /** | |
51 | * @verbatim | |
52 | * | |
53 | * <start> | |
54 | * | | |
55 | * v | |
56 | * GET_LOCAL_IMAGE_ID | |
57 | * | | |
58 | * v | |
28e407b8 AA |
59 | * GET_LOCAL_IMAGE_NAME |
60 | * | | |
61 | * v | |
7c673cae FG |
62 | * GET_MIRROR_STATE |
63 | * | | |
64 | * v | |
65 | * <finish> | |
66 | ||
67 | * @endverbatim | |
68 | */ | |
69 | ||
70 | librados::IoCtx &m_io_ctx; | |
71 | std::string m_global_image_id; | |
72 | std::string *m_local_image_id; | |
28e407b8 | 73 | std::string *m_local_image_name; |
7c673cae FG |
74 | std::string *m_tag_owner; |
75 | ContextWQ *m_work_queue; | |
76 | Context *m_on_finish; | |
77 | ||
78 | bufferlist m_out_bl; | |
79 | ||
80 | void get_local_image_id(); | |
81 | void handle_get_local_image_id(int r); | |
82 | ||
28e407b8 AA |
83 | void get_local_image_name(); |
84 | void handle_get_local_image_name(int r); | |
85 | ||
7c673cae FG |
86 | void get_mirror_state(); |
87 | void handle_get_mirror_state(int r); | |
88 | ||
89 | void get_tag_owner(); | |
90 | void handle_get_tag_owner(int r); | |
91 | ||
92 | void finish(int r); | |
93 | ||
94 | }; | |
95 | ||
96 | } // namespace image_replayer | |
97 | } // namespace mirror | |
98 | } // namespace rbd | |
99 | ||
100 | extern template class rbd::mirror::image_replayer::PrepareLocalImageRequest<librbd::ImageCtx>; | |
101 | ||
102 | #endif // RBD_MIRROR_IMAGE_REPLAYER_PREPARE_LOCAL_IMAGE_REQUEST_H |