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
49
50
51
52
53
54
55
56
57
58
59
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.service.health;
import ai.vespa.http.DomainName;
import com.yahoo.vespa.service.executor.RunletExecutor;
import com.yahoo.vespa.service.monitor.ServiceId;
import java.net.URL;
import java.time.Duration;
import static com.yahoo.yolean.Exceptions.uncheck;
/**
* @author hakonhall
*/
class StateV1HealthEndpoint implements HealthEndpoint {
private final ServiceId serviceId;
private final URL url;
private final Duration requestTimeout;
private final Duration connectionKeepAlive;
private final Duration delay;
private final RunletExecutor executor;
StateV1HealthEndpoint(ServiceId serviceId,
DomainName hostname,
int port,
Duration delay,
Duration requestTimeout,
Duration connectionKeepAlive,
RunletExecutor executor) {
this.serviceId = serviceId;
this.delay = delay;
this.executor = executor;
this.url = uncheck(() -> new URL("http", hostname.value(), port, "/state/v1/health"));
this.requestTimeout = requestTimeout;
this.connectionKeepAlive = connectionKeepAlive;
}
@Override
public ServiceId getServiceId() {
return serviceId;
}
@Override
public HealthMonitor startMonitoring() {
var updater = new StateV1HealthUpdater(url, requestTimeout, connectionKeepAlive);
return new StateV1HealthMonitor(updater, executor, delay);
}
@Override
public String description() {
return url.toString();
}
@Override
public String toString() {
return description();
}
}
|