aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/distributor/distributor_host_info_reporter.h
blob: 412867b537ff35b713c0024845f1201d8db542fc (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <vespa/storage/common/hostreporter/hostreporter.h>
#include <atomic>

namespace storage::distributor {

class BucketSpacesStatsProvider;
class MinReplicaProvider;
struct OperationStats;

class DistributorHostInfoReporter : public HostReporter
{
public:
    DistributorHostInfoReporter(MinReplicaProvider& minReplicaProvider,
                                BucketSpacesStatsProvider& bucketSpacesStatsProvider);

    DistributorHostInfoReporter(const DistributorHostInfoReporter&) = delete;
    DistributorHostInfoReporter& operator=(
            const DistributorHostInfoReporter&) = delete;

    void report(vespalib::JsonStream& output) override;

    /**
     * Set wether per-node latency, replication factors, merge stats etc are
     * to be included in the generated JSON report.
     *
     * Thread safe.
     */
    void enableReporting(bool enabled) noexcept {
        _enabled.store(enabled, std::memory_order_relaxed);
    }

    /**
     * Thread safe.
     */
    bool isReportingEnabled() const noexcept {
        return _enabled.load(std::memory_order_relaxed);
    }

private:
    MinReplicaProvider& _minReplicaProvider;
    BucketSpacesStatsProvider& _bucketSpacesStatsProvider;
    std::atomic<bool> _enabled;
};

} // storage::distributor