Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / tools / rbd_mirror / image_replayer / IsPrimaryRequest.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef RBD_MIRROR_IMAGE_REPLAYER_IS_PRIMARY_REQUEST_H
5 #define RBD_MIRROR_IMAGE_REPLAYER_IS_PRIMARY_REQUEST_H
6
7 #include "include/buffer.h"
8
9 class Context;
10 class ContextWQ;
11 namespace librbd { class ImageCtx; }
12
13 namespace rbd {
14 namespace mirror {
15 namespace image_replayer {
16
17 template <typename ImageCtxT = librbd::ImageCtx>
18 class IsPrimaryRequest {
19 public:
20   static IsPrimaryRequest* create(ImageCtxT *image_ctx, bool *primary,
21                                   Context *on_finish) {
22     return new IsPrimaryRequest(image_ctx, primary, on_finish);
23   }
24
25   IsPrimaryRequest(ImageCtxT *image_ctx, bool *primary, Context *on_finish);
26
27   void send();
28
29 private:
30   /**
31    * @verbatim
32    *
33    * <start>
34    *    |
35    *    v
36    * GET_MIRROR_STATE * * * * *
37    *    |                     *
38    *    v                     *
39    * IS_TAG_OWNER * * * * * * * (error)
40    *    |                     *
41    *    v                     *
42    * <finish> < * * * * * * * *
43    *
44    * @endverbatim
45    */
46   ImageCtxT *m_image_ctx;
47   bool *m_primary;
48   Context *m_on_finish;
49
50   bufferlist m_out_bl;
51
52   void send_get_mirror_state();
53   void handle_get_mirror_state(int r);
54
55   void send_is_tag_owner();
56   void handle_is_tag_owner(int r);
57
58   void finish(int r);
59 };
60
61 } // namespace image_replayer
62 } // namespace mirror
63 } // namespace rbd
64
65 extern template class rbd::mirror::image_replayer::IsPrimaryRequest<librbd::ImageCtx>;
66
67 #endif // RBD_MIRROR_IMAGE_REPLAYER_IS_PRIMARY_REQUEST_H