]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #ifndef OSD_PERF_METRIC_COLLECTOR_H_ | |
5 | #define OSD_PERF_METRIC_COLLECTOR_H_ | |
6 | ||
7 | #include "common/Mutex.h" | |
8 | ||
9 | #include "mgr/OSDPerfMetricTypes.h" | |
10 | ||
11 | #include <map> | |
12 | ||
13 | /** | |
14 | * OSD performance query class. | |
15 | */ | |
16 | class OSDPerfMetricCollector { | |
17 | public: | |
18 | struct Listener { | |
19 | virtual ~Listener() { | |
20 | } | |
21 | ||
22 | virtual void handle_query_updated() = 0; | |
23 | }; | |
24 | ||
25 | OSDPerfMetricCollector(Listener &listener); | |
26 | ||
27 | std::map<OSDPerfMetricQuery, OSDPerfMetricLimits> get_queries() const; | |
28 | ||
29 | OSDPerfMetricQueryID add_query( | |
30 | const OSDPerfMetricQuery& query, | |
31 | const std::optional<OSDPerfMetricLimit> &limit); | |
32 | int remove_query(OSDPerfMetricQueryID query_id); | |
33 | void remove_all_queries(); | |
34 | ||
35 | int get_counters(OSDPerfMetricQueryID query_id, | |
36 | std::map<OSDPerfMetricKey, PerformanceCounters> *counters); | |
37 | ||
38 | void process_reports( | |
39 | const std::map<OSDPerfMetricQuery, OSDPerfMetricReport> &reports); | |
40 | ||
41 | private: | |
42 | typedef std::optional<OSDPerfMetricLimit> OptionalLimit; | |
43 | typedef std::map<OSDPerfMetricQuery, | |
44 | std::map<OSDPerfMetricQueryID, OptionalLimit>> Queries; | |
45 | typedef std::map<OSDPerfMetricQueryID, | |
46 | std::map<OSDPerfMetricKey, PerformanceCounters>> Counters; | |
47 | ||
48 | Listener &listener; | |
49 | mutable Mutex lock; | |
50 | OSDPerfMetricQueryID next_query_id = 0; | |
51 | Queries queries; | |
52 | Counters counters; | |
53 | }; | |
54 | ||
55 | #endif // OSD_PERF_METRIC_COLLECTOR_H_ |