]> git.proxmox.com Git - ceph.git/blob - ceph/src/mds/MetricAggregator.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / mds / MetricAggregator.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef CEPH_MDS_METRIC_AGGREGATOR_H
5 #define CEPH_MDS_METRIC_AGGREGATOR_H
6
7 #include <map>
8 #include <set>
9 #include <thread>
10
11 #include "msg/msg_types.h"
12 #include "msg/Dispatcher.h"
13 #include "common/ceph_mutex.h"
14 #include "include/common_fwd.h"
15 #include "messages/MMDSMetrics.h"
16
17 #include "mgr/MetricTypes.h"
18 #include "mgr/MDSPerfMetricTypes.h"
19
20 #include "mdstypes.h"
21 #include "MDSMap.h"
22 #include "MDSPinger.h"
23
24 class MDSRank;
25 class MgrClient;
26
27 class MetricAggregator : public Dispatcher {
28 public:
29 MetricAggregator(CephContext *cct, MDSRank *mds, MgrClient *mgrc);
30
31 int init();
32 void shutdown();
33
34 void notify_mdsmap(const MDSMap &mdsmap);
35
36 bool ms_can_fast_dispatch_any() const override {
37 return true;
38 }
39 bool ms_can_fast_dispatch2(const cref_t<Message> &m) const override;
40 void ms_fast_dispatch2(const ref_t<Message> &m) override;
41 bool ms_dispatch2(const ref_t<Message> &m) override;
42
43 void ms_handle_connect(Connection *c) override {
44 }
45 bool ms_handle_reset(Connection *c) override {
46 return false;
47 }
48 void ms_handle_remote_reset(Connection *c) override {
49 }
50 bool ms_handle_refused(Connection *c) override {
51 return false;
52 }
53
54 private:
55 // drop this lock when calling ->send_message_mds() else mds might
56 // deadlock
57 ceph::mutex lock = ceph::make_mutex("MetricAggregator::lock");
58 MDSRank *mds;
59 MgrClient *mgrc;
60
61 // maintain a map of rank to list of clients so that when a rank
62 // goes away we cull metrics of clients connected to that rank.
63 std::map<mds_rank_t, std::unordered_set<entity_inst_t>> clients_by_rank;
64
65 // user query to metrics map
66 std::map<MDSPerfMetricQuery, std::map<MDSPerfMetricKey, PerformanceCounters>> query_metrics_map;
67
68 MDSPinger mds_pinger;
69 std::thread pinger;
70
71 std::map<mds_rank_t, entity_addrvec_t> active_rank_addrs;
72
73 bool stopping = false;
74
75 void handle_mds_metrics(const cref_t<MMDSMetrics> &m);
76
77 void refresh_metrics_for_rank(const entity_inst_t &client, mds_rank_t rank,
78 const Metrics &metrics);
79 void remove_metrics_for_rank(const entity_inst_t &client, mds_rank_t rank, bool remove);
80
81 void cull_metrics_for_rank(mds_rank_t rank);
82
83 void ping_all_active_ranks();
84
85 void set_perf_queries(const ConfigPayload &config_payload);
86 MetricPayload get_perf_reports();
87 };
88
89 #endif // CEPH_MDS_METRIC_AGGREGATOR_H