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
{
23 static const int HEAD_VERSION
= 3;
24 static const int COMPAT_VERSION
= 1;
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
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
),
47 ~MWatchNotify() override
{}
50 void decode_payload() override
{
52 bufferlist::iterator p
= payload
.begin();
57 ::decode(notify_id
, p
);
60 if (header
.version
>= 2)
61 ::decode(return_code
, p
);
64 if (header
.version
>= 3)
65 ::decode(notifier_gid
, p
);
69 void encode_payload(uint64_t features
) override
{
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
);
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