summaryrefslogtreecommitdiffstats
path: root/controller-api
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2022-08-31 14:11:05 +0200
committerMartin Polden <mpolden@mpolden.no>2022-08-31 14:28:17 +0200
commit3af64a004f65f0f2695a57027582eb09c5cee23e (patch)
treeb158e2c2841c379b576f0fb9c387f00958dc08f6 /controller-api
parentc8e01e3df9a9fcc910cceef07f060c6e9f13d2f8 (diff)
Ensure that the scheduling instant is never in the past
Diffstat (limited to 'controller-api')
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/OsRelease.java33
1 files changed, 11 insertions, 22 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/OsRelease.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/OsRelease.java
index d80b2201810..fdcda9e5403 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/OsRelease.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/OsRelease.java
@@ -3,6 +3,7 @@ package com.yahoo.vespa.hosted.controller.api.integration.deployment;
import com.yahoo.component.Version;
+import java.time.Duration;
import java.time.Instant;
import java.util.Objects;
@@ -11,16 +12,12 @@ import java.util.Objects;
*
* @author mpolden
*/
-public class OsRelease {
+public record OsRelease(Version version, Tag tag, Instant taggedAt) {
- private final Version version;
- private final Tag tag;
- private final Instant taggedAt;
-
- public OsRelease(Version version, Tag tag, Instant taggedAt) {
- this.version = Objects.requireNonNull(version);
- this.tag = Objects.requireNonNull(tag);
- this.taggedAt = Objects.requireNonNull(taggedAt);
+ public OsRelease {
+ Objects.requireNonNull(version);
+ Objects.requireNonNull(tag);
+ Objects.requireNonNull(taggedAt);
}
/** The version number */
@@ -38,22 +35,14 @@ public class OsRelease {
return taggedAt;
}
- @Override
- public String toString() {
- return "os release " + version + ", tagged " + tag + " at " + taggedAt;
+ /** Returns the age of this at given instant */
+ public Duration age(Instant instant) {
+ return Duration.between(taggedAt, instant);
}
@Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- OsRelease osRelease = (OsRelease) o;
- return version.equals(osRelease.version) && tag == osRelease.tag && taggedAt.equals(osRelease.taggedAt);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(version, tag, taggedAt);
+ public String toString() {
+ return "os release " + version + ", tagged " + tag + " at " + taggedAt;
}
/** Known release tags */