1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
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.
16 #ifndef CEPH_MWATCHNOTIFY_H
17 #define CEPH_MWATCHNOTIFY_H
19 #include "msg/Message.h"
22 class MWatchNotify
: public Message
{
24 static constexpr int HEAD_VERSION
= 3;
25 static constexpr int COMPAT_VERSION
= 1;
28 uint64_t cookie
; ///< client unique id for this watch or notify
29 uint64_t ver
; ///< unused
30 uint64_t notify_id
; ///< osd unique id for a notify notification
31 uint8_t opcode
; ///< CEPH_WATCH_EVENT_*
32 ceph::buffer::list bl
; ///< notify payload (osd->client)
33 errorcode32_t return_code
; ///< notify result (osd->client)
34 uint64_t notifier_gid
; ///< who sent the notify
37 : Message
{CEPH_MSG_WATCH_NOTIFY
, HEAD_VERSION
, COMPAT_VERSION
} { }
38 MWatchNotify(uint64_t c
, uint64_t v
, uint64_t i
, uint8_t o
, ceph::buffer::list b
, uint64_t n
=0)
39 : Message
{CEPH_MSG_WATCH_NOTIFY
, HEAD_VERSION
, COMPAT_VERSION
},
48 ~MWatchNotify() override
{}
51 void decode_payload() override
{
54 auto p
= payload
.cbegin();
62 if (header
.version
>= 2)
63 decode(return_code
, p
);
66 if (header
.version
>= 3)
67 decode(notifier_gid
, p
);
71 void encode_payload(uint64_t features
) override
{
74 encode(msg_ver
, payload
);
75 encode(opcode
, payload
);
76 encode(cookie
, payload
);
78 encode(notify_id
, payload
);
80 encode(return_code
, payload
);
81 encode(notifier_gid
, payload
);
84 std::string_view
get_type_name() const override
{ return "watch-notify"; }
85 void print(std::ostream
& out
) const override
{
86 out
<< "watch-notify("
87 << ceph_watch_event_name(opcode
) << " (" << (int)opcode
<< ")"
88 << " cookie " << cookie
89 << " notify " << notify_id
90 << " ret " << return_code
94 template<class T
, typename
... Args
>
95 friend boost::intrusive_ptr
<T
> ceph::make_message(Args
&&... args
);