]>
Commit | Line | Data |
---|---|---|
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) 2016 John Spray <john.spray@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_MMGRCONFIGURE_H_ | |
16 | #define CEPH_MMGRCONFIGURE_H_ | |
17 | ||
18 | #include "msg/Message.h" | |
19 | #include "mgr/MetricTypes.h" | |
20 | #include "mgr/OSDPerfMetricTypes.h" | |
21 | ||
22 | /** | |
23 | * This message is sent from ceph-mgr to MgrClient, instructing it | |
24 | * it about what data to send back to ceph-mgr at what frequency. | |
25 | */ | |
26 | class MMgrConfigure : public Message { | |
27 | private: | |
28 | static constexpr int HEAD_VERSION = 4; | |
29 | static constexpr int COMPAT_VERSION = 1; | |
30 | ||
31 | public: | |
32 | uint32_t stats_period = 0; | |
33 | ||
34 | // Default 0 means if unspecified will include all stats | |
35 | uint32_t stats_threshold = 0; | |
36 | ||
37 | std::map<OSDPerfMetricQuery, OSDPerfMetricLimits> osd_perf_metric_queries; | |
38 | ||
39 | boost::optional<MetricConfigMessage> metric_config_message; | |
40 | ||
41 | void decode_payload() override | |
42 | { | |
43 | using ceph::decode; | |
44 | auto p = payload.cbegin(); | |
45 | decode(stats_period, p); | |
46 | if (header.version >= 2) { | |
47 | decode(stats_threshold, p); | |
48 | } | |
49 | if (header.version >= 3) { | |
50 | decode(osd_perf_metric_queries, p); | |
51 | } | |
52 | if (header.version >= 4) { | |
53 | decode(metric_config_message, p); | |
54 | } | |
55 | } | |
56 | ||
57 | void encode_payload(uint64_t features) override { | |
58 | using ceph::encode; | |
59 | encode(stats_period, payload); | |
60 | encode(stats_threshold, payload); | |
61 | encode(osd_perf_metric_queries, payload); | |
62 | if (metric_config_message && metric_config_message->should_encode(features)) { | |
63 | encode(metric_config_message, payload); | |
64 | } else { | |
65 | boost::optional<MetricConfigMessage> empty; | |
66 | encode(empty, payload); | |
67 | } | |
68 | } | |
69 | ||
70 | std::string_view get_type_name() const override { return "mgrconfigure"; } | |
71 | void print(std::ostream& out) const override { | |
72 | out << get_type_name() << "(period=" << stats_period | |
73 | << ", threshold=" << stats_threshold << ")"; | |
74 | } | |
75 | ||
76 | private: | |
77 | MMgrConfigure() | |
78 | : Message{MSG_MGR_CONFIGURE, HEAD_VERSION, COMPAT_VERSION} | |
79 | {} | |
80 | using RefCountedObject::put; | |
81 | using RefCountedObject::get; | |
82 | template<class T, typename... Args> | |
83 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
84 | template<class T, typename... Args> | |
85 | friend MURef<T> crimson::make_message(Args&&... args); | |
86 | }; | |
87 | ||
88 | #endif | |
89 |