]> git.proxmox.com Git - ceph.git/blame - ceph/src/tools/rbd_mirror/image_replayer/PrepareLocalImageRequest.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / tools / rbd_mirror / image_replayer / PrepareLocalImageRequest.h
CommitLineData
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"
11fdf7f2 8#include "include/rados/librados_fwd.hpp"
9f95a23c
TL
9#include "cls/rbd/cls_rbd_types.h"
10#include "librbd/mirror/Types.h"
7c673cae
FG
11#include <string>
12
7c673cae
FG
13namespace librbd { struct ImageCtx; }
14
15struct Context;
16struct ContextWQ;
17
18namespace rbd {
19namespace mirror {
20namespace image_replayer {
21
9f95a23c
TL
22template <typename> class StateBuilder;
23
7c673cae
FG
24template <typename ImageCtxT = librbd::ImageCtx>
25class PrepareLocalImageRequest {
26public:
9f95a23c
TL
27 static PrepareLocalImageRequest *create(
28 librados::IoCtx &io_ctx,
29 const std::string &global_image_id,
30 std::string *local_image_name,
31 StateBuilder<ImageCtxT>** state_builder,
32 ContextWQ *work_queue,
33 Context *on_finish) {
34 return new PrepareLocalImageRequest(io_ctx, global_image_id,
35 local_image_name, state_builder,
36 work_queue, on_finish);
7c673cae
FG
37 }
38
9f95a23c
TL
39 PrepareLocalImageRequest(
40 librados::IoCtx &io_ctx,
41 const std::string &global_image_id,
42 std::string *local_image_name,
43 StateBuilder<ImageCtxT>** state_builder,
44 ContextWQ *work_queue,
45 Context *on_finish)
7c673cae 46 : m_io_ctx(io_ctx), m_global_image_id(global_image_id),
9f95a23c
TL
47 m_local_image_name(local_image_name), m_state_builder(state_builder),
48 m_work_queue(work_queue), m_on_finish(on_finish) {
7c673cae
FG
49 }
50
51 void send();
52
53private:
54 /**
55 * @verbatim
56 *
57 * <start>
58 * |
59 * v
60 * GET_LOCAL_IMAGE_ID
61 * |
62 * v
28e407b8
AA
63 * GET_LOCAL_IMAGE_NAME
64 * |
65 * v
9f95a23c 66 * GET_MIRROR_INFO
7c673cae
FG
67 * |
68 * v
69 * <finish>
9f95a23c 70 *
7c673cae
FG
71 * @endverbatim
72 */
73
74 librados::IoCtx &m_io_ctx;
75 std::string m_global_image_id;
28e407b8 76 std::string *m_local_image_name;
9f95a23c 77 StateBuilder<ImageCtxT>** m_state_builder;
7c673cae
FG
78 ContextWQ *m_work_queue;
79 Context *m_on_finish;
80
81 bufferlist m_out_bl;
9f95a23c
TL
82 std::string m_local_image_id;
83 cls::rbd::MirrorImage m_mirror_image;
84 librbd::mirror::PromotionState m_promotion_state;
85 std::string m_primary_mirror_uuid;
7c673cae
FG
86
87 void get_local_image_id();
88 void handle_get_local_image_id(int r);
89
28e407b8
AA
90 void get_local_image_name();
91 void handle_get_local_image_name(int r);
92
9f95a23c
TL
93 void get_mirror_info();
94 void handle_get_mirror_info(int r);
7c673cae
FG
95
96 void finish(int r);
97
98};
99
100} // namespace image_replayer
101} // namespace mirror
102} // namespace rbd
103
104extern template class rbd::mirror::image_replayer::PrepareLocalImageRequest<librbd::ImageCtx>;
105
106#endif // RBD_MIRROR_IMAGE_REPLAYER_PREPARE_LOCAL_IMAGE_REQUEST_H