]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MWatchNotify.h
update sources to 12.2.7
[ceph.git] / ceph / src / messages / MWatchNotify.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15
16 #ifndef CEPH_MWATCHNOTIFY_H
17 #define CEPH_MWATCHNOTIFY_H
18
19 #include "msg/Message.h"
20
21
22 class MWatchNotify : public Message {
23 static const int HEAD_VERSION = 3;
24 static const int COMPAT_VERSION = 1;
25
26 public:
27 uint64_t cookie; ///< client unique id for this watch or notify
28 uint64_t ver; ///< unused
29 uint64_t notify_id; ///< osd unique id for a notify notification
30 uint8_t opcode; ///< CEPH_WATCH_EVENT_*
31 bufferlist bl; ///< notify payload (osd->client)
32 errorcode32_t return_code; ///< notify result (osd->client)
33 uint64_t notifier_gid; ///< who sent the notify
34
35 MWatchNotify()
36 : Message(CEPH_MSG_WATCH_NOTIFY, HEAD_VERSION, COMPAT_VERSION) { }
37 MWatchNotify(uint64_t c, uint64_t v, uint64_t i, uint8_t o, bufferlist b)
38 : Message(CEPH_MSG_WATCH_NOTIFY, HEAD_VERSION, COMPAT_VERSION),
39 cookie(c),
40 ver(v),
41 notify_id(i),
42 opcode(o),
43 bl(b),
44 return_code(0),
45 notifier_gid(0) { }
46 private:
47 ~MWatchNotify() override {}
48
49 public:
50 void decode_payload() override {
51 uint8_t msg_ver;
52 bufferlist::iterator p = payload.begin();
53 ::decode(msg_ver, p);
54 ::decode(opcode, p);
55 ::decode(cookie, p);
56 ::decode(ver, p);
57 ::decode(notify_id, p);
58 if (msg_ver >= 1)
59 ::decode(bl, p);
60 if (header.version >= 2)
61 ::decode(return_code, p);
62 else
63 return_code = 0;
64 if (header.version >= 3)
65 ::decode(notifier_gid, p);
66 else
67 notifier_gid = 0;
68 }
69 void encode_payload(uint64_t features) override {
70 uint8_t msg_ver = 1;
71 ::encode(msg_ver, payload);
72 ::encode(opcode, payload);
73 ::encode(cookie, payload);
74 ::encode(ver, payload);
75 ::encode(notify_id, payload);
76 ::encode(bl, payload);
77 ::encode(return_code, payload);
78 ::encode(notifier_gid, payload);
79 }
80
81 const char *get_type_name() const override { return "watch-notify"; }
82 void print(ostream& out) const override {
83 out << "watch-notify("
84 << ceph_watch_event_name(opcode) << " (" << (int)opcode << ")"
85 << " cookie " << cookie
86 << " notify " << notify_id
87 << " ret " << return_code
88 << ")";
89 }
90 };
91
92 #endif