blob: 628b7a9e5499c3f67686eaa2d80e87ea9d44c51c (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "health_adapter.h"
#include <vespa/vespalib/util/stringfmt.h>
namespace proton {
HealthAdapter::HealthAdapter(const StatusProducer &sp)
: _statusProducer(sp)
{
}
vespalib::HealthProducer::Health
HealthAdapter::getHealth() const
{
bool ok = true;
vespalib::string msg;
StatusReport::List reports(_statusProducer.getStatusReports());
for (size_t i = 0; i < reports.size(); ++i) {
const StatusReport &r = *reports[i];
if (r.getState() != StatusReport::UPOK) {
ok = false;
if (msg.size() > 0) {
msg.append(", ");
}
msg.append(vespalib::make_string("%s: %s",
r.getComponent().c_str(),
r.getMessage().c_str()));
}
}
if (ok) {
return Health(true, "All OK");
} else {
return Health(false, msg);
}
}
} // namespace proton
|