]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/tools/rbd_mirror/image_replayer/PrepareLocalImageRequest.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / tools / rbd_mirror / image_replayer / PrepareLocalImageRequest.h
index 3417dd960a10e37b9876eedf8300c2f6b054c505..05473c204aed4493e1c84379722d555b8bff0802 100644 (file)
@@ -6,6 +6,8 @@
 
 #include "include/buffer.h"
 #include "include/rados/librados_fwd.hpp"
+#include "cls/rbd/cls_rbd_types.h"
+#include "librbd/mirror/Types.h"
 #include <string>
 
 namespace librbd { struct ImageCtx; }
@@ -17,31 +19,33 @@ namespace rbd {
 namespace mirror {
 namespace image_replayer {
 
+template <typename> class StateBuilder;
+
 template <typename ImageCtxT = librbd::ImageCtx>
 class PrepareLocalImageRequest {
 public:
-  static PrepareLocalImageRequest *create(librados::IoCtx &io_ctx,
-                                          const std::string &global_image_id,
-                                          std::string *local_image_id,
-                                          std::string *local_image_name,
-                                          std::string *tag_owner,
-                                          ContextWQ *work_queue,
-                                          Context *on_finish) {
-    return new PrepareLocalImageRequest(io_ctx, global_image_id, local_image_id,
-                                        local_image_name, tag_owner, work_queue,
-                                        on_finish);
+  static PrepareLocalImageRequest *create(
+      librados::IoCtx &io_ctx,
+      const std::string &global_image_id,
+      std::string *local_image_name,
+      StateBuilder<ImageCtxT>** state_builder,
+      ContextWQ *work_queue,
+      Context *on_finish) {
+    return new PrepareLocalImageRequest(io_ctx, global_image_id,
+                                        local_image_name, state_builder,
+                                        work_queue, on_finish);
   }
 
-  PrepareLocalImageRequest(librados::IoCtx &io_ctx,
-                           const std::string &global_image_id,
-                           std::string *local_image_id,
-                           std::string *local_image_name,
-                           std::string *tag_owner,
-                           ContextWQ *work_queue,
-                           Context *on_finish)
+  PrepareLocalImageRequest(
+      librados::IoCtx &io_ctx,
+      const std::string &global_image_id,
+      std::string *local_image_name,
+      StateBuilder<ImageCtxT>** state_builder,
+      ContextWQ *work_queue,
+      Context *on_finish)
     : m_io_ctx(io_ctx), m_global_image_id(global_image_id),
-      m_local_image_id(local_image_id), m_local_image_name(local_image_name),
-      m_tag_owner(tag_owner), m_work_queue(work_queue), m_on_finish(on_finish) {
+      m_local_image_name(local_image_name), m_state_builder(state_builder),
+      m_work_queue(work_queue), m_on_finish(on_finish) {
   }
 
   void send();
@@ -59,23 +63,26 @@ private:
    * GET_LOCAL_IMAGE_NAME
    *    |
    *    v
-   * GET_MIRROR_STATE
+   * GET_MIRROR_INFO
    *    |
    *    v
    * <finish>
-
+   *
    * @endverbatim
    */
 
   librados::IoCtx &m_io_ctx;
   std::string m_global_image_id;
-  std::string *m_local_image_id;
   std::string *m_local_image_name;
-  std::string *m_tag_owner;
+  StateBuilder<ImageCtxT>** m_state_builder;
   ContextWQ *m_work_queue;
   Context *m_on_finish;
 
   bufferlist m_out_bl;
+  std::string m_local_image_id;
+  cls::rbd::MirrorImage m_mirror_image;
+  librbd::mirror::PromotionState m_promotion_state;
+  std::string m_primary_mirror_uuid;
 
   void get_local_image_id();
   void handle_get_local_image_id(int r);
@@ -83,11 +90,8 @@ private:
   void get_local_image_name();
   void handle_get_local_image_name(int r);
 
-  void get_mirror_state();
-  void handle_get_mirror_state(int r);
-
-  void get_tag_owner();
-  void handle_get_tag_owner(int r);
+  void get_mirror_info();
+  void handle_get_mirror_info(int r);
 
   void finish(int r);