blob: 2ba17f5c07c451b0cff83a5c8a5c5ff64d1f16ed (
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
|
// 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,
const ModelConfig &model);
bool checkConnectivity(RpcServer &rpcServer);
static SpecMap specsFrom(const ModelConfig &model);
private:
struct Accumulated {
size_t numIssues = 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;
};
}
|