#ifndef CEPH_RBD_MIRROR_IMAGE_REPLAYER_STATE_BUILDER_H
#define CEPH_RBD_MIRROR_IMAGE_REPLAYER_STATE_BUILDER_H
+#include "include/rados/librados_fwd.hpp"
#include "cls/rbd/cls_rbd_types.h"
+#include "librbd/mirror/Types.h"
struct Context;
namespace librbd { struct ImageCtx; }
namespace rbd {
namespace mirror {
+struct BaseRequest;
+struct ProgressContext;
+template <typename> class Threads;
+
namespace image_sync { struct SyncPointHandler; }
namespace image_replayer {
+struct Replayer;
+struct ReplayerListener;
+
template <typename ImageCtxT>
class StateBuilder {
public:
virtual image_sync::SyncPointHandler* create_sync_point_handler() = 0;
void destroy_sync_point_handler();
+ virtual BaseRequest* create_local_image_request(
+ Threads<ImageCtxT>* threads,
+ librados::IoCtx& local_io_ctx,
+ ImageCtxT* remote_image_ctx,
+ const std::string& global_image_id,
+ ProgressContext* progress_ctx,
+ Context* on_finish) = 0;
+
+ virtual BaseRequest* create_prepare_replay_request(
+ const std::string& local_mirror_uuid,
+ librbd::mirror::PromotionState remote_promotion_state,
+ ProgressContext* progress_ctx,
+ bool* resync_requested,
+ bool* syncing,
+ Context* on_finish) = 0;
+
+ virtual Replayer* create_replayer(
+ Threads<ImageCtxT>* threads,
+ const std::string& local_mirror_uuid,
+ ReplayerListener* replayer_listener) = 0;
+
std::string global_image_id;
std::string local_image_id;
#include "journal/Journaler.h"
#include "librbd/ImageCtx.h"
#include "librbd/Journal.h"
+#include "tools/rbd_mirror/image_replayer/journal/CreateLocalImageRequest.h"
+#include "tools/rbd_mirror/image_replayer/journal/PrepareReplayRequest.h"
+#include "tools/rbd_mirror/image_replayer/journal/Replayer.h"
#include "tools/rbd_mirror/image_replayer/journal/SyncPointHandler.h"
#define dout_context g_ceph_context
return this->m_sync_point_handler;
}
+template <typename I>
+BaseRequest* StateBuilder<I>::create_local_image_request(
+ Threads<I>* threads,
+ librados::IoCtx& local_io_ctx,
+ I* remote_image_ctx,
+ const std::string& global_image_id,
+ ProgressContext* progress_ctx,
+ Context* on_finish) {
+ return CreateLocalImageRequest<I>::create(
+ threads, local_io_ctx, remote_image_ctx, remote_journaler,
+ this->global_image_id, this->remote_mirror_uuid, &remote_client_meta,
+ progress_ctx, &this->local_image_id, on_finish);
+}
+
+template <typename I>
+BaseRequest* StateBuilder<I>::create_prepare_replay_request(
+ const std::string& local_mirror_uuid,
+ librbd::mirror::PromotionState remote_promotion_state,
+ ProgressContext* progress_ctx,
+ bool* resync_requested,
+ bool* syncing,
+ Context* on_finish) {
+ return PrepareReplayRequest<I>::create(
+ this->local_image_ctx,
+ remote_journaler,
+ remote_promotion_state,
+ local_mirror_uuid,
+ this->remote_mirror_uuid,
+ &remote_client_meta,
+ progress_ctx,
+ resync_requested,
+ syncing,
+ on_finish);
+}
+
+template <typename I>
+image_replayer::Replayer* StateBuilder<I>::create_replayer(
+ Threads<I>* threads,
+ const std::string& local_mirror_uuid,
+ ReplayerListener* replayer_listener) {
+ return Replayer<I>::create(
+ &this->local_image_ctx,
+ remote_journaler,
+ local_mirror_uuid,
+ this->remote_mirror_uuid,
+ replayer_listener,
+ threads);
+}
+
template <typename I>
void StateBuilder<I>::shut_down_remote_journaler(Context* on_finish) {
if (remote_journaler == nullptr) {
image_sync::SyncPointHandler* create_sync_point_handler() override;
+ BaseRequest* create_local_image_request(
+ Threads<ImageCtxT>* threads,
+ librados::IoCtx& local_io_ctx,
+ ImageCtxT* remote_image_ctx,
+ const std::string& global_image_id,
+ ProgressContext* progress_ctx,
+ Context* on_finish) override;
+
+ BaseRequest* create_prepare_replay_request(
+ const std::string& local_mirror_uuid,
+ librbd::mirror::PromotionState remote_promotion_state,
+ ProgressContext* progress_ctx,
+ bool* resync_requested,
+ bool* syncing,
+ Context* on_finish) override;
+
+ Replayer* create_replayer(
+ Threads<ImageCtxT>* threads,
+ const std::string& local_mirror_uuid,
+ ReplayerListener* replayer_listener) override;
+
std::string local_tag_owner;
Journaler* remote_journaler = nullptr;