]>
git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MMgrReport.h
52090b256b3594ac377bf55c3400e4780fec6966
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) 2016 John Spray <john.spray@redhat.com>
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_MMGRREPORT_H_
16 #define CEPH_MMGRREPORT_H_
18 #include "msg/Message.h"
20 #include "common/perf_counters.h"
26 std::string description
;
28 enum perfcounter_type_d type
;
30 void encode(bufferlist
&bl
) const
32 // TODO: decide whether to drop the per-type
33 // encoding here, we could rely on the MgrReport
34 // verisoning instead.
35 ENCODE_START(1, 1, bl
);
37 ::encode(description
, bl
);
39 static_assert(sizeof(type
) == 1, "perfcounter_type_d must be one byte");
40 ::encode((uint8_t)type
, bl
);
44 void decode(bufferlist::iterator
&p
)
48 ::decode(description
, p
);
50 ::decode((uint8_t&)type
, p
);
54 WRITE_CLASS_ENCODER(PerfCounterType
)
56 class MMgrReport
: public Message
58 static const int HEAD_VERSION
= 2;
59 static const int COMPAT_VERSION
= 1;
63 * Client is responsible for remembering whether it has introduced
64 * each perf counter to the server. When first sending a particular
65 * counter, it must inline the counter's schema here.
67 std::vector
<PerfCounterType
> declare_types
;
68 std::vector
<std::string
> undeclare_types
;
70 // For all counters present, sorted by idx, output
71 // as many bytes as are needed to represent them
73 // Decode: iterate over the types we know about, sorted by idx,
74 // and use the current type's type to decide how to decode
75 // the next bytes from the bufferlist.
78 std::string daemon_name
;
80 void decode_payload() override
82 bufferlist::iterator p
= payload
.begin();
83 ::decode(daemon_name
, p
);
84 ::decode(declare_types
, p
);
86 if (header
.version
>= 2)
87 ::decode(undeclare_types
, p
);
90 void encode_payload(uint64_t features
) override
{
91 ::encode(daemon_name
, payload
);
92 ::encode(declare_types
, payload
);
93 ::encode(packed
, payload
);
94 ::encode(undeclare_types
, payload
);
97 const char *get_type_name() const override
{ return "mgrreport"; }
98 void print(ostream
& out
) const override
{
99 out
<< get_type_name() << "(+" << declare_types
.size() << "-" << undeclare_types
.size()
100 << " packed " << packed
.length() << ")";
104 : Message(MSG_MGR_REPORT
, HEAD_VERSION
, COMPAT_VERSION
)