]>
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) 2012 Inktank, Inc. | |
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_MTIMECHECK_H | |
16 | #define CEPH_MTIMECHECK_H | |
17 | ||
18 | struct MTimeCheck : public Message | |
19 | { | |
20 | static const int HEAD_VERSION = 1; | |
21 | ||
22 | enum { | |
23 | OP_PING = 1, | |
24 | OP_PONG = 2, | |
25 | OP_REPORT = 3, | |
26 | }; | |
27 | ||
d2e6a577 FG |
28 | int op = 0; |
29 | version_t epoch = 0; | |
30 | version_t round = 0; | |
7c673cae FG |
31 | |
32 | utime_t timestamp; | |
33 | map<entity_inst_t, double> skews; | |
34 | map<entity_inst_t, double> latencies; | |
35 | ||
36 | MTimeCheck() : Message(MSG_TIMECHECK, HEAD_VERSION) { } | |
37 | MTimeCheck(int op) : | |
38 | Message(MSG_TIMECHECK, HEAD_VERSION), | |
39 | op(op) | |
40 | { } | |
41 | ||
42 | private: | |
43 | ~MTimeCheck() override { } | |
44 | ||
45 | public: | |
46 | const char *get_type_name() const override { return "time_check"; } | |
47 | const char *get_op_name() const { | |
48 | switch (op) { | |
49 | case OP_PING: return "ping"; | |
50 | case OP_PONG: return "pong"; | |
51 | case OP_REPORT: return "report"; | |
52 | } | |
53 | return "???"; | |
54 | } | |
55 | void print(ostream &o) const override { | |
56 | o << "time_check( " << get_op_name() | |
57 | << " e " << epoch << " r " << round; | |
58 | if (op == OP_PONG) { | |
59 | o << " ts " << timestamp; | |
60 | } else if (op == OP_REPORT) { | |
61 | o << " #skews " << skews.size() | |
62 | << " #latencies " << latencies.size(); | |
63 | } | |
64 | o << " )"; | |
65 | } | |
66 | ||
67 | void decode_payload() override { | |
68 | bufferlist::iterator p = payload.begin(); | |
69 | ::decode(op, p); | |
70 | ::decode(epoch, p); | |
71 | ::decode(round, p); | |
72 | ::decode(timestamp, p); | |
73 | ::decode(skews, p); | |
74 | ::decode(latencies, p); | |
75 | } | |
76 | ||
77 | void encode_payload(uint64_t features) override { | |
78 | ::encode(op, payload); | |
79 | ::encode(epoch, payload); | |
80 | ::encode(round, payload); | |
81 | ::encode(timestamp, payload); | |
82 | ::encode(skews, payload, features); | |
83 | ::encode(latencies, payload, features); | |
84 | } | |
85 | }; | |
86 | ||
87 | #endif /* CEPH_MTIMECHECK_H */ |