-
Notifications
You must be signed in to change notification settings - Fork 188
/
HealthcheckOptions.java
131 lines (114 loc) · 5.45 KB
/
HealthcheckOptions.java
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package com.hubspot.deploy;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Objects;
import com.google.common.base.Optional;
import com.hubspot.singularity.HealthcheckProtocol;
import com.wordnik.swagger.annotations.ApiModelProperty;
public class HealthcheckOptions {
@NotNull
private final String uri;
private final Optional<Integer> portIndex;
private final Optional<Long> portNumber;
private final Optional<HealthcheckProtocol> protocol;
private final Optional<Integer> startupTimeoutSeconds;
private final Optional<Integer> startupDelaySeconds;
private final Optional<Integer> startupIntervalSeconds;
private final Optional<Integer> intervalSeconds;
private final Optional<Integer> responseTimeoutSeconds;
private final Optional<Integer> maxRetries;
@JsonCreator
public HealthcheckOptions(@JsonProperty("uri") String uri, @JsonProperty("portIndex") Optional<Integer> portIndex, @JsonProperty("portNumber") Optional<Long> portNumber, @JsonProperty("protocol") Optional<HealthcheckProtocol> protocol,
@JsonProperty("startupTimeoutSeconds") Optional<Integer> startupTimeoutSeconds, @JsonProperty("startupDelaySeconds") Optional<Integer> startupDelaySeconds, @JsonProperty("startupIntervalSeconds") Optional<Integer> startupIntervalSeconds,
@JsonProperty("intervalSeconds") Optional<Integer> intervalSeconds, @JsonProperty("responseTimeoutSeconds") Optional<Integer> responseTimeoutSeconds, @JsonProperty("maxRetries") Optional<Integer> maxRetries) {
this.uri = uri;
this.portIndex = portIndex;
this.portNumber = portNumber;
this.protocol = protocol;
this.startupTimeoutSeconds = startupTimeoutSeconds;
this.startupDelaySeconds = startupDelaySeconds;
this.startupIntervalSeconds = startupIntervalSeconds;
this.intervalSeconds = intervalSeconds;
this.responseTimeoutSeconds = responseTimeoutSeconds;
this.maxRetries = maxRetries;
}
public String getUri() {
return uri;
}
@ApiModelProperty(required=false, value="Perform healthcheck on this dynamically allocated port (e.g. 0 for first port), defaults to first port")
public Optional<Integer> getPortIndex() {
return portIndex;
}
@ApiModelProperty(required=false, value="Perform healthcheck on this port (portIndex cannot also be used when using this setting)")
public Optional<Long> getPortNumber() {
return portNumber;
}
@ApiModelProperty(required=false, value="Healthcheck protocol - HTTP or HTTPS")
public Optional<HealthcheckProtocol> getProtocol() {
return protocol;
}
@ApiModelProperty(required=false, value="Consider the task unhealthy/failed if the app has not started responding to healthchecks in this amount of time")
public Optional<Integer> getStartupTimeoutSeconds() {
return startupTimeoutSeconds;
}
@ApiModelProperty(required=false, value="Wait this long before issuing the first healthcheck")
public Optional<Integer> getStartupDelaySeconds() {
return startupDelaySeconds;
}
@ApiModelProperty(required=false, value="Time to wait after a failed healthcheck to try again in seconds.")
public Optional<Integer> getStartupIntervalSeconds() {
return startupIntervalSeconds;
}
@ApiModelProperty(required=false, value="Time to wait after a valid but failed healthcheck response to try again in seconds.")
public Optional<Integer> getIntervalSeconds() {
return intervalSeconds;
}
@ApiModelProperty(required=false, value="Single healthcheck HTTP timeout in seconds.")
public Optional<Integer> getResponseTimeoutSeconds() {
return responseTimeoutSeconds;
}
@ApiModelProperty(required=false, value="Maximum number of times to retry an individual healthcheck before failing the deploy.")
public Optional<Integer> getMaxRetries() {
return maxRetries;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
HealthcheckOptions options = (HealthcheckOptions) o;
return Objects.equal(uri, options.uri) &&
Objects.equal(portIndex, options.portIndex) &&
Objects.equal(portNumber, options.portNumber) &&
Objects.equal(protocol, options.protocol) &&
Objects.equal(startupTimeoutSeconds, options.startupTimeoutSeconds) &&
Objects.equal(startupDelaySeconds, options.startupDelaySeconds) &&
Objects.equal(startupIntervalSeconds, options.startupIntervalSeconds) &&
Objects.equal(intervalSeconds, options.intervalSeconds) &&
Objects.equal(responseTimeoutSeconds, options.responseTimeoutSeconds) &&
Objects.equal(maxRetries, options.maxRetries);
}
@Override
public int hashCode() {
return Objects.hashCode(uri, portIndex, portNumber, protocol, startupTimeoutSeconds, startupDelaySeconds, startupIntervalSeconds, intervalSeconds, responseTimeoutSeconds, maxRetries);
}
@Override
public String toString() {
return Objects.toStringHelper(this)
.add("uri", uri)
.add("portIndex", portIndex)
.add("portNumber", portNumber)
.add("protocol", protocol)
.add("startupTimeoutSeconds", startupTimeoutSeconds)
.add("startupDelaySeconds", startupDelaySeconds)
.add("startupIntervalSeconds", startupIntervalSeconds)
.add("intervalSeconds", intervalSeconds)
.add("responseTimeoutSeconds", responseTimeoutSeconds)
.add("maxRetries", maxRetries)
.toString();
}
}