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.
15 #ifndef CEPH_MOSDPING_H
16 #define CEPH_MOSDPING_H
18 #include "common/Clock.h"
20 #include "msg/Message.h"
21 #include "osd/osd_types.h"
24 class MOSDPing
: public Message
{
26 static const int HEAD_VERSION
= 2;
27 static const int COMPAT_VERSION
= 2;
38 const char *get_op_name(int op
) const {
40 case HEARTBEAT
: return "heartbeat";
41 case START_HEARTBEAT
: return "start_heartbeat";
42 case STOP_HEARTBEAT
: return "stop_heartbeat";
43 case YOU_DIED
: return "you_died";
44 case PING
: return "ping";
45 case PING_REPLY
: return "ping_reply";
46 default: return "???";
51 epoch_t map_epoch
, peer_as_of_epoch
;
53 osd_peer_stat_t peer_stat
;
56 MOSDPing(const uuid_d
& f
, epoch_t e
, __u8 o
, utime_t s
)
57 : Message(MSG_OSD_PING
, HEAD_VERSION
, COMPAT_VERSION
),
58 fsid(f
), map_epoch(e
), peer_as_of_epoch(0), op(o
), stamp(s
)
61 : Message(MSG_OSD_PING
, HEAD_VERSION
, COMPAT_VERSION
)
64 ~MOSDPing() override
{}
67 void decode_payload() override
{
68 bufferlist::iterator p
= payload
.begin();
70 ::decode(map_epoch
, p
);
71 ::decode(peer_as_of_epoch
, p
);
73 ::decode(peer_stat
, p
);
76 void encode_payload(uint64_t features
) override
{
77 ::encode(fsid
, payload
);
78 ::encode(map_epoch
, payload
);
79 ::encode(peer_as_of_epoch
, payload
);
80 ::encode(op
, payload
);
81 ::encode(peer_stat
, payload
);
82 ::encode(stamp
, payload
);
85 const char *get_type_name() const override
{ return "osd_ping"; }
86 void print(ostream
& out
) const override
{
87 out
<< "osd_ping(" << get_op_name(op
)
89 //<< " as_of " << peer_as_of_epoch