]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #include "common/debug.h" | |
5 | #include "common/errno.h" | |
6 | ||
7 | #include "messages/MMgrReport.h" | |
8 | #include "mgr/MDSPerfMetricTypes.h" | |
9 | #include "mgr/MDSPerfMetricCollector.h" | |
10 | ||
11 | #define dout_context g_ceph_context | |
12 | #define dout_subsys ceph_subsys_mgr | |
13 | #undef dout_prefix | |
14 | #define dout_prefix *_dout << "mgr.mds_perf_metric_collector " << __func__ << " " | |
15 | ||
16 | MDSPerfMetricCollector::MDSPerfMetricCollector(MetricListener &listener) | |
17 | : MetricCollector<MDSPerfMetricQuery, | |
18 | MDSPerfMetricLimit, | |
19 | MDSPerfMetricKey, | |
20 | MDSPerfMetrics>(listener) { | |
21 | } | |
22 | ||
23 | void MDSPerfMetricCollector::process_reports(const MetricPayload &payload) { | |
24 | const MDSPerfMetricReport &metric_report = boost::get<MDSMetricPayload>(payload).metric_report; | |
25 | ||
26 | std::lock_guard locker(lock); | |
27 | process_reports_generic( | |
28 | metric_report.reports, [](PerformanceCounter *counter, const PerformanceCounter &update) { | |
29 | counter->first = update.first; | |
30 | counter->second = update.second; | |
31 | }); | |
32 | ||
33 | // update delayed rank set | |
34 | delayed_ranks = metric_report.rank_metrics_delayed; | |
35 | dout(20) << ": delayed ranks=[" << delayed_ranks << "]" << dendl; | |
33c7a0ef TL |
36 | |
37 | clock_gettime(CLOCK_MONOTONIC_COARSE, &last_updated_mono); | |
f67539c2 TL |
38 | } |
39 | ||
40 | int MDSPerfMetricCollector::get_counters(PerfCollector *collector) { | |
41 | MDSPerfCollector *c = static_cast<MDSPerfCollector *>(collector); | |
42 | ||
43 | std::lock_guard locker(lock); | |
44 | ||
45 | int r = get_counters_generic(c->query_id, &c->counters); | |
46 | if (r != 0) { | |
47 | return r; | |
48 | } | |
49 | ||
50 | get_delayed_ranks(&c->delayed_ranks); | |
51 | ||
33c7a0ef | 52 | get_last_updated(&c->last_updated_mono); |
f67539c2 TL |
53 | return r; |
54 | } | |
55 | ||
56 | void MDSPerfMetricCollector::get_delayed_ranks(std::set<mds_rank_t> *ranks) { | |
57 | ceph_assert(ceph_mutex_is_locked(lock)); | |
58 | *ranks = delayed_ranks; | |
59 | } | |
33c7a0ef TL |
60 | |
61 | void MDSPerfMetricCollector::get_last_updated(utime_t *ts) { | |
62 | ceph_assert(ceph_mutex_is_locked(lock)); | |
63 | *ts = utime_t(last_updated_mono); | |
64 | } |