1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_LIBRBD_WATCHER_TYPES_H
5 #define CEPH_LIBRBD_WATCHER_TYPES_H
7 #include "include/int_types.h"
8 #include "include/buffer_fwd.h"
9 #include "include/encoding.h"
11 namespace ceph { class Formatter; }
23 ClientId() : gid(0), handle(0) {}
24 ClientId(uint64_t gid, uint64_t handle) : gid(gid), handle(handle) {}
26 void encode(bufferlist& bl) const;
27 void decode(bufferlist::iterator& it);
28 void dump(Formatter *f) const;
30 inline bool is_valid() const {
31 return (*this != ClientId());
34 inline bool operator==(const ClientId &rhs) const {
35 return (gid == rhs.gid && handle == rhs.handle);
37 inline bool operator!=(const ClientId &rhs) const {
38 return !(*this == rhs);
40 inline bool operator<(const ClientId &rhs) const {
44 return handle < rhs.handle;
49 struct NotifyResponse {
50 std::map<ClientId, bufferlist> acks;
51 std::vector<ClientId> timeouts;
53 void encode(bufferlist& bl) const;
54 void decode(bufferlist::iterator& it);
57 template <typename ImageCtxT>
59 typedef librbd::Watcher Watcher;
62 } // namespace watcher
65 std::ostream &operator<<(std::ostream &out,
66 const librbd::watcher::ClientId &client);
68 WRITE_CLASS_ENCODER(librbd::watcher::ClientId);
69 WRITE_CLASS_ENCODER(librbd::watcher::NotifyResponse);
71 #endif // CEPH_LIBRBD_WATCHER_TYPES_H