blob: bb4dfc3f0470631dfb80106f25481185178f5d86 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "ideal_state_total_metrics.h"
namespace storage::distributor {
void
IdealStateTotalMetrics::aggregate_helper(IdealStateMetricSet& total) const
{
for (auto& stripe_metrics : _stripes_metrics) {
stripe_metrics->addToPart(total);
}
}
IdealStateTotalMetrics::IdealStateTotalMetrics(uint32_t num_distributor_stripes)
: IdealStateMetricSet(),
_stripes_metrics()
{
_stripes_metrics.reserve(num_distributor_stripes);
for (uint32_t i = 0; i < num_distributor_stripes; ++i) {
_stripes_metrics.emplace_back(std::make_shared<IdealStateMetricSet>());
}
}
IdealStateTotalMetrics::~IdealStateTotalMetrics() = default;
void
IdealStateTotalMetrics::aggregate()
{
IdealStateMetricSet::reset();
aggregate_helper(*this);
}
void
IdealStateTotalMetrics::addToSnapshot(Metric& m, std::vector<Metric::UP>& owner_list) const
{
IdealStateMetricSet total;
aggregate_helper(total);
total.addToSnapshot(m, owner_list);
}
void
IdealStateTotalMetrics::reset()
{
IdealStateMetricSet::reset();
for (auto& stripe_metrics : _stripes_metrics) {
stripe_metrics->reset();
}
}
}
|