]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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_WATCHER_REWATCH_REQUEST_H | |
5 | #define CEPH_LIBRBD_WATCHER_REWATCH_REQUEST_H | |
6 | ||
9f95a23c | 7 | #include "common/ceph_mutex.h" |
7c673cae FG |
8 | #include "include/int_types.h" |
9 | #include "include/rados/librados.hpp" | |
10 | ||
11 | struct Context; | |
7c673cae FG |
12 | |
13 | namespace librbd { | |
14 | ||
15 | namespace watcher { | |
16 | ||
17 | class RewatchRequest { | |
18 | public: | |
19 | ||
20 | static RewatchRequest *create(librados::IoCtx& ioctx, const std::string& oid, | |
9f95a23c | 21 | ceph::shared_mutex &watch_lock, |
7c673cae FG |
22 | librados::WatchCtx2 *watch_ctx, |
23 | uint64_t *watch_handle, Context *on_finish) { | |
24 | return new RewatchRequest(ioctx, oid, watch_lock, watch_ctx, watch_handle, | |
25 | on_finish); | |
26 | } | |
27 | ||
28 | RewatchRequest(librados::IoCtx& ioctx, const std::string& oid, | |
9f95a23c | 29 | ceph::shared_mutex &watch_lock, librados::WatchCtx2 *watch_ctx, |
7c673cae FG |
30 | uint64_t *watch_handle, Context *on_finish); |
31 | ||
32 | void send(); | |
33 | ||
34 | private: | |
35 | /** | |
36 | * @verbatim | |
37 | * | |
38 | * <start> | |
39 | * | | |
40 | * v | |
41 | * UNWATCH | |
42 | * | | |
43 | * | . . . . | |
44 | * | . . (recoverable error) | |
45 | * v v . | |
46 | * REWATCH . . . | |
47 | * | | |
48 | * v | |
49 | * <finish> | |
50 | * | |
51 | * @endverbatim | |
52 | */ | |
53 | ||
54 | librados::IoCtx& m_ioctx; | |
55 | std::string m_oid; | |
9f95a23c | 56 | ceph::shared_mutex &m_watch_lock; |
7c673cae FG |
57 | librados::WatchCtx2 *m_watch_ctx; |
58 | uint64_t *m_watch_handle; | |
59 | Context *m_on_finish; | |
60 | ||
61 | uint64_t m_rewatch_handle = 0; | |
62 | ||
63 | void unwatch(); | |
64 | void handle_unwatch(int r); | |
65 | ||
66 | void rewatch(); | |
67 | void handle_rewatch(int r); | |
68 | ||
69 | void finish(int r); | |
70 | }; | |
71 | ||
72 | } // namespace watcher | |
73 | } // namespace librbd | |
74 | ||
75 | #endif // CEPH_LIBRBD_WATCHER_REWATCH_REQUEST_H |