]>
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_TYPES_H | |
5 | #define CEPH_LIBRBD_WATCHER_TYPES_H | |
6 | ||
7 | #include "include/int_types.h" | |
8 | #include "include/buffer_fwd.h" | |
9 | #include "include/encoding.h" | |
10 | ||
11 | namespace ceph { class Formatter; } | |
12 | ||
13 | namespace librbd { | |
14 | ||
15 | class Watcher; | |
16 | ||
17 | namespace watcher { | |
18 | ||
19 | struct ClientId { | |
20 | uint64_t gid; | |
21 | uint64_t handle; | |
22 | ||
23 | ClientId() : gid(0), handle(0) {} | |
24 | ClientId(uint64_t gid, uint64_t handle) : gid(gid), handle(handle) {} | |
25 | ||
26 | void encode(bufferlist& bl) const; | |
11fdf7f2 | 27 | void decode(bufferlist::const_iterator& it); |
7c673cae FG |
28 | void dump(Formatter *f) const; |
29 | ||
30 | inline bool is_valid() const { | |
31 | return (*this != ClientId()); | |
32 | } | |
33 | ||
34 | inline bool operator==(const ClientId &rhs) const { | |
35 | return (gid == rhs.gid && handle == rhs.handle); | |
36 | } | |
37 | inline bool operator!=(const ClientId &rhs) const { | |
38 | return !(*this == rhs); | |
39 | } | |
40 | inline bool operator<(const ClientId &rhs) const { | |
41 | if (gid != rhs.gid) { | |
42 | return gid < rhs.gid; | |
43 | } else { | |
44 | return handle < rhs.handle; | |
45 | } | |
46 | } | |
47 | }; | |
48 | ||
49 | struct NotifyResponse { | |
50 | std::map<ClientId, bufferlist> acks; | |
51 | std::vector<ClientId> timeouts; | |
52 | ||
53 | void encode(bufferlist& bl) const; | |
11fdf7f2 | 54 | void decode(bufferlist::const_iterator& it); |
7c673cae FG |
55 | }; |
56 | ||
57 | template <typename ImageCtxT> | |
58 | struct Traits { | |
59 | typedef librbd::Watcher Watcher; | |
60 | }; | |
61 | ||
7c673cae | 62 | std::ostream &operator<<(std::ostream &out, |
11fdf7f2 | 63 | const ClientId &client); |
7c673cae | 64 | |
11fdf7f2 TL |
65 | WRITE_CLASS_ENCODER(ClientId); |
66 | WRITE_CLASS_ENCODER(NotifyResponse); | |
67 | ||
68 | } // namespace watcher | |
69 | } // namespace librbd | |
7c673cae FG |
70 | |
71 | #endif // CEPH_LIBRBD_WATCHER_TYPES_H |