blob: aec0f02e22e3fea20f623b768e06df584eac159e (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.os;
import com.yahoo.component.Version;
import com.yahoo.config.provision.NodeType;
import java.time.Duration;
import java.time.Instant;
import java.util.Objects;
import java.util.Optional;
/**
* The target OS version for a {@link NodeType}.
*
* @author mpolden
*/
public class OsVersionTarget {
private final NodeType nodeType;
private final Version version;
private final Duration upgradeBudget;
private final Optional<Instant> lastRetiredAt;
public OsVersionTarget(NodeType nodeType, Version version, Duration upgradeBudget, Optional<Instant> lastRetiredAt) {
this.nodeType = Objects.requireNonNull(nodeType);
this.version = Objects.requireNonNull(version);
this.upgradeBudget = Objects.requireNonNull(upgradeBudget);
this.lastRetiredAt = Objects.requireNonNull(lastRetiredAt);
if (upgradeBudget.isNegative()) throw new IllegalArgumentException("Upgrade budget cannot be negative");
}
/** The node type this applies to */
public NodeType nodeType() {
return nodeType;
}
/** The OS version of this target */
public Version version() {
return version;
}
/** The upgrade budget for this. All nodes targeting this must upgrade within this budget */
public Duration upgradeBudget() {
return upgradeBudget;
}
/** The most recent time a node was retired to apply a version upgrade */
public Optional<Instant> lastRetiredAt() {
return lastRetiredAt;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
OsVersionTarget target = (OsVersionTarget) o;
return nodeType == target.nodeType &&
version.equals(target.version) &&
upgradeBudget.equals(target.upgradeBudget) &&
lastRetiredAt.equals(target.lastRetiredAt);
}
@Override
public int hashCode() {
return Objects.hash(nodeType, version, upgradeBudget, lastRetiredAt);
}
}
|