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_linked() const;
49 virtual cls::rbd::MirrorImageMode
get_mirror_image_mode() const = 0;
51 virtual image_sync::SyncPointHandler
* create_sync_point_handler() = 0;
52 void destroy_sync_point_handler();
54 virtual bool replay_requires_remote_image() const = 0;
56 void close_remote_image(Context
* on_finish
);
58 virtual BaseRequest
* create_local_image_request(
59 Threads
<ImageCtxT
>* threads
,
60 librados::IoCtx
& local_io_ctx
,
61 const std::string
& global_image_id
,
62 PoolMetaCache
* pool_meta_cache
,
63 ProgressContext
* progress_ctx
,
64 Context
* on_finish
) = 0;
66 virtual BaseRequest
* create_prepare_replay_request(
67 const std::string
& local_mirror_uuid
,
68 ProgressContext
* progress_ctx
,
69 bool* resync_requested
,
71 Context
* on_finish
) = 0;
73 virtual Replayer
* create_replayer(
74 Threads
<ImageCtxT
>* threads
,
75 InstanceWatcher
<ImageCtxT
>* instance_watcher
,
76 const std::string
& local_mirror_uuid
,
77 PoolMetaCache
* pool_meta_cache
,
78 ReplayerListener
* replayer_listener
) = 0;
80 std::string global_image_id
;
82 std::string local_image_id
;
83 librbd::mirror::PromotionState local_promotion_state
=
84 librbd::mirror::PROMOTION_STATE_PRIMARY
;
85 ImageCtxT
* local_image_ctx
= nullptr;
87 std::string remote_mirror_uuid
;
88 std::string remote_image_id
;
89 librbd::mirror::PromotionState remote_promotion_state
=
90 librbd::mirror::PROMOTION_STATE_NON_PRIMARY
;
91 ImageCtxT
* remote_image_ctx
= nullptr;
94 image_sync::SyncPointHandler
* m_sync_point_handler
= nullptr;
96 StateBuilder(const std::string
& global_image_id
);
98 void close_local_image(Context
* on_finish
);
101 virtual bool is_linked_impl() const = 0;
103 void handle_close_local_image(int r
, Context
* on_finish
);
104 void handle_close_remote_image(int r
, Context
* on_finish
);
107 } // namespace image_replayer
108 } // namespace mirror
111 extern template class rbd::mirror::image_replayer::StateBuilder
<librbd::ImageCtx
>;
113 #endif // CEPH_RBD_MIRROR_IMAGE_REPLAYER_STATE_BUILDER_H