Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / librbd / image_watcher / NotifyLockOwner.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 CEPH_LIBRBD_IMAGE_WATCHER_NOTIFY_LOCK_OWNER_H
5 #define CEPH_LIBRBD_IMAGE_WATCHER_NOTIFY_LOCK_OWNER_H
6
7 #include "include/buffer.h"
8 #include "librbd/watcher/Types.h"
9
10 class Context;
11
12 namespace librbd {
13
14 struct ImageCtx;
15
16 namespace watcher { class Notifier; }
17
18 namespace image_watcher {
19
20 class NotifyLockOwner {
21 public:
22   static NotifyLockOwner *create(ImageCtx &image_ctx,
23                                  watcher::Notifier &notifier,
24                                  bufferlist &&bl, Context *on_finish) {
25     return new NotifyLockOwner(image_ctx, notifier, std::move(bl), on_finish);
26   }
27
28   NotifyLockOwner(ImageCtx &image_ctx, watcher::Notifier &notifier,
29                   bufferlist &&bl, Context *on_finish);
30
31   void send();
32
33 private:
34   ImageCtx &m_image_ctx;
35   watcher::Notifier &m_notifier;
36
37   bufferlist m_bl;
38   watcher::NotifyResponse m_notify_response;
39   Context *m_on_finish;
40
41   void send_notify();
42   void handle_notify(int r);
43
44   void finish(int r);
45 };
46
47 } // namespace image_watcher
48 } // namespace librbd
49
50 #endif // CEPH_LIBRBD_IMAGE_WATCHER_NOTIFY_LOCK_OWNER_H