]> git.proxmox.com Git - ceph.git/blame - ceph/src/messages/MTimeCheck2.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / messages / MTimeCheck2.h
CommitLineData
11fdf7f2
TL
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#pragma once
16
f67539c2 17class MTimeCheck2 final : public Message {
11fdf7f2 18public:
11fdf7f2
TL
19 static constexpr int HEAD_VERSION = 1;
20 static constexpr int COMPAT_VERSION = 1;
21
22 enum {
23 OP_PING = 1,
24 OP_PONG = 2,
25 OP_REPORT = 3,
26 };
27
28 int op = 0;
29 version_t epoch = 0;
30 version_t round = 0;
31
32 utime_t timestamp;
f67539c2
TL
33 std::map<int, double> skews;
34 std::map<int, double> latencies;
11fdf7f2 35
9f95a23c 36 MTimeCheck2() : Message{MSG_TIMECHECK2, HEAD_VERSION, COMPAT_VERSION} { }
11fdf7f2 37 MTimeCheck2(int op) :
9f95a23c 38 Message{MSG_TIMECHECK2, HEAD_VERSION, COMPAT_VERSION},
11fdf7f2
TL
39 op(op)
40 { }
41
42private:
f67539c2 43 ~MTimeCheck2() final { }
11fdf7f2
TL
44
45public:
46 std::string_view get_type_name() const override { return "time_check2"; }
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 }
f67539c2 55 void print(std::ostream &o) const override {
11fdf7f2
TL
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 {
f67539c2 68 using ceph::decode;
11fdf7f2
TL
69 auto p = payload.cbegin();
70 decode(op, p);
71 decode(epoch, p);
72 decode(round, p);
73 decode(timestamp, p);
74 decode(skews, p);
75 decode(latencies, p);
76 }
77
78 void encode_payload(uint64_t features) override {
79 using ceph::encode;
80 encode(op, payload);
81 encode(epoch, payload);
82 encode(round, payload);
83 encode(timestamp, payload);
84 encode(skews, payload, features);
85 encode(latencies, payload, features);
86 }
9f95a23c
TL
87private:
88 template<class T, typename... Args>
89 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
11fdf7f2 90};