1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_RBD_MIRROR_IMAGE_REPLAYER_STATE_BUILDER_H
5 #define CEPH_RBD_MIRROR_IMAGE_REPLAYER_STATE_BUILDER_H
7 #include "include/rados/librados_fwd.hpp"
8 #include "cls/rbd/cls_rbd_types.h"
9 #include "librbd/mirror/Types.h"
12 namespace librbd
{ struct ImageCtx
; }
18 template <typename
> class InstanceWatcher
;
20 struct ProgressContext
;
21 template <typename
> class Threads
;
23 namespace image_sync
{ struct SyncPointHandler
; }
25 namespace image_replayer
{
28 struct ReplayerListener
;
30 template <typename ImageCtxT
>
33 StateBuilder(const StateBuilder
&) = delete;
34 StateBuilder
& operator=(const StateBuilder
&) = delete;
36 virtual ~StateBuilder();
38 virtual void destroy() {
42 virtual void close(Context
* on_finish
) = 0;
44 virtual bool is_disconnected() const = 0;
46 bool is_local_primary() const;
47 bool is_remote_primary() const;
48 bool is_linked() const;
50 virtual cls::rbd::MirrorImageMode
get_mirror_image_mode() const = 0;
52 virtual image_sync::SyncPointHandler
* create_sync_point_handler() = 0;
53 void destroy_sync_point_handler();
55 virtual bool replay_requires_remote_image() const = 0;
57 void close_remote_image(Context
* on_finish
);
59 virtual BaseRequest
* create_local_image_request(
60 Threads
<ImageCtxT
>* threads
,
61 librados::IoCtx
& local_io_ctx
,
62 const std::string
& global_image_id
,
63 PoolMetaCache
* pool_meta_cache
,
64 ProgressContext
* progress_ctx
,
65 Context
* on_finish
) = 0;
67 virtual BaseRequest
* create_prepare_replay_request(
68 const std::string
& local_mirror_uuid
,
69 ProgressContext
* progress_ctx
,
70 bool* resync_requested
,
72 Context
* on_finish
) = 0;
74 virtual Replayer
* create_replayer(
75 Threads
<ImageCtxT
>* threads
,
76 InstanceWatcher
<ImageCtxT
>* instance_watcher
,
77 const std::string
& local_mirror_uuid
,
78 PoolMetaCache
* pool_meta_cache
,
79 ReplayerListener
* replayer_listener
) = 0;
81 std::string global_image_id
;
83 std::string local_image_id
;
84 librbd::mirror::PromotionState local_promotion_state
=
85 librbd::mirror::PROMOTION_STATE_UNKNOWN
;
86 ImageCtxT
* local_image_ctx
= nullptr;
88 std::string remote_mirror_uuid
;
89 std::string remote_image_id
;
90 librbd::mirror::PromotionState remote_promotion_state
=
91 librbd::mirror::PROMOTION_STATE_UNKNOWN
;
92 ImageCtxT
* remote_image_ctx
= nullptr;
95 image_sync::SyncPointHandler
* m_sync_point_handler
= nullptr;
97 StateBuilder(const std::string
& global_image_id
);
99 void close_local_image(Context
* on_finish
);
102 virtual bool is_linked_impl() const = 0;
104 void handle_close_local_image(int r
, Context
* on_finish
);
105 void handle_close_remote_image(int r
, Context
* on_finish
);
108 } // namespace image_replayer
109 } // namespace mirror
112 extern template class rbd::mirror::image_replayer::StateBuilder
<librbd::ImageCtx
>;
114 #endif // CEPH_RBD_MIRROR_IMAGE_REPLAYER_STATE_BUILDER_H