blob: d9076557ac771e10ea605aaa35edc3ed6a9ac914 (
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
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
|
package com.yahoo.config.provision;
import java.time.Duration;
import java.util.Objects;
import static ai.vespa.validation.Validation.requireAtLeast;
/**
* Auxiliary information about a cluster, provided by the config model to the node repo during a
* capacity request.
*
* @author bratseth
*/
public class ClusterInfo {
private static final ClusterInfo empty = new ClusterInfo.Builder().build();
private final Duration bcpDeadline;
private final Duration hostTTL;
private ClusterInfo(Builder builder) {
this.bcpDeadline = builder.bcpDeadline;
this.hostTTL = builder.hostTTL;
requireAtLeast(hostTTL, "host TTL", Duration.ZERO);
}
public Duration bcpDeadline() { return bcpDeadline; }
public Duration hostTTL() { return hostTTL; }
public static ClusterInfo empty() { return empty; }
public boolean isEmpty() { return this.equals(empty); }
@Override
public boolean equals(Object o) {
if (o == this) return true;
if ( ! (o instanceof ClusterInfo other)) return false;
if ( ! other.bcpDeadline.equals(this.bcpDeadline)) return false;
if ( ! other.hostTTL.equals(this.hostTTL)) return false;
return true;
}
@Override
public int hashCode() {
return Objects.hash(bcpDeadline, hostTTL);
}
@Override
public String toString() {
return "cluster info: [bcp deadline: " + bcpDeadline + ", host TTL: " + hostTTL + "]";
}
public static class Builder {
private Duration bcpDeadline = Duration.ZERO;
private Duration hostTTL = Duration.ZERO;
public Builder bcpDeadline(Duration duration) {
this.bcpDeadline = Objects.requireNonNull(duration);
return this;
}
public Builder hostTTL(Duration duration) {
this.hostTTL = Objects.requireNonNull(duration);
return this;
}
public ClusterInfo build() {
return new ClusterInfo(this);
}
}
}
|