]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: added factory methods for journal replay state machines
authorJason Dillaman <dillaman@redhat.com>
Wed, 8 Jan 2020 19:51:27 +0000 (14:51 -0500)
committerJason Dillaman <dillaman@redhat.com>
Thu, 9 Jan 2020 15:48:52 +0000 (10:48 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/tools/rbd_mirror/image_replayer/StateBuilder.h
src/tools/rbd_mirror/image_replayer/journal/StateBuilder.cc
src/tools/rbd_mirror/image_replayer/journal/StateBuilder.h

index b506fc24e75f6d0872a4bd490b03ed6958e75a77..22c5ee5c0a5b619148f323985181be4dd32bc8d0 100644 (file)
@@ -4,7 +4,9 @@
 #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; }
@@ -12,10 +14,17 @@ 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:
@@ -40,6 +49,27 @@ 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;
index edab1a3cabcb9d7a3f2243af350a07227060a806..a0f85f0a1167871efad1c58b70f3bc06f33f4d6b 100644 (file)
@@ -9,6 +9,9 @@
 #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
@@ -75,6 +78,55 @@ image_sync::SyncPointHandler* StateBuilder<I>::create_sync_point_handler() {
   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) {
index 5d9edba47ceba0a7441eb80274e13308e27fc12b..274c2acbcb8fae4a38193ae94e9aaf0b308afb35 100644 (file)
@@ -45,6 +45,27 @@ public:
 
   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;