From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/mgr/MDSPerfMetricCollector.cc | 64 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/mgr/MDSPerfMetricCollector.cc (limited to 'src/mgr/MDSPerfMetricCollector.cc') diff --git a/src/mgr/MDSPerfMetricCollector.cc b/src/mgr/MDSPerfMetricCollector.cc new file mode 100644 index 000000000..62298aba3 --- /dev/null +++ b/src/mgr/MDSPerfMetricCollector.cc @@ -0,0 +1,64 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#include "common/debug.h" +#include "common/errno.h" + +#include "messages/MMgrReport.h" +#include "mgr/MDSPerfMetricTypes.h" +#include "mgr/MDSPerfMetricCollector.h" + +#define dout_context g_ceph_context +#define dout_subsys ceph_subsys_mgr +#undef dout_prefix +#define dout_prefix *_dout << "mgr.mds_perf_metric_collector " << __func__ << " " + +MDSPerfMetricCollector::MDSPerfMetricCollector(MetricListener &listener) + : MetricCollector(listener) { +} + +void MDSPerfMetricCollector::process_reports(const MetricPayload &payload) { + const MDSPerfMetricReport &metric_report = boost::get(payload).metric_report; + + std::lock_guard locker(lock); + process_reports_generic( + metric_report.reports, [](PerformanceCounter *counter, const PerformanceCounter &update) { + counter->first = update.first; + counter->second = update.second; + }); + + // update delayed rank set + delayed_ranks = metric_report.rank_metrics_delayed; + dout(20) << ": delayed ranks=[" << delayed_ranks << "]" << dendl; + + clock_gettime(CLOCK_MONOTONIC_COARSE, &last_updated_mono); +} + +int MDSPerfMetricCollector::get_counters(PerfCollector *collector) { + MDSPerfCollector *c = static_cast(collector); + + std::lock_guard locker(lock); + + int r = get_counters_generic(c->query_id, &c->counters); + if (r != 0) { + return r; + } + + get_delayed_ranks(&c->delayed_ranks); + + get_last_updated(&c->last_updated_mono); + return r; +} + +void MDSPerfMetricCollector::get_delayed_ranks(std::set *ranks) { + ceph_assert(ceph_mutex_is_locked(lock)); + *ranks = delayed_ranks; +} + +void MDSPerfMetricCollector::get_last_updated(utime_t *ts) { + ceph_assert(ceph_mutex_is_locked(lock)); + *ts = utime_t(last_updated_mono); +} -- cgit v1.2.3