diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-04-19 13:00:52 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-04-19 13:00:52 +0200 |
commit | 43ccb0583cf52cfdc75df493bda4b60dd5263eed (patch) | |
tree | 05c9c77f55fd60be96bcb673e2c0fd7c25aeaa76 /config-provisioning/src/main/java/com/yahoo | |
parent | 16b11bcc414e23d1f901a98d712212f1c7c9d2df (diff) |
Always pass wanted Vespa version
Diffstat (limited to 'config-provisioning/src/main/java/com/yahoo')
3 files changed, 33 insertions, 22 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 ff7ff0b4971..b78c4bb9f56 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 @@ -2,6 +2,7 @@ package com.yahoo.config.provision; import com.yahoo.component.Version; +import com.yahoo.component.Vtag; import java.util.Optional; @@ -20,7 +21,7 @@ public class ClusterMembership { protected ClusterMembership() {} - private ClusterMembership(String stringValue, Optional<Version> vespaVersion) { + private ClusterMembership(String stringValue, Version vespaVersion) { String restValue; if (stringValue.endsWith("/retired")) { retired = true; @@ -51,14 +52,14 @@ public class ClusterMembership { this.stringValue = toStringValue(); } - private void initWithoutGroup(String[] components, Optional<Version> vespaVersion) { - this.cluster = ClusterSpec.requestVersion(ClusterSpec.Type.valueOf(components[0]), - ClusterSpec.Id.from(components[1]), - vespaVersion); + private void initWithoutGroup(String[] components, Version vespaVersion) { + this.cluster = ClusterSpec.request(ClusterSpec.Type.valueOf(components[0]), + ClusterSpec.Id.from(components[1]), + vespaVersion); this.index = Integer.parseInt(components[2]); } - private void initWithGroup(String[] components, Optional<Version> vespaVersion) { + private void initWithGroup(String[] components, Version vespaVersion) { this.cluster = ClusterSpec.from(ClusterSpec.Type.valueOf(components[0]), ClusterSpec.Id.from(components[1]), ClusterSpec.Group.from(Integer.valueOf(components[2])), vespaVersion); this.index = Integer.parseInt(components[3]); @@ -115,10 +116,16 @@ public class ClusterMembership { @Deprecated // TODO: April 2017 - Remove this when no version older than 6.92 is in production public static ClusterMembership from(String stringValue, Optional<String> dockerImage) { - return fromVersion(stringValue, dockerImage.map(DockerImage::new).map(DockerImage::tagAsVersion)); + return from(stringValue, dockerImage.map(DockerImage::new).map(DockerImage::tagAsVersion).orElse(Vtag.currentVersion)); } + @Deprecated + // TODO: April 2017 - Remove this when no version older than 6.97 is in production public static ClusterMembership fromVersion(String stringValue, Optional<Version> vespaVersion) { + return new ClusterMembership(stringValue, vespaVersion.orElse(Vtag.currentVersion)); + } + + public static ClusterMembership from(String stringValue, Version vespaVersion) { return new ClusterMembership(stringValue, vespaVersion); } 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 ec655f0eee2..6a79f2f06ed 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 @@ -2,6 +2,8 @@ package com.yahoo.config.provision; import com.yahoo.component.Version; +import com.yahoo.component.Vtag; + import java.util.Objects; import java.util.Optional; @@ -55,7 +57,7 @@ public final class ClusterSpec { /** Create a specification <b>requesting</b> a cluster with these attributes */ // TODO: April 2017 - Remove this when no version older than 6.97 is used anywhere public static ClusterSpec requestVersion(Type type, Id id, Optional<Version> vespaVersion) { - return new ClusterSpec(type, id, Optional.empty(), vespaVersion.get()); + return new ClusterSpec(type, id, Optional.empty(), vespaVersion.orElse(Vtag.currentVersion)); } public static ClusterSpec request(Type type, Id id, Version vespaVersion) { @@ -65,18 +67,13 @@ public final class ClusterSpec { /** Create a specification <b>specifying</b> an existing cluster group having these attributes */ // TODO: April 2017 - Remove this when no version older than 6.97 is used anywhere public static ClusterSpec from(Type type, Id id, Group groupId, Optional<Version> vespaVersion) { - return new ClusterSpec(type, id, Optional.of(groupId), vespaVersion.get()); + return new ClusterSpec(type, id, Optional.of(groupId), vespaVersion.orElse(Vtag.currentVersion)); } - /** Create a specification <b>specifying</b> an existing cluster group having these attributes */ - // TODO: April 2017 - Remove this when no version older than 6.97 is used anywhere public static ClusterSpec from(Type type, Id id, Group groupId, Version vespaVersion) { return new ClusterSpec(type, id, Optional.of(groupId), vespaVersion); } - neste: - sørg for at ingen bruker deprecateds over - - gå tilbake til NodeSpecification og sørg for at version sendes inn der fra ModelContext - @Override public String toString() { return String.join(" ", type.toString(), id.toString(), diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/ProvisionInfo.java b/config-provisioning/src/main/java/com/yahoo/config/provision/ProvisionInfo.java index cc7d871d23f..01ef305034d 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/ProvisionInfo.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/ProvisionInfo.java @@ -1,6 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config.provision; +import com.yahoo.component.Vtag; import com.yahoo.slime.ArrayTraverser; import com.yahoo.slime.Cursor; import com.yahoo.slime.Inspector; @@ -8,10 +9,13 @@ import com.yahoo.slime.Slime; import com.yahoo.vespa.config.SlimeUtils; import java.io.IOException; -import java.util.*; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Optional; +import java.util.Set; /** - * Information about provisioned hosts, and (de)serialization (from)to JSON. + * Information about hosts provisioned for an application, and (de)serialization of this information to/from JSON. * * @author lulf * @since 5.12 @@ -23,7 +27,7 @@ public class ProvisionInfo { private static final String hostSpecHostName = "hostName"; private static final String hostSpecMembership = "membership"; private static final String hostSpecFlavor = "flavor"; - private static final String dockerImage = "dockerImage"; + private static final String hostSpecVespaVersion = "vespaVersion"; private final Set<HostSpec> hosts = new LinkedHashSet<>(); @@ -47,7 +51,7 @@ public class ProvisionInfo { cursor.setString(hostSpecHostName, host.hostname()); if (host.membership().isPresent()) { cursor.setString(hostSpecMembership, host.membership().get().stringValue()); - cursor.setString(dockerImage, host.membership().get().cluster().dockerImage()); + cursor.setString(hostSpecVespaVersion, host.membership().get().cluster().vespaVersion().toString()); } if (host.flavor().isPresent()) cursor.setString(hostSpecFlavor, host.flavor().get().name()); @@ -59,17 +63,17 @@ public class ProvisionInfo { private static ProvisionInfo fromSlime(Inspector inspector, Optional<NodeFlavors> nodeFlavors) { Inspector array = inspector.field(mappingKey); - final Set<HostSpec> hosts = new LinkedHashSet<>(); + Set<HostSpec> hosts = new LinkedHashSet<>(); array.traverse(new ArrayTraverser() { @Override public void entry(int i, Inspector inspector) { - hosts.add(createHostSpec(inspector.field(hostSpecKey), nodeFlavors)); + hosts.add(deserializeHostSpec(inspector.field(hostSpecKey), nodeFlavors)); } }); return new ProvisionInfo(hosts); } - private static HostSpec createHostSpec(Inspector object, Optional<NodeFlavors> nodeFlavors) { + private static HostSpec deserializeHostSpec(Inspector object, Optional<NodeFlavors> nodeFlavors) { Optional<ClusterMembership> membership = object.field(hostSpecMembership).valid() ? Optional.of(readMembership(object)) : Optional.empty(); Optional<Flavor> flavor = @@ -79,8 +83,11 @@ public class ProvisionInfo { } private static ClusterMembership readMembership(Inspector object) { + // TODO: When no version older than 6.97 is present anywhere, remove the possibility of the version field missing return ClusterMembership.from(object.field(hostSpecMembership).asString(), - object.field(dockerImage).valid() ? Optional.of(object.field(dockerImage).asString()) : Optional.empty()); + object.field(hostSpecVespaVersion).valid() ? + com.yahoo.component.Version.fromString(object.field(hostSpecVespaVersion).asString()) : + Vtag.currentVersion); } private static Optional<Flavor> readFlavor(Inspector object, Optional<NodeFlavors> nodeFlavors) { |