]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | #ifndef CEPH_MOSDPING_H | |
16 | #define CEPH_MOSDPING_H | |
17 | ||
18 | #include "common/Clock.h" | |
19 | ||
20 | #include "msg/Message.h" | |
21 | #include "osd/osd_types.h" | |
22 | ||
23 | ||
24 | class MOSDPing : public Message { | |
25 | ||
26 | static const int HEAD_VERSION = 2; | |
27 | static const int COMPAT_VERSION = 2; | |
28 | ||
29 | public: | |
30 | enum { | |
31 | HEARTBEAT = 0, | |
32 | START_HEARTBEAT = 1, | |
33 | YOU_DIED = 2, | |
34 | STOP_HEARTBEAT = 3, | |
35 | PING = 4, | |
36 | PING_REPLY = 5, | |
37 | }; | |
38 | const char *get_op_name(int op) const { | |
39 | switch (op) { | |
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 "???"; | |
47 | } | |
48 | } | |
49 | ||
50 | uuid_d fsid; | |
51 | epoch_t map_epoch, peer_as_of_epoch; | |
52 | __u8 op; | |
53 | osd_peer_stat_t peer_stat; | |
54 | utime_t stamp; | |
55 | ||
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) | |
59 | { } | |
60 | MOSDPing() | |
61 | : Message(MSG_OSD_PING, HEAD_VERSION, COMPAT_VERSION) | |
62 | {} | |
63 | private: | |
64 | ~MOSDPing() override {} | |
65 | ||
66 | public: | |
67 | void decode_payload() override { | |
68 | bufferlist::iterator p = payload.begin(); | |
69 | ::decode(fsid, p); | |
70 | ::decode(map_epoch, p); | |
71 | ::decode(peer_as_of_epoch, p); | |
72 | ::decode(op, p); | |
73 | ::decode(peer_stat, p); | |
74 | ::decode(stamp, p); | |
75 | } | |
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); | |
83 | } | |
84 | ||
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) | |
88 | << " e" << map_epoch | |
89 | //<< " as_of " << peer_as_of_epoch | |
90 | << " stamp " << stamp | |
91 | << ")"; | |
92 | } | |
93 | }; | |
94 | ||
95 | #endif |