X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Flibrbd%2Fwatcher%2FTypes.h;fp=src%2Fceph%2Fsrc%2Flibrbd%2Fwatcher%2FTypes.h;h=e7886f6cad5e77869939528ec7b4a49c8e91cbd6;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/librbd/watcher/Types.h b/src/ceph/src/librbd/watcher/Types.h new file mode 100644 index 0000000..e7886f6 --- /dev/null +++ b/src/ceph/src/librbd/watcher/Types.h @@ -0,0 +1,71 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef CEPH_LIBRBD_WATCHER_TYPES_H +#define CEPH_LIBRBD_WATCHER_TYPES_H + +#include "include/int_types.h" +#include "include/buffer_fwd.h" +#include "include/encoding.h" + +namespace ceph { class Formatter; } + +namespace librbd { + +class Watcher; + +namespace watcher { + +struct ClientId { + uint64_t gid; + uint64_t handle; + + ClientId() : gid(0), handle(0) {} + ClientId(uint64_t gid, uint64_t handle) : gid(gid), handle(handle) {} + + void encode(bufferlist& bl) const; + void decode(bufferlist::iterator& it); + void dump(Formatter *f) const; + + inline bool is_valid() const { + return (*this != ClientId()); + } + + inline bool operator==(const ClientId &rhs) const { + return (gid == rhs.gid && handle == rhs.handle); + } + inline bool operator!=(const ClientId &rhs) const { + return !(*this == rhs); + } + inline bool operator<(const ClientId &rhs) const { + if (gid != rhs.gid) { + return gid < rhs.gid; + } else { + return handle < rhs.handle; + } + } +}; + +struct NotifyResponse { + std::map acks; + std::vector timeouts; + + void encode(bufferlist& bl) const; + void decode(bufferlist::iterator& it); +}; + +template +struct Traits { + typedef librbd::Watcher Watcher; +}; + +} // namespace watcher +} // namespace librbd + +std::ostream &operator<<(std::ostream &out, + const librbd::watcher::ClientId &client); + +WRITE_CLASS_ENCODER(librbd::watcher::ClientId); +WRITE_CLASS_ENCODER(librbd::watcher::NotifyResponse); + +#endif // CEPH_LIBRBD_WATCHER_TYPES_H