blob: c6bfed8a144db5721b7e2eb3e86bf5cd7e6b9120 (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/vespalib/util/threadstackexecutor.h>
#include <chrono>
#include <mutex>
#include <condition_variable>
namespace search::bmcluster {
class BmCluster;
class BmNodeStats;
/*
* Class handling background reporting of node stats during feed or
* document redistribution.
*/
class BmNodeStatsReporter {
BmCluster& _cluster;
vespalib::ThreadStackExecutor _executor;
std::mutex _mutex;
std::condition_variable _cond;
std::chrono::time_point<std::chrono::steady_clock> _change_time;
std::vector<BmNodeStats> _prev_node_stats;
uint32_t _pending_report;
bool _report_merge_stats;
bool _started;
bool _stop;
void report();
void run_report_loop(std::chrono::milliseconds interval);
public:
BmNodeStatsReporter(BmCluster& cluster, bool report_merge_stats);
~BmNodeStatsReporter();
void start(std::chrono::milliseconds interval);
void stop();
void report_now();
std::chrono::time_point<std::chrono::steady_clock> get_change_time() const noexcept { return _change_time; }
};
}
|