]>
git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MMgrReport.h
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 <boost/optional.hpp>
20 #include "msg/Message.h"
22 #include "common/perf_counters.h"
28 std::string description
;
30 enum perfcounter_type_d type
;
32 void encode(bufferlist
&bl
) const
34 // TODO: decide whether to drop the per-type
35 // encoding here, we could rely on the MgrReport
36 // verisoning instead.
37 ENCODE_START(1, 1, bl
);
39 ::encode(description
, bl
);
41 static_assert(sizeof(type
) == 1, "perfcounter_type_d must be one byte");
42 ::encode((uint8_t)type
, bl
);
46 void decode(bufferlist::iterator
&p
)
50 ::decode(description
, p
);
52 ::decode((uint8_t&)type
, p
);
56 WRITE_CLASS_ENCODER(PerfCounterType
)
58 class MMgrReport
: public Message
60 static const int HEAD_VERSION
= 4;
61 static const int COMPAT_VERSION
= 1;
65 * Client is responsible for remembering whether it has introduced
66 * each perf counter to the server. When first sending a particular
67 * counter, it must inline the counter's schema here.
69 std::vector
<PerfCounterType
> declare_types
;
70 std::vector
<std::string
> undeclare_types
;
72 // For all counters present, sorted by idx, output
73 // as many bytes as are needed to represent them
75 // Decode: iterate over the types we know about, sorted by idx,
76 // and use the current type's type to decide how to decode
77 // the next bytes from the bufferlist.
80 std::string daemon_name
;
81 std::string service_name
; // optional; otherwise infer from entity type
83 // for service registration
84 boost::optional
<std::map
<std::string
,std::string
>> daemon_status
;
86 void decode_payload() override
88 bufferlist::iterator p
= payload
.begin();
89 ::decode(daemon_name
, p
);
90 ::decode(declare_types
, p
);
92 if (header
.version
>= 2)
93 ::decode(undeclare_types
, p
);
94 if (header
.version
>= 3) {
95 ::decode(service_name
, p
);
96 ::decode(daemon_status
, p
);
100 void encode_payload(uint64_t features
) override
{
101 ::encode(daemon_name
, payload
);
102 ::encode(declare_types
, payload
);
103 ::encode(packed
, payload
);
104 ::encode(undeclare_types
, payload
);
105 ::encode(service_name
, payload
);
106 ::encode(daemon_status
, payload
);
109 const char *get_type_name() const override
{ return "mgrreport"; }
110 void print(ostream
& out
) const override
{
111 out
<< get_type_name() << "(";
112 if (service_name
.length()) {
115 out
<< ceph_entity_type_name(get_source().type());
117 out
<< "." << daemon_name
118 << " +" << declare_types
.size()
119 << "-" << undeclare_types
.size()
120 << " packed " << packed
.length();
122 out
<< " status=" << daemon_status
->size();
128 : Message(MSG_MGR_REPORT
, HEAD_VERSION
, COMPAT_VERSION
)