aboutsummaryrefslogtreecommitdiffstats
path: root/configd/src/apps/sentinel/connectivity.h
blob: 6b0e2d7523e13b14f746286d5adf7829733d8139 (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
// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "rpcserver.h"
#include "cc-result.h"
#include <vespa/config-sentinel.h>
#include <vespa/config-model.h>
#include <string>
#include <map>

using cloud::config::SentinelConfig;
using cloud::config::ModelConfig;

namespace config::sentinel {

/**
 * Utility class for running connectivity check.
 **/
class Connectivity {
public:
    using SpecMap = std::map<std::string, int>;
    using HostAndPort = SpecMap::value_type;

    Connectivity();
    ~Connectivity();
    void configure(const SentinelConfig::Connectivity &config);
    bool checkConnectivity(RpcServer &rpcServer);
private:
    struct Accumulated {
        size_t numUpAndOk = 0;
        size_t numSeriousIssues = 0;
    };
    void accumulate(Accumulated &target, CcResult value);
    bool enoughOk(const Accumulated &results, size_t clusterSize);
    SentinelConfig::Connectivity _config;
    SpecMap _checkSpecs;
    std::map<std::string, std::string> _detailsPerHost;
};

}