1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef RBD_MIRROR_IMAGE_REPLAYER_PREPARE_REMOTE_IMAGE_REQUEST_H
5 #define RBD_MIRROR_IMAGE_REPLAYER_PREPARE_REMOTE_IMAGE_REQUEST_H
7 #include "include/buffer.h"
8 #include "cls/journal/cls_journal_types.h"
9 #include "librbd/journal/TypeTraits.h"
12 namespace journal
{ class Journaler
; }
13 namespace librados
{ struct IoCtx
; }
14 namespace librbd
{ struct ImageCtx
; }
15 namespace librbd
{ namespace journal
{ struct MirrorPeerClientMeta
; } }
23 template <typename
> struct Threads
;
25 namespace image_replayer
{
27 template <typename ImageCtxT
= librbd::ImageCtx
>
28 class PrepareRemoteImageRequest
{
30 typedef librbd::journal::TypeTraits
<ImageCtxT
> TypeTraits
;
31 typedef typename
TypeTraits::Journaler Journaler
;
32 typedef librbd::journal::MirrorPeerClientMeta MirrorPeerClientMeta
;
34 static PrepareRemoteImageRequest
*create(Threads
<ImageCtxT
> *threads
,
35 librados::IoCtx
&remote_io_ctx
,
36 const std::string
&global_image_id
,
37 const std::string
&local_mirror_uuid
,
38 const std::string
&local_image_id
,
39 std::string
*remote_mirror_uuid
,
40 std::string
*remote_image_id
,
41 Journaler
**remote_journaler
,
42 cls::journal::ClientState
*client_state
,
43 MirrorPeerClientMeta
*client_meta
,
45 return new PrepareRemoteImageRequest(threads
, remote_io_ctx
,
46 global_image_id
, local_mirror_uuid
,
47 local_image_id
, remote_mirror_uuid
,
48 remote_image_id
, remote_journaler
,
49 client_state
, client_meta
, on_finish
);
52 PrepareRemoteImageRequest(Threads
<ImageCtxT
> *threads
,
53 librados::IoCtx
&remote_io_ctx
,
54 const std::string
&global_image_id
,
55 const std::string
&local_mirror_uuid
,
56 const std::string
&local_image_id
,
57 std::string
*remote_mirror_uuid
,
58 std::string
*remote_image_id
,
59 Journaler
**remote_journaler
,
60 cls::journal::ClientState
*client_state
,
61 MirrorPeerClientMeta
*client_meta
,
63 : m_threads(threads
), m_remote_io_ctx(remote_io_ctx
),
64 m_global_image_id(global_image_id
),
65 m_local_mirror_uuid(local_mirror_uuid
), m_local_image_id(local_image_id
),
66 m_remote_mirror_uuid(remote_mirror_uuid
),
67 m_remote_image_id(remote_image_id
),
68 m_remote_journaler(remote_journaler
), m_client_state(client_state
),
69 m_client_meta(client_meta
), m_on_finish(on_finish
) {
81 * GET_REMOTE_MIRROR_UUID
89 * v (skip if not needed)
98 Threads
<ImageCtxT
> *m_threads
;
99 librados::IoCtx
&m_remote_io_ctx
;
100 std::string m_global_image_id
;
101 std::string m_local_mirror_uuid
;
102 std::string m_local_image_id
;
103 std::string
*m_remote_mirror_uuid
;
104 std::string
*m_remote_image_id
;
105 Journaler
**m_remote_journaler
;
106 cls::journal::ClientState
*m_client_state
;
107 MirrorPeerClientMeta
*m_client_meta
;
108 Context
*m_on_finish
;
111 cls::journal::Client m_client
;
113 void get_remote_mirror_uuid();
114 void handle_get_remote_mirror_uuid(int r
);
116 void get_remote_image_id();
117 void handle_get_remote_image_id(int r
);
120 void handle_get_client(int r
);
122 void register_client();
123 void handle_register_client(int r
);
127 bool decode_client_meta();
130 } // namespace image_replayer
131 } // namespace mirror
134 extern template class rbd::mirror::image_replayer::PrepareRemoteImageRequest
<librbd::ImageCtx
>;
136 #endif // RBD_MIRROR_IMAGE_REPLAYER_PREPARE_REMOTE_IMAGE_REQUEST_H