]> git.proxmox.com Git - ceph.git/blame - ceph/src/tools/rbd_mirror/image_replayer/journal/PrepareReplayRequest.h
import ceph quincy 17.2.4
[ceph.git] / ceph / src / tools / rbd_mirror / image_replayer / journal / PrepareReplayRequest.h
CommitLineData
9f95a23c
TL
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_JOURNAL_PREPARE_REPLAY_REQUEST_H
5#define RBD_MIRROR_IMAGE_REPLAYER_JOURNAL_PREPARE_REPLAY_REQUEST_H
6
7#include "include/int_types.h"
8#include "cls/journal/cls_journal_types.h"
9#include "librbd/journal/Types.h"
10#include "librbd/mirror/Types.h"
11#include "tools/rbd_mirror/BaseRequest.h"
12#include <list>
13#include <string>
14
15struct Context;
16namespace librbd { struct ImageCtx; }
17
18namespace rbd {
19namespace mirror {
20
21class ProgressContext;
22
23namespace image_replayer {
24namespace journal {
25
26template <typename> class StateBuilder;
27
28template <typename ImageCtxT>
29class PrepareReplayRequest : public BaseRequest {
30public:
31 static PrepareReplayRequest* create(
32 const std::string& local_mirror_uuid,
9f95a23c
TL
33 ProgressContext* progress_ctx,
34 StateBuilder<ImageCtxT>* state_builder,
35 bool* resync_requested,
36 bool* syncing,
37 Context* on_finish) {
38 return new PrepareReplayRequest(
2a845540
TL
39 local_mirror_uuid, progress_ctx, state_builder, resync_requested,
40 syncing, on_finish);
9f95a23c
TL
41 }
42
43 PrepareReplayRequest(
44 const std::string& local_mirror_uuid,
9f95a23c
TL
45 ProgressContext* progress_ctx,
46 StateBuilder<ImageCtxT>* state_builder,
47 bool* resync_requested,
48 bool* syncing,
49 Context* on_finish)
50 : BaseRequest(on_finish),
51 m_local_mirror_uuid(local_mirror_uuid),
9f95a23c
TL
52 m_progress_ctx(progress_ctx),
53 m_state_builder(state_builder),
54 m_resync_requested(resync_requested),
55 m_syncing(syncing) {
56 }
57
58 void send() override;
59
60private:
61 /**
62 * @verbatim
63 *
64 * <start>
65 * |
66 * v
67 * UPDATE_CLIENT_STATE
68 * |
69 * v
70 * GET_REMOTE_TAG_CLASS
71 * |
72 * v
73 * GET_REMOTE_TAGS
74 * |
75 * v
76 * <finish>
77 *
78 * @endverbatim
79 */
80 typedef std::list<cls::journal::Tag> Tags;
81
82 std::string m_local_mirror_uuid;
9f95a23c
TL
83 ProgressContext* m_progress_ctx;
84 StateBuilder<ImageCtxT>* m_state_builder;
85 bool* m_resync_requested;
86 bool* m_syncing;
87
88 uint64_t m_local_tag_tid = 0;
89 librbd::journal::TagData m_local_tag_data;
90
91 uint64_t m_remote_tag_class = 0;
92 Tags m_remote_tags;
93 cls::journal::Client m_client;
94
95 void update_client_state();
96 void handle_update_client_state(int r);
97
98 void get_remote_tag_class();
99 void handle_get_remote_tag_class(int r);
100
101 void get_remote_tags();
102 void handle_get_remote_tags(int r);
103
104 void update_progress(const std::string& description);
105
106};
107
108} // namespace journal
109} // namespace image_replayer
110} // namespace mirror
111} // namespace rbd
112
113extern template class rbd::mirror::image_replayer::journal::PrepareReplayRequest<librbd::ImageCtx>;
114
115#endif // RBD_MIRROR_IMAGE_REPLAYER_JOURNAL_PREPARE_REPLAY_REQUEST_H