diff options
Diffstat (limited to 'config-provisioning/src/main/java/com/yahoo/config')
-rw-r--r-- | config-provisioning/src/main/java/com/yahoo/config/provision/ClusterMembership.java | 10 | ||||
-rw-r--r-- | config-provisioning/src/main/java/com/yahoo/config/provision/ClusterSpec.java | 19 |
2 files changed, 22 insertions, 7 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterMembership.java b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterMembership.java index 0cd30061139..b777a13af7c 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterMembership.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterMembership.java @@ -39,9 +39,13 @@ public class ClusterMembership { } } - this.cluster = ClusterSpec.from(ClusterSpec.Type.valueOf(components[0]), ClusterSpec.Id.from(components[1]), - ClusterSpec.Group.from(Integer.parseInt(components[2])), vespaVersion, - exclusive, combinedId.map(ClusterSpec.Id::from), dockerImageRepo); + this.cluster = ClusterSpec.specification(ClusterSpec.Type.valueOf(components[0]), ClusterSpec.Id.from(components[1])) + .group(ClusterSpec.Group.from(Integer.parseInt(components[2]))) + .vespaVersion(vespaVersion) + .exclusive(exclusive) + .combinedId(combinedId.map(ClusterSpec.Id::from)) + .dockerImageRepo(dockerImageRepo) + .build(); this.index = Integer.parseInt(components[3]); this.stringValue = toStringValue(); } diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterSpec.java b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterSpec.java index 45a276a83b2..70d0a7a1929 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterSpec.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterSpec.java @@ -100,14 +100,21 @@ public final class ClusterSpec { return new ClusterSpec(type, id, Optional.of(groupId), vespaVersion, exclusive, combinedId, dockerImageRepo); } - public static Builder builder(Type type, Id id) { - return new Builder(type, id); + /** Creates a ClusterSpec when requesting a cluster */ + public static Builder request(Type type, Id id) { + return new Builder(type, id, false); + } + + /** Creates a ClusterSpec for an existing cluster, group id and vespa version needs to be set */ + public static Builder specification(Type type, Id id) { + return new Builder(type, id, true); } public static class Builder { private final Type type; private final Id id; + private final boolean specification; private Optional<Group> groupId = Optional.empty(); private Optional<String> dockerImageRepo = Optional.empty(); @@ -115,13 +122,17 @@ public final class ClusterSpec { private boolean exclusive = false; private Optional<Id> combinedId = Optional.empty(); - - Builder(Type type, Id id) { + Builder(Type type, Id id, boolean specification) { this.type = type; this.id = id; + this.specification = specification; } public ClusterSpec build() { + if (specification) { + if (groupId.isEmpty()) throw new IllegalArgumentException("Creating a ClusterSpec with specification() requires groupId to be set"); + if (vespaVersion == null) throw new IllegalArgumentException("Creating a ClusterSpec with specification() requires vespaVersion to be set"); + } return new ClusterSpec(type, id, groupId, vespaVersion, exclusive, combinedId, dockerImageRepo); } |