]>
Commit | Line | Data |
---|---|---|
31f18b77 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) 2017 Greg Farnum/Red Hat <gfarnum@redhat.com> | |
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_MMONMGRREPORT_H | |
16 | #define CEPH_MMONMGRREPORT_H | |
17 | ||
18 | #include "messages/PaxosServiceMessage.h" | |
19 | #include "include/types.h" | |
224ce89b WB |
20 | #include "include/health.h" |
21 | #include "mon/health_check.h" | |
11fdf7f2 | 22 | #include "mon/PGMap.h" |
31f18b77 | 23 | |
f67539c2 | 24 | class MMonMgrReport final : public PaxosServiceMessage { |
11fdf7f2 | 25 | private: |
f67539c2 | 26 | static constexpr int HEAD_VERSION = 3; |
11fdf7f2 | 27 | static constexpr int COMPAT_VERSION = 1; |
31f18b77 FG |
28 | |
29 | public: | |
30 | // PGMapDigest is in data payload | |
224ce89b | 31 | health_check_map_t health_checks; |
f67539c2 | 32 | ceph::buffer::list service_map_bl; // encoded ServiceMap |
11fdf7f2 | 33 | std::map<std::string,ProgressEvent> progress_events; |
f67539c2 | 34 | uint64_t gid = 0; |
31f18b77 FG |
35 | |
36 | MMonMgrReport() | |
9f95a23c | 37 | : PaxosServiceMessage{MSG_MON_MGR_REPORT, 0, HEAD_VERSION, COMPAT_VERSION} |
31f18b77 FG |
38 | {} |
39 | private: | |
f67539c2 | 40 | ~MMonMgrReport() final {} |
31f18b77 FG |
41 | |
42 | public: | |
11fdf7f2 | 43 | std::string_view get_type_name() const override { return "monmgrreport"; } |
31f18b77 | 44 | |
f67539c2 TL |
45 | void print(std::ostream& out) const override { |
46 | out << get_type_name() << "(gid " << gid | |
47 | << ", " << health_checks.checks.size() << " checks, " | |
11fdf7f2 | 48 | << progress_events.size() << " progress events)"; |
31f18b77 FG |
49 | } |
50 | ||
51 | void encode_payload(uint64_t features) override { | |
11fdf7f2 | 52 | using ceph::encode; |
31f18b77 | 53 | paxos_encode(); |
11fdf7f2 TL |
54 | encode(health_checks, payload); |
55 | encode(service_map_bl, payload); | |
56 | encode(progress_events, payload); | |
f67539c2 | 57 | encode(gid, payload); |
11fdf7f2 TL |
58 | |
59 | if (!HAVE_FEATURE(features, SERVER_NAUTILUS) || | |
60 | !HAVE_FEATURE(features, SERVER_MIMIC)) { | |
61 | // PGMapDigest had a backwards-incompatible change between | |
62 | // luminous and mimic, and conditionally encodes based on | |
63 | // provided features, so reencode the one in our data payload. | |
64 | // The mgr isn't able to do this at the time the encoded | |
65 | // PGMapDigest is constructed because we don't know which mon we | |
66 | // will target. Note that this only triggers if the user | |
67 | // upgrades ceph-mgr before ceph-mon (tsk tsk). | |
68 | PGMapDigest digest; | |
69 | auto p = data.cbegin(); | |
70 | decode(digest, p); | |
f67539c2 | 71 | ceph::buffer::list bl; |
11fdf7f2 TL |
72 | encode(digest, bl, features); |
73 | set_data(bl); | |
74 | } | |
31f18b77 FG |
75 | } |
76 | void decode_payload() override { | |
f67539c2 | 77 | using ceph::decode; |
11fdf7f2 | 78 | auto p = payload.cbegin(); |
31f18b77 | 79 | paxos_decode(p); |
11fdf7f2 TL |
80 | decode(health_checks, p); |
81 | decode(service_map_bl, p); | |
82 | if (header.version >= 2) { | |
83 | decode(progress_events, p); | |
84 | } | |
f67539c2 TL |
85 | if (header.version >= 3) { |
86 | decode(gid, p); | |
87 | } | |
31f18b77 | 88 | } |
9f95a23c TL |
89 | private: |
90 | template<class T, typename... Args> | |
91 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
31f18b77 FG |
92 | }; |
93 | ||
94 | #endif |