]> git.proxmox.com Git - ceph.git/blob - ceph/src/tools/rbd_mirror/image_replayer/GetMirrorImageIdRequest.h
update sources to v12.1.3
[ceph.git] / ceph / src / tools / rbd_mirror / image_replayer / GetMirrorImageIdRequest.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 RBD_MIRROR_IMAGE_REPLAYER_GET_MIRROR_IMAGE_ID_REQUEST_H
5 #define RBD_MIRROR_IMAGE_REPLAYER_GET_MIRROR_IMAGE_ID_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
15 namespace rbd {
16 namespace mirror {
17 namespace image_replayer {
18
19 template <typename ImageCtxT = librbd::ImageCtx>
20 class GetMirrorImageIdRequest {
21 public:
22 static GetMirrorImageIdRequest *create(librados::IoCtx &io_ctx,
23 const std::string &global_image_id,
24 std::string *image_id,
25 Context *on_finish) {
26 return new GetMirrorImageIdRequest(io_ctx, global_image_id, image_id,
27 on_finish);
28 }
29
30 GetMirrorImageIdRequest(librados::IoCtx &io_ctx,
31 const std::string &global_image_id,
32 std::string *image_id,
33 Context *on_finish)
34 : m_io_ctx(io_ctx), m_global_image_id(global_image_id),
35 m_image_id(image_id), m_on_finish(on_finish) {
36 }
37
38 void send();
39
40 private:
41 /**
42 * @verbatim
43 *
44 * <start>
45 * |
46 * v
47 * GET_IMAGE_ID
48 * |
49 * v
50 * <finish>
51
52 * @endverbatim
53 */
54
55 librados::IoCtx &m_io_ctx;
56 std::string m_global_image_id;
57 std::string *m_image_id;
58 Context *m_on_finish;
59
60 bufferlist m_out_bl;
61
62 void get_image_id();
63 void handle_get_image_id(int r);
64
65 void finish(int r);
66
67 };
68
69 } // namespace image_replayer
70 } // namespace mirror
71 } // namespace rbd
72
73 extern template class rbd::mirror::image_replayer::GetMirrorImageIdRequest<librbd::ImageCtx>;
74
75 #endif // RBD_MIRROR_IMAGE_REPLAYER_GET_MIRROR_IMAGE_ID_REQUEST_H