--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_RBD_MIRROR_BASE_REQUEST_H
+#define CEPH_RBD_MIRROR_BASE_REQUEST_H
+
+#include "include/Context.h"
+
+namespace rbd {
+namespace mirror {
+
+class BaseRequest {
+public:
+ BaseRequest(Context *on_finish) : m_on_finish(on_finish) {
+ }
+ virtual ~BaseRequest() {}
+
+ virtual void send() = 0;
+
+protected:
+ virtual void finish(int r) {
+ m_on_finish->complete(r);
+ delete this;
+ }
+
+private:
+ Context *m_on_finish;
+};
+
+} // namespace mirror
+} // namespace rbd
+
+#endif // CEPH_RBD_MIRROR_BASE_REQUEST_H
create_local_image();
}
-template <typename I>
-void CreateLocalImageRequest<I>::finish(int r) {
- dout(10) << "r=" << r << dendl;
-
- m_on_finish->complete(r);
- delete this;
-}
-
template <typename I>
void CreateLocalImageRequest<I>::update_progress(
const std::string& description) {
#include "include/rados/librados_fwd.hpp"
#include "librbd/journal/Types.h"
#include "librbd/journal/TypeTraits.h"
+#include "tools/rbd_mirror/BaseRequest.h"
#include <string>
struct Context;
namespace journal {
template <typename ImageCtxT>
-class CreateLocalImageRequest {
+class CreateLocalImageRequest : public BaseRequest {
public:
typedef librbd::journal::MirrorPeerClientMeta MirrorPeerClientMeta;
typedef librbd::journal::TypeTraits<ImageCtxT> TypeTraits;
const std::string& remote_mirror_uuid,
MirrorPeerClientMeta* client_meta, ProgressContext* progress_ctx,
std::string* local_image_id, Context* on_finish)
- : m_threads(threads), m_local_io_ctx(local_io_ctx),
+ : BaseRequest(on_finish),
+ m_threads(threads), m_local_io_ctx(local_io_ctx),
m_remote_image_ctx(remote_image_ctx),
m_remote_journaler(remote_journaler),
m_global_image_id(global_image_id),
m_remote_mirror_uuid(remote_mirror_uuid), m_client_meta(client_meta),
- m_progress_ctx(progress_ctx), m_local_image_id(local_image_id),
- m_on_finish(on_finish) {
+ m_progress_ctx(progress_ctx), m_local_image_id(local_image_id) {
}
void send();
MirrorPeerClientMeta* m_client_meta;
ProgressContext* m_progress_ctx;
std::string* m_local_image_id;
- Context* m_on_finish;
void unregister_client();
void handle_unregister_client(int r);
void update_client_image();
void handle_update_client_image(int r);
- void finish(int r);
-
void update_progress(const std::string& description);
};
finish(0);
}
-template <typename I>
-void PrepareReplayRequest<I>::finish(int r) {
- dout(10) << "r=" << r << dendl;
-
- m_on_finish->complete(r);
- delete this;
-}
-
template <typename I>
void PrepareReplayRequest<I>::update_progress(const std::string &description) {
dout(10) << description << dendl;
#include "librbd/journal/Types.h"
#include "librbd/journal/TypeTraits.h"
#include "librbd/mirror/Types.h"
+#include "tools/rbd_mirror/BaseRequest.h"
#include <list>
#include <string>
namespace journal {
template <typename ImageCtxT>
-class PrepareReplayRequest {
+class PrepareReplayRequest : public BaseRequest {
public:
typedef librbd::journal::TypeTraits<ImageCtxT> TypeTraits;
typedef typename TypeTraits::Journaler Journaler;
const std::string& remote_mirror_uuid,
MirrorPeerClientMeta* client_meta, ProgressContext* progress_ctx,
bool* resync_requested, bool* syncing, Context* on_finish)
- : m_local_image_ctx(local_image_ctx), m_remote_journaler(remote_journaler),
+ : BaseRequest(on_finish),
+ m_local_image_ctx(local_image_ctx), m_remote_journaler(remote_journaler),
m_remote_promotion_state(remote_promotion_state),
m_local_mirror_uuid(local_mirror_uuid),
m_remote_mirror_uuid(remote_mirror_uuid), m_client_meta(client_meta),
m_progress_ctx(progress_ctx), m_resync_requested(resync_requested),
- m_syncing(syncing), m_on_finish(on_finish) {
+ m_syncing(syncing) {
}
- void send();
+ void send() override;
private:
/**
ProgressContext* m_progress_ctx;
bool* m_resync_requested;
bool* m_syncing;
- Context* m_on_finish;
uint64_t m_local_tag_tid = 0;
librbd::journal::TagData m_local_tag_data;
void get_remote_tags();
void handle_get_remote_tags(int r);
- void finish(int r);
void update_progress(const std::string& description);
};