diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-12-01 07:35:14 -0800 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-12-01 07:35:14 -0800 |
commit | 051c699dee05fc0a2f5e9a83ddd49016114d8bfb (patch) | |
tree | a94c05da756ff987d198a8bea2b9bf5149771546 | |
parent | c0513ac34d2c438e9f97e699659855029e1f06e8 (diff) |
Deprecate com.yahoo.config.provision.Version
We have com.yahoo.component.Version, and one is enough.
57 files changed, 315 insertions, 193 deletions
diff --git a/component/src/main/java/com/yahoo/component/Version.java b/component/src/main/java/com/yahoo/component/Version.java index d97ecc3e1e7..8ce4fe050f7 100644 --- a/component/src/main/java/com/yahoo/component/Version.java +++ b/component/src/main/java/com/yahoo/component/Version.java @@ -250,7 +250,9 @@ public final class Version implements Comparable<Version> { /** * Returns the string representation of this version identifier as major.minor.micro.qualifier, - * omitting .qualifier if qualifier was empty or unspecified + * omitting .qualifier if qualifier empty or unspecified + * <p> + * This string form is part of the API of Version and will never change. */ public String toFullString() { StringBuilder b = new StringBuilder(); @@ -284,9 +286,13 @@ public final class Version implements Comparable<Version> { * Returns the string representation of this version identifier as major.minor.micro.qualifier, * omitting the remaining parts after reaching the first unspecified component. * Unspecified version component is equivalent to 0 (or the empty string for qualifier). + * <p> + * The string representation of a Version specified here is a part of the API and will never change. */ + @Override public String toString() { return stringValue; } + @Override public int hashCode() { return stringValue.hashCode(); } /** Returns whether this equals the empty version */ @@ -306,8 +312,9 @@ public final class Version implements Comparable<Version> { * <code>Version</code> and is equal to this object; * <code>false</code> otherwise. */ + @Override public boolean equals(Object object) { - if (!(object instanceof Version)) return false; + if ( ! (object instanceof Version)) return false; Version other = (Version) object; if (this.major != other.major) return false; if (this.minor != other.minor) return false; @@ -317,8 +324,8 @@ public final class Version implements Comparable<Version> { @SuppressWarnings("unused") private boolean equals(Object o1, Object o2) { - if (o1==null && o2==null) return true; - if (o1==null || o2==null) return false; + if (o1 == null && o2 == null) return true; + if (o1 == null || o2 == null) return false; return o1.equals(o2); } @@ -345,6 +352,7 @@ public final class Version implements Comparable<Version> { * less than, equal to, or greater than the specified <code>Version</code> object. * @throws ClassCastException if the specified object is not a <code>Version</code>. */ + @Override public int compareTo(Version other) { if (other == this) return 0; diff --git a/component/src/main/java/com/yahoo/component/VersionSpecification.java b/component/src/main/java/com/yahoo/component/VersionSpecification.java index c926df4a80b..c484c1f80c0 100644 --- a/component/src/main/java/com/yahoo/component/VersionSpecification.java +++ b/component/src/main/java/com/yahoo/component/VersionSpecification.java @@ -21,7 +21,6 @@ package com.yahoo.component; * @author arnej27959 * @author bratseth */ - public final class VersionSpecification implements Comparable<VersionSpecification> { private Integer major = null; diff --git a/config-application-package/src/main/java/com/yahoo/config/model/application/provider/FilesApplicationPackage.java b/config-application-package/src/main/java/com/yahoo/config/model/application/provider/FilesApplicationPackage.java index 1724bad765f..5ec30f71e7b 100644 --- a/config-application-package/src/main/java/com/yahoo/config/model/application/provider/FilesApplicationPackage.java +++ b/config-application-package/src/main/java/com/yahoo/config/model/application/provider/FilesApplicationPackage.java @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config.model.application.provider; +import com.yahoo.component.Version; import com.yahoo.component.Vtag; import com.yahoo.config.application.ConfigDefinitionDir; import com.yahoo.config.application.Xml; @@ -12,7 +13,6 @@ import com.yahoo.config.application.api.UnparsedConfigDefinition; import com.yahoo.config.codegen.DefParser; import com.yahoo.config.application.api.ApplicationFile; import com.yahoo.config.application.api.ApplicationPackage; -import com.yahoo.config.provision.Version; import com.yahoo.config.provision.Zone; import com.yahoo.path.Path; import com.yahoo.io.HexDump; @@ -45,7 +45,6 @@ import java.security.MessageDigest; import java.util.*; import java.util.jar.JarFile; import java.util.logging.Logger; -import java.util.stream.Collectors; import static com.yahoo.text.Lowercase.toLowerCase; @@ -571,7 +570,7 @@ public class FilesApplicationPackage implements ApplicationPackage { return appDir.getCanonicalFile(); } - public static ApplicationMetaData readMetaData(File appDir) { + private static ApplicationMetaData readMetaData(File appDir) { ApplicationMetaData defaultMetaData = new ApplicationMetaData(appDir, "n/a", "n/a", 0l, false, "", 0l, 0l); File metaFile = new File(appDir, META_FILE_NAME); if (!metaFile.exists()) { @@ -642,13 +641,12 @@ public class FilesApplicationPackage implements ApplicationPackage { @Override public void validateXML() throws IOException { - validateXML(Optional.empty()); + validateXMLFor(Optional.empty()); } @Override - public void validateXML(Optional<Version> vespaVersion) throws IOException { - com.yahoo.component.Version modelVersion = - vespaVersion.map(v -> new com.yahoo.component.Version(vespaVersion.toString())).orElse(Vtag.currentVersion); + public void validateXMLFor(Optional<Version> vespaVersion) throws IOException { + Version modelVersion = vespaVersion.orElse(Vtag.currentVersion); ApplicationPackageXmlFilesValidator validator = ApplicationPackageXmlFilesValidator.create(appDir, modelVersion); validator.checkApplication(); validator.checkIncludedDirs(this); diff --git a/config-model-api/src/main/java/com/yahoo/config/application/api/ApplicationPackage.java b/config-model-api/src/main/java/com/yahoo/config/application/api/ApplicationPackage.java index c6e44e3aef3..6b49ea0c172 100644 --- a/config-model-api/src/main/java/com/yahoo/config/application/api/ApplicationPackage.java +++ b/config-model-api/src/main/java/com/yahoo/config/application/api/ApplicationPackage.java @@ -2,7 +2,7 @@ package com.yahoo.config.application.api; import com.yahoo.config.provision.AllocatedHosts; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.config.provision.Zone; import com.yahoo.io.IOUtils; import com.yahoo.io.reader.NamedReader; @@ -27,6 +27,7 @@ import java.util.Map; import java.util.Optional; import java.util.jar.JarEntry; import java.util.jar.JarFile; +import java.util.stream.Collectors; /** * Represents an application package, that is, used as input when creating a VespaModel and as @@ -184,7 +185,17 @@ public interface ApplicationPackage { Optional<Reader> getDeployment(); Optional<Reader> getValidationOverrides(); - List<ComponentInfo> getComponentsInfo(Version vespaVersion); + /** @deprecated do not override or call. Use the other Version class */ + @Deprecated + default List<ComponentInfo> getComponentsInfo(com.yahoo.config.provision.Version vespaVersion) { + return getComponentsInfo(vespaVersion.toVersion()); + } + + // TODO: Remove the default implementation after December 2018 + @SuppressWarnings("deprecation") + default List<ComponentInfo> getComponentsInfo(Version vespaVersion) { + return getComponentsInfo(com.yahoo.config.provision.Version.from(vespaVersion)); + } /** * Reads a ranking expression from file to a string and returns it. @@ -237,7 +248,13 @@ public interface ApplicationPackage { throw new UnsupportedOperationException("This application package cannot validate XML"); } - default void validateXML(Optional<Version> vespaVersion) throws IOException { + /** @deprecated do not override or call. Use the other Version class */ + @Deprecated + default void validateXML(Optional<com.yahoo.config.provision.Version> vespaVersion) throws IOException { + validateXMLFor(vespaVersion.map(com.yahoo.config.provision.Version::toVersion)); + } + + default void validateXMLFor(Optional<Version> vespaVersion) throws IOException { throw new UnsupportedOperationException("This application package cannot validate XML"); } @@ -252,7 +269,7 @@ public interface ApplicationPackage { */ // TODO: Remove on Vespa 7 @Deprecated - default Map<Version, AllocatedHosts> getProvisionInfoMap() { + default Map<com.yahoo.config.provision.Version, AllocatedHosts> getProvisionInfoMap() { return Collections.emptyMap(); } @@ -261,7 +278,16 @@ public interface ApplicationPackage { return Optional.empty(); } - default Map<Version, FileRegistry> getFileRegistryMap() { + /** @deprecated do not override or call. Use getFileRegistries */ + @Deprecated + default Map<com.yahoo.config.provision.Version, FileRegistry> getFileRegistryMap() { + return getFileRegistries().entrySet() + .stream() + .collect(Collectors.toMap(e -> com.yahoo.config.provision.Version.from(e.getKey()), + e -> e.getValue())); + } + + default Map<Version, FileRegistry> getFileRegistries() { return Collections.emptyMap(); } diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/ModelFactory.java b/config-model-api/src/main/java/com/yahoo/config/model/api/ModelFactory.java index b2d9244cc9d..23782162725 100644 --- a/config-model-api/src/main/java/com/yahoo/config/model/api/ModelFactory.java +++ b/config-model-api/src/main/java/com/yahoo/config/model/api/ModelFactory.java @@ -1,7 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config.model.api; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; /** * Factory for config models. @@ -13,7 +13,14 @@ public interface ModelFactory { * * @return the version of a {@link Model} instance that this factory can create. */ - Version getVersion(); + @SuppressWarnings("deprecation") + default Version version() { // TODO: Remove this default implementationm after December 2018 + return getVersion().toVersion(); + } + + /** @deprecated use and override version(). TODO: Remove this method after December 2018 */ + @Deprecated + default com.yahoo.config.provision.Version getVersion() { return com.yahoo.config.provision.Version.from(version()); } /** * Creates an instance of a {@link Model}. The resulting instance will be used to serve config. No model @@ -34,4 +41,5 @@ public interface ModelFactory { * @return a {@link ModelCreateResult} instance. */ ModelCreateResult createAndValidateModel(ModelContext modelContext, ValidationParameters validationParameters); + } diff --git a/config-model/src/main/java/com/yahoo/config/model/ApplicationConfigProducerRoot.java b/config-model/src/main/java/com/yahoo/config/model/ApplicationConfigProducerRoot.java index da79e34b3ad..af9eba92a98 100644 --- a/config-model/src/main/java/com/yahoo/config/model/ApplicationConfigProducerRoot.java +++ b/config-model/src/main/java/com/yahoo/config/model/ApplicationConfigProducerRoot.java @@ -1,10 +1,14 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config.model; -import com.yahoo.cloud.config.*; +import com.yahoo.cloud.config.ApplicationIdConfig; +import com.yahoo.cloud.config.ClusterListConfig; +import com.yahoo.cloud.config.ModelConfig; +import com.yahoo.cloud.config.SlobroksConfig; +import com.yahoo.cloud.config.ZookeepersConfig; import com.yahoo.config.model.deploy.DeployState; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.vespa.config.content.LoadTypeConfig; import com.yahoo.cloud.config.ModelConfig.Hosts; import com.yahoo.cloud.config.ModelConfig.Hosts.Services; @@ -18,7 +22,12 @@ import com.yahoo.messagebus.MessagebusConfig; import com.yahoo.vespa.configmodel.producers.DocumentManager; import com.yahoo.vespa.configmodel.producers.DocumentTypes; import com.yahoo.vespa.documentmodel.DocumentModel; -import com.yahoo.vespa.model.*; +import com.yahoo.vespa.model.ConfigProducer; +import com.yahoo.vespa.model.HostResource; +import com.yahoo.vespa.model.HostSystem; +import com.yahoo.vespa.model.PortsMeta; +import com.yahoo.vespa.model.Service; +import com.yahoo.vespa.model.VespaModel; import com.yahoo.vespa.model.admin.Admin; import com.yahoo.vespa.model.clients.Clients; import com.yahoo.vespa.model.content.cluster.ContentCluster; @@ -204,7 +213,7 @@ public class ApplicationConfigProducerRoot extends AbstractConfigProducer<Abstra @Override public void getConfig(ModelConfig.Builder builder) { - builder.vespaVersion(vespaVersion.toSerializedForm()); + builder.vespaVersion(vespaVersion.toFullString()); for (HostResource modelHost : getHostSystem().getHosts()) { builder.hosts(new Hosts.Builder() .name(modelHost.getHostname()) @@ -279,4 +288,5 @@ public class ApplicationConfigProducerRoot extends AbstractConfigProducer<Abstra builder.application(applicationId.application().value()); builder.instance(applicationId.instance().value()); } + } diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployProperties.java b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployProperties.java index 9d9a19bfbd6..626b5bfbf5c 100644 --- a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployProperties.java +++ b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployProperties.java @@ -4,7 +4,7 @@ package com.yahoo.config.model.deploy; import com.yahoo.config.model.api.ConfigServerSpec; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.HostName; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import java.net.URI; import java.util.ArrayList; @@ -104,7 +104,7 @@ public class DeployProperties { private URI ztsUrl; private String athenzDnsSuffix; private boolean hostedVespa = false; - private Version vespaVersion = Version.fromIntValues(1, 0, 0); + private Version vespaVersion = new Version(1, 0, 0); private boolean isBootstrap = false; private boolean isFirstTimeDeployment = false; private boolean useDedicatedNodeForLogserver = false; diff --git a/config-model/src/main/java/com/yahoo/config/model/test/MockApplicationPackage.java b/config-model/src/main/java/com/yahoo/config/model/test/MockApplicationPackage.java index 4442b42bb88..ca6bdee82cf 100644 --- a/config-model/src/main/java/com/yahoo/config/model/test/MockApplicationPackage.java +++ b/config-model/src/main/java/com/yahoo/config/model/test/MockApplicationPackage.java @@ -5,13 +5,14 @@ import com.yahoo.config.application.api.ApplicationMetaData; import com.yahoo.config.application.api.ComponentInfo; import com.yahoo.config.application.api.UnparsedConfigDefinition; import com.yahoo.config.application.api.ApplicationFile; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.io.IOUtils; import com.yahoo.path.Path; import com.yahoo.io.reader.NamedReader; import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.search.query.profile.config.QueryProfileXMLReader; -import com.yahoo.searchdefinition.*; +import com.yahoo.searchdefinition.RankProfileRegistry; +import com.yahoo.searchdefinition.SearchBuilder; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.config.ConfigDefinitionKey; import com.yahoo.config.application.api.ApplicationPackage; @@ -25,7 +26,13 @@ import java.io.InputStream; import java.io.Reader; import java.io.StringReader; import java.io.UncheckedIOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Optional; import java.util.stream.Collectors; /** diff --git a/config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java b/config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java index 07ebece3ea9..d3f4a122b1e 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java @@ -20,7 +20,7 @@ import com.yahoo.config.model.application.provider.ApplicationPackageXmlFilesVal import com.yahoo.config.model.builder.xml.ConfigModelBuilder; import com.yahoo.config.model.deploy.DeployProperties; import com.yahoo.config.model.deploy.DeployState; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.config.provision.Zone; import com.yahoo.vespa.config.VespaVersion; import com.yahoo.vespa.model.application.validation.Validation; @@ -54,7 +54,7 @@ public class VespaModelFactory implements ModelFactory { public VespaModelFactory(ComponentRegistry<ConfigModelPlugin> pluginRegistry, ComponentRegistry<MlModelImporter> modelImporters, Zone zone) { - this.version = Version.fromIntValues(VespaVersion.major, VespaVersion.minor, VespaVersion.micro); + this.version = new Version(VespaVersion.major, VespaVersion.minor, VespaVersion.micro); List<ConfigModelBuilder> modelBuilders = new ArrayList<>(); for (ConfigModelPlugin plugin : pluginRegistry.allComponents()) { if (plugin instanceof ConfigModelBuilder) { @@ -71,7 +71,7 @@ public class VespaModelFactory implements ModelFactory { this(configModelRegistry, Clock.systemUTC()); } public VespaModelFactory(ConfigModelRegistry configModelRegistry, Clock clock) { - this(Version.fromIntValues(VespaVersion.major, VespaVersion.minor, VespaVersion.micro), configModelRegistry, clock); + this(new Version(VespaVersion.major, VespaVersion.minor, VespaVersion.micro), configModelRegistry, clock); } public VespaModelFactory(Version version, ConfigModelRegistry configModelRegistry, Clock clock) { this.version = version; @@ -88,7 +88,7 @@ public class VespaModelFactory implements ModelFactory { /** Returns the version this model is build for */ @Override - public Version getVersion() { return version; } + public Version version() { return version; } @Override public Model createModel(ModelContext modelContext) { @@ -157,7 +157,7 @@ public class VespaModelFactory implements ModelFactory { .athenzDnsSuffix(properties.athenzDnsSuffix()) .multitenant(properties.multitenant()) .hostedVespa(properties.hostedVespa()) - .vespaVersion(getVersion()) + .vespaVersion(version()) .isBootstrap(properties.isBootstrap()) .isFirstTimeDeployment(properties.isFirstTimeDeployment()) .useDedicatedNodeForLogserver(properties.useDedicatedNodeForLogserver()) diff --git a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/VespaDomBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/VespaDomBuilder.java index a6d3809ff64..7e98804370f 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/VespaDomBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/VespaDomBuilder.java @@ -235,10 +235,11 @@ public class VespaDomBuilder extends VespaModelBuilder { @Override protected ApplicationConfigProducerRoot doBuild(DeployState deployState, AbstractConfigProducer parent, Element producerSpec) { - ApplicationConfigProducerRoot root = new ApplicationConfigProducerRoot(parent, name, - deployState.getDocumentModel(), - deployState.getProperties().vespaVersion(), - deployState.getProperties().applicationId()); + ApplicationConfigProducerRoot root = new ApplicationConfigProducerRoot(parent, + name, + deployState.getDocumentModel(), + deployState.getProperties().vespaVersion(), + deployState.getProperties().applicationId()); root.setHostSystem(new HostSystem(root, "hosts", deployState.getProvisioner(), deployState.getDeployLogger())); new Client(root); return root; diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/AllocatedHosts.java b/config-provisioning/src/main/java/com/yahoo/config/provision/AllocatedHosts.java index 0f30575d5aa..4c1798c549f 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/AllocatedHosts.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/AllocatedHosts.java @@ -56,10 +56,10 @@ public class AllocatedHosts { cursor.setString(hostSpecHostName, host.hostname()); host.membership().ifPresent(membership -> { cursor.setString(hostSpecMembership, membership.stringValue()); - cursor.setString(hostSpecVespaVersion, membership.cluster().vespaVersion().toString()); + cursor.setString(hostSpecVespaVersion, membership.cluster().vespaVersion().toFullString()); }); host.flavor().ifPresent(flavor -> cursor.setString(hostSpecFlavor, flavor.name())); - host.version().ifPresent(version -> cursor.setString(hostSpecCurrentVespaVersion, version.toString())); + host.version().ifPresent(version -> cursor.setString(hostSpecCurrentVespaVersion, version.toFullString())); } /** Returns the hosts of this allocation */ diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/Version.java b/config-provisioning/src/main/java/com/yahoo/config/provision/Version.java index 5e40ef70d7d..bd6e7d62833 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/Version.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/Version.java @@ -14,8 +14,10 @@ package com.yahoo.config.provision; * @since 5.39 * Loosely based on component/Version.java * {@link Version} objects are immutable. + * @deprecated use com.yahoo.component.Version */ // TODO: Replace usage of this by com.yahoo.component.Version +@Deprecated public final class Version implements Comparable<Version> { private final int major; @@ -51,6 +53,10 @@ public final class Version implements Comparable<Version> { } } + public com.yahoo.component.Version toVersion() { + return new com.yahoo.component.Version(major, minor, micro); + } + /** * Verifies that the numerical components in a version are legal. * Must be called on construction after the component values are set @@ -94,6 +100,10 @@ public final class Version implements Comparable<Version> { return new Version(versionString); } + public static Version from(com.yahoo.component.Version version) { + return new Version(version.getMajor(), version.getMinor(), version.getMicro()); + } + /** * Returns a string representation of this version identifier, encoded as major.minor.micro */ diff --git a/config/src/main/java/com/yahoo/vespa/config/protocol/VespaVersion.java b/config/src/main/java/com/yahoo/vespa/config/protocol/VespaVersion.java index 8ef202f8f05..c136916f06f 100644 --- a/config/src/main/java/com/yahoo/vespa/config/protocol/VespaVersion.java +++ b/config/src/main/java/com/yahoo/vespa/config/protocol/VespaVersion.java @@ -5,9 +5,9 @@ package com.yahoo.vespa.config.protocol; * A wrapper class for Vespa version * * @author hmusum - * @since 5.39 */ public class VespaVersion { + private final String version; public static VespaVersion fromString(String version) { @@ -39,4 +39,5 @@ public class VespaVersion { public String toString() { return version; } + } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/RequestHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/RequestHandler.java index f23c96db6f2..185958510b6 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/RequestHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/RequestHandler.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.config.server; import java.util.Optional; import java.util.Set; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.vespa.config.ConfigKey; import com.yahoo.vespa.config.GetConfigRequest; import com.yahoo.config.provision.ApplicationId; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelRequestHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelRequestHandler.java index 8458f9f0ddd..d77ca396974 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelRequestHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelRequestHandler.java @@ -5,7 +5,7 @@ import com.google.inject.Inject; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.config.ConfigInstance; import com.yahoo.config.model.api.ConfigDefinitionRepo; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.log.LogLevel; import com.yahoo.vespa.config.ConfigKey; import com.yahoo.vespa.config.GetConfigRequest; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java index 64123420622..0d787895087 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java @@ -5,7 +5,7 @@ import com.yahoo.config.ConfigurationRuntimeException; import com.yahoo.config.model.api.ApplicationInfo; import com.yahoo.config.model.api.Model; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.log.LogLevel; import com.yahoo.vespa.config.ConfigCacheKey; import com.yahoo.vespa.config.ConfigDefinitionKey; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationMapper.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationMapper.java index 0d055d3bfc9..4fe2a018766 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationMapper.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationMapper.java @@ -2,7 +2,7 @@ package com.yahoo.vespa.config.server.application; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import java.time.Instant; import java.util.Collections; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationSet.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationSet.java index b4346498f0c..3444ffc2865 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationSet.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationSet.java @@ -1,9 +1,9 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.application; + import com.yahoo.config.model.api.HostInfo; -import com.yahoo.config.model.api.Model; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import java.time.Instant; import java.util.*; @@ -91,4 +91,5 @@ public final class ApplicationSet { public long getApplicationGeneration() { return generation; } + } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClient.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClient.java index f9f84de1cfb..e5552de41f5 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClient.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClient.java @@ -9,7 +9,7 @@ import com.yahoo.config.application.api.FileRegistry; import com.yahoo.config.application.api.UnparsedConfigDefinition; import com.yahoo.config.model.application.provider.PreGeneratedFileRegistry; import com.yahoo.config.provision.AllocatedHosts; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.io.reader.NamedReader; import com.yahoo.log.LogLevel; import com.yahoo.path.Path; @@ -310,7 +310,7 @@ public class ZooKeeperClient { String exportedRegistry = PreGeneratedFileRegistry.exportRegistry(fileRegistry); configCurator.putData(getZooKeeperAppPath(null).append(ZKApplicationPackage.fileRegistryNode).getAbsolute(), - vespaVersion.toSerializedForm(), + vespaVersion.toFullString(), exportedRegistry); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperDeployer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperDeployer.java index 68c129d1e42..e24d24f0c3f 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperDeployer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperDeployer.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.config.server.deploy; import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.application.api.FileRegistry; import com.yahoo.config.provision.AllocatedHosts; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import java.io.IOException; import java.util.Map; @@ -26,7 +26,7 @@ public class ZooKeeperDeployer { /** * Deploys an application package to zookeeper. initialize() must be called before calling this method. * - * @param applicationPackage The application package to persist. + * @param applicationPackage the application package to persist. * @param fileRegistryMap the file registries to persist. * @param allocatedHosts the provisioning info to persist. * @throws IOException if deploying fails @@ -42,4 +42,5 @@ public class ZooKeeperDeployer { public void cleanup() { zooKeeperClient.cleanupZooKeeper(); } + } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/status/StatusHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/status/StatusHandler.java index 5c0439c0af3..bb752f9b804 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/status/StatusHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/status/StatusHandler.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.config.server.http.status; import com.google.inject.Inject; import com.yahoo.config.model.api.ModelFactory; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.slime.Cursor; @@ -46,8 +46,8 @@ public class StatusHandler extends HttpHandler { Cursor modelVersionsCursor = object.setArray("modelVersions"); componentRegistry.getModelFactoryRegistry().getFactories().stream() - .map(ModelFactory::getVersion) - .map(Version::toString) + .map(ModelFactory::version) + .map(Version::toFullString) .forEach(modelVersionsCursor::addString); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java index b6346677d6b..9871ce2e26b 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java @@ -11,7 +11,7 @@ import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.AllocatedHosts; import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.TenantName; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.log.LogLevel; import com.yahoo.vespa.config.server.ConfigServerSpec; import com.yahoo.vespa.config.server.GlobalComponentRegistry; @@ -51,7 +51,10 @@ public class ActivatedModelsBuilder extends ModelsBuilder<Application> { private final Curator curator; private final DeployLogger logger; - public ActivatedModelsBuilder(TenantName tenant, long appGeneration, SessionZooKeeperClient zkClient, GlobalComponentRegistry globalComponentRegistry) { + public ActivatedModelsBuilder(TenantName tenant, + long appGeneration, + SessionZooKeeperClient zkClient, + GlobalComponentRegistry globalComponentRegistry) { super(globalComponentRegistry.getModelFactoryRegistry(), globalComponentRegistry.getConfigserverConfig(), globalComponentRegistry.getZone(), @@ -70,11 +73,11 @@ public class ActivatedModelsBuilder extends ModelsBuilder<Application> { protected Application buildModelVersion(ModelFactory modelFactory, ApplicationPackage applicationPackage, ApplicationId applicationId, - com.yahoo.component.Version wantedNodeVespaVersion, + Version wantedNodeVespaVersion, Optional<AllocatedHosts> ignored, // Ignored since we have this in the app package for activated models Instant now) { log.log(LogLevel.DEBUG, String.format("Loading model version %s for session %s application %s", - modelFactory.getVersion(), appGeneration, applicationId)); + modelFactory.version(), appGeneration, applicationId)); ModelContext.Properties modelContextProperties = createModelContextProperties(applicationId); ModelContext modelContext = new ModelContextImpl( applicationPackage, @@ -82,16 +85,18 @@ public class ActivatedModelsBuilder extends ModelsBuilder<Application> { permanentApplicationPackage.applicationPackage(), logger, configDefinitionRepo, - getForVersionOrLatest(applicationPackage.getFileRegistryMap(), modelFactory.getVersion()).orElse(new MockFileRegistry()), + getForVersionOrLatest(applicationPackage.getFileRegistries(), modelFactory.version()).orElse(new MockFileRegistry()), createStaticProvisioner(applicationPackage.getAllocatedHosts(), modelContextProperties), modelContextProperties, Optional.empty(), - new com.yahoo.component.Version(modelFactory.getVersion().toString()), + modelFactory.version(), wantedNodeVespaVersion); MetricUpdater applicationMetricUpdater = metrics.getOrCreateMetricUpdater(Metrics.createDimensions(applicationId)); - return new Application(modelFactory.createModel(modelContext), zkClient.loadServerCache(), appGeneration, + return new Application(modelFactory.createModel(modelContext), + zkClient.loadServerCache(), + appGeneration, applicationPackage.getMetaData().isInternalRedeploy(), - modelFactory.getVersion(), + modelFactory.version(), applicationMetricUpdater, applicationId); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelFactoryRegistry.java b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelFactoryRegistry.java index 1c2c9c731d1..b2b5a06b6ea 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelFactoryRegistry.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelFactoryRegistry.java @@ -4,14 +4,14 @@ package com.yahoo.vespa.config.server.modelfactory; import com.google.inject.Inject; import com.yahoo.component.provider.ComponentRegistry; import com.yahoo.config.model.api.ModelFactory; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.vespa.config.server.http.UnknownVespaVersionException; import java.util.*; /** * A registry of model factories. Allows querying for a specific version of a {@link ModelFactory} or - * simply returning all of them. Keeps track of the latest {@link com.yahoo.config.provision.Version} supported. + * simply returning all of them. Keeps track of the latest {@link Version} supported. * * @author Ulf Lilleengen */ @@ -29,7 +29,7 @@ public class ModelFactoryRegistry { throw new IllegalArgumentException("No ModelFactory instances registered, cannot build config models"); } for (ModelFactory factory : modelFactories) { - factories.put(factory.getVersion(), factory); + factories.put(factory.version(), factory); } } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java index 92d4471c41c..19a568d9e01 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java @@ -11,7 +11,7 @@ import com.yahoo.config.provision.AllocatedHosts; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ApplicationLockException; import com.yahoo.config.provision.OutOfCapacityException; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.config.provision.Zone; import com.yahoo.lang.SettableOptional; import com.yahoo.log.LogLevel; @@ -173,14 +173,14 @@ public abstract class ModelsBuilder<MODELRESULT extends ModelResult> { return allApplicationVersions; } - private Set<Version> versionsToBuild(Set<Version> versions, com.yahoo.component.Version wantedVersion, int majorVersion, AllocatedHosts allocatedHosts) { + private Set<Version> versionsToBuild(Set<Version> versions, Version wantedVersion, int majorVersion, AllocatedHosts allocatedHosts) { if (configserverConfig.buildMinimalSetOfConfigModels()) versions = keepThoseUsedOn(allocatedHosts, versions); // Make sure we build wanted version if we are building models for this major version and we are on hosted vespa // If not on hosted vespa, we do not want to try to build this version, since we have only one version (the latest) if (hosted && wantedVersion.getMajor() == majorVersion) - versions.add(Version.fromIntValues(wantedVersion.getMajor(), wantedVersion.getMinor(), wantedVersion.getMicro())); + versions.add(wantedVersion); return versions; } @@ -205,14 +205,13 @@ public abstract class ModelsBuilder<MODELRESULT extends ModelResult> { } private boolean isUsedOn(AllocatedHosts hosts, Version version) { - com.yahoo.component.Version v = new com.yahoo.component.Version(version.toString()); return hosts.getHosts().stream() - .anyMatch(host -> host.version().isPresent() && host.version().get().equals(v)); + .anyMatch(host -> host.version().isPresent() && host.version().get().equals(version)); } protected abstract MODELRESULT buildModelVersion(ModelFactory modelFactory, ApplicationPackage applicationPackage, ApplicationId applicationId, - com.yahoo.component.Version wantedNodeVespaVersion, + Version wantedNodeVespaVersion, Optional<AllocatedHosts> allocatedHosts, Instant now); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/PreparedModelsBuilder.java b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/PreparedModelsBuilder.java index 4c43abf5faa..9cacb78e53c 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/PreparedModelsBuilder.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/PreparedModelsBuilder.java @@ -16,7 +16,7 @@ import com.yahoo.config.model.api.ValidationParameters.IgnoreValidationErrors; import com.yahoo.config.model.application.provider.FilesApplicationPackage; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.AllocatedHosts; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.log.LogLevel; import com.yahoo.vespa.config.server.application.Application; import com.yahoo.vespa.config.server.application.ApplicationSet; @@ -86,7 +86,7 @@ public class PreparedModelsBuilder extends ModelsBuilder<PreparedModelsBuilder.P com.yahoo.component.Version wantedNodeVespaVersion, Optional<AllocatedHosts> allocatedHosts, Instant now) { - Version modelVersion = modelFactory.getVersion(); + Version modelVersion = modelFactory.version(); log.log(LogLevel.DEBUG, "Building model " + modelVersion + " for " + applicationId); FileDistributionProvider fileDistributionProvider = fileDistributionFactory.createProvider(context.getServerDBSessionDir()); @@ -101,7 +101,7 @@ public class PreparedModelsBuilder extends ModelsBuilder<PreparedModelsBuilder.P createHostProvisioner(allocatedHosts), properties, getAppDir(applicationPackage), - new com.yahoo.component.Version(modelVersion.toString()), + modelVersion, wantedNodeVespaVersion); log.log(LogLevel.DEBUG, "Create and validate model " + modelVersion + " for " + applicationId); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java index 55d5321c93f..b291a828bc0 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.config.server.rpc; import com.yahoo.cloud.config.SentinelConfig; import com.yahoo.config.provision.TenantName; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.jrt.Request; import com.yahoo.log.LogLevel; import com.yahoo.net.HostName; @@ -140,7 +140,7 @@ class GetConfigProcessor implements Runnable { } private static String getPrintableVespaVersion(Optional<Version> vespaVersion) { - return (vespaVersion.isPresent() ? vespaVersion.get().toString() : "LATEST"); + return (vespaVersion.isPresent() ? vespaVersion.get().toFullString() : "LATEST"); } private void returnEmpty(JRTServerConfigRequest request) { diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java index 048000f31c4..1cae6ac2244 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java @@ -8,7 +8,7 @@ import com.yahoo.config.FileReference; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.HostLivenessTracker; import com.yahoo.config.provision.TenantName; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.jrt.Acceptor; import com.yahoo.jrt.DataValue; import com.yahoo.jrt.Int32Value; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/PrepareParams.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/PrepareParams.java index b44896ecb89..a5e74d3b85f 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/PrepareParams.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/PrepareParams.java @@ -103,8 +103,8 @@ public final class PrepareParams { return this; } - public Builder vespaVersion(com.yahoo.config.provision.Version vespaVersion) { - this.vespaVersion = Optional.ofNullable(Version.fromString(vespaVersion.toSerializedForm())); + public Builder vespaVersion(Version vespaVersion) { + this.vespaVersion = Optional.ofNullable(vespaVersion); return this; } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java index 9fdd94c2fb4..fd4628baa85 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java @@ -15,7 +15,7 @@ import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.OutOfCapacityException; import com.yahoo.config.provision.Rotation; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.config.provision.Zone; import com.yahoo.lang.SettableOptional; import com.yahoo.log.LogLevel; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandler.java index f30a58cffea..a341061bd9a 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandler.java @@ -2,11 +2,16 @@ package com.yahoo.vespa.config.server.tenant; import java.time.Clock; -import java.util.*; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Optional; +import java.util.Set; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.log.LogLevel; -import com.yahoo.vespa.config.*; +import com.yahoo.vespa.config.ConfigKey; +import com.yahoo.vespa.config.GetConfigRequest; import com.yahoo.vespa.config.protocol.ConfigResponse; import com.yahoo.vespa.config.server.NotFoundException; import com.yahoo.vespa.config.server.application.ApplicationMapper; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/version/VersionState.java b/configserver/src/main/java/com/yahoo/vespa/config/server/version/VersionState.java index 31abe81a313..641aa31a6b7 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/version/VersionState.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/version/VersionState.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.config.server.version; import com.google.inject.Inject; import com.yahoo.cloud.config.ConfigserverConfig; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.io.IOUtils; import com.yahoo.vespa.defaults.Defaults; @@ -36,7 +36,7 @@ public class VersionState { public void saveNewVersion() { try (FileWriter writer = new FileWriter(versionFile)) { - writer.write(currentVersion().toSerializedForm()); + writer.write(currentVersion().toFullString()); } catch (IOException e) { throw new RuntimeException(e); } @@ -46,12 +46,12 @@ public class VersionState { try (FileReader reader = new FileReader(versionFile)) { return Version.fromString(IOUtils.readAll(reader)); } catch (Exception e) { - return Version.fromIntValues(0, 0, 0); // Use an old value to signal we don't know + return new Version(0, 0, 0); // Use an old value to signal we don't know } } public Version currentVersion() { - return Version.fromIntValues(VespaVersion.major, VespaVersion.minor, VespaVersion.micro); + return new Version(VespaVersion.major, VespaVersion.minor, VespaVersion.micro); } @Override diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java index e9b4d6ac1aa..5c40f592a77 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java @@ -2,6 +2,7 @@ package com.yahoo.vespa.config.server.zookeeper; import com.google.common.base.Joiner; +import com.yahoo.component.Version; import com.yahoo.config.application.api.ApplicationMetaData; import com.yahoo.config.application.api.ComponentInfo; import com.yahoo.config.application.api.FileRegistry; @@ -9,7 +10,7 @@ import com.yahoo.config.application.api.UnparsedConfigDefinition; import com.yahoo.config.codegen.DefParser; import com.yahoo.config.application.api.ApplicationFile; import com.yahoo.config.application.api.ApplicationPackage; -import com.yahoo.config.model.application.provider.*; +import com.yahoo.config.model.application.provider.PreGeneratedFileRegistry; import com.yahoo.config.provision.NodeFlavors; import com.yahoo.config.provision.AllocatedHosts; import com.yahoo.io.IOUtils; @@ -24,14 +25,12 @@ import java.io.File; import java.io.Reader; import java.io.StringReader; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; /** * Represents an application residing in zookeeper. @@ -42,9 +41,9 @@ public class ZKApplicationPackage implements ApplicationPackage { private ZKLiveApp liveApp; - private final Map<com.yahoo.config.provision.Version, PreGeneratedFileRegistry> fileRegistryMap = new HashMap<>(); + private final Map<Version, PreGeneratedFileRegistry> fileRegistryMap = new HashMap<>(); private final Optional<AllocatedHosts> allocatedHosts; - private static final com.yahoo.config.provision.Version legacyVersion = com.yahoo.config.provision.Version.fromIntValues(0, 0, 0); + private static final Version legacyVersion = new Version(0, 0, 0); public static final String fileRegistryNode = "fileregistry"; public static final String allocatedHostsNode = "allocatedHosts"; @@ -82,7 +81,7 @@ public class ZKApplicationPackage implements ApplicationPackage { fileRegistryMap.put(legacyVersion, importFileRegistry(fileRegistryNode)); } else { fileRegistryNodes.forEach(version -> - fileRegistryMap.put(com.yahoo.config.provision.Version.fromString(version), + fileRegistryMap.put(Version.fromString(version), importFileRegistry(Joiner.on("/").join(fileRegistryNode, version)))); } } @@ -148,11 +147,11 @@ public class ZKApplicationPackage implements ApplicationPackage { } @Override - public Map<com.yahoo.config.provision.Version, FileRegistry> getFileRegistryMap() { + public Map<Version, FileRegistry> getFileRegistries() { return Collections.unmodifiableMap(fileRegistryMap); } - private Optional<PreGeneratedFileRegistry> getPreGeneratedFileRegistry(com.yahoo.config.provision.Version vespaVersion) { + private Optional<PreGeneratedFileRegistry> getPreGeneratedFileRegistry(Version vespaVersion) { // Assumes at least one file registry, which we always have. Optional<PreGeneratedFileRegistry> fileRegistry = Optional.ofNullable(fileRegistryMap.get(vespaVersion)); if ( ! fileRegistry.isPresent()) { @@ -180,8 +179,8 @@ public class ZKApplicationPackage implements ApplicationPackage { List<String> allDefs = liveApp.getChildren(ConfigCurator.DEFCONFIGS_ZK_SUBPATH); - for (final String nodeName : allDefs) { - final ConfigDefinitionKey key = ConfigUtils.createConfigDefinitionKeyFromZKString(nodeName); + for (String nodeName : allDefs) { + ConfigDefinitionKey key = ConfigUtils.createConfigDefinitionKeyFromZKString(nodeName); ret.put(key, new UnparsedConfigDefinition() { @Override public ConfigDefinition parse() { @@ -240,7 +239,7 @@ public class ZKApplicationPackage implements ApplicationPackage { } @Override - public List<ComponentInfo> getComponentsInfo(com.yahoo.config.provision.Version vespaVersion) { + public List<ComponentInfo> getComponentsInfo(Version vespaVersion) { List<ComponentInfo> components = new ArrayList<>(); PreGeneratedFileRegistry fileRegistry = getPreGeneratedFileRegistry(vespaVersion).get(); for (String path : fileRegistry.getPaths()) { diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java index 205b69d1a1e..bc7c090482e 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java @@ -9,7 +9,7 @@ import com.yahoo.config.model.provision.InMemoryProvisioner; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.RegionName; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.config.provision.Zone; import com.yahoo.container.handler.VipStatus; import com.yahoo.container.jdisc.config.HealthMonitorConfig; diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ModelFactoryRegistryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ModelFactoryRegistryTest.java index 8aa75001482..986e9f5603d 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/ModelFactoryRegistryTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ModelFactoryRegistryTest.java @@ -7,7 +7,7 @@ import com.yahoo.config.model.api.ModelContext; import com.yahoo.config.model.api.ModelCreateResult; import com.yahoo.config.model.api.ModelFactory; import com.yahoo.config.model.api.ValidationParameters; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.vespa.config.server.http.UnknownVespaVersionException; import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry; import org.junit.Test; @@ -31,10 +31,10 @@ public class ModelFactoryRegistryTest { @Test public void testThatLatestVersionIsSelected() { - Version versionA = Version.fromIntValues(5, 38, 4); - Version versionB = Version.fromIntValues(5, 58, 1); - Version versionC = Version.fromIntValues(5, 48, 44); - Version versionD = Version.fromIntValues(5, 18, 44); + Version versionA = new Version(5, 38, 4); + Version versionB = new Version(5, 58, 1); + Version versionC = new Version(5, 48, 44); + Version versionD = new Version(5, 18, 44); TestFactory a = new TestFactory(versionA); TestFactory b = new TestFactory(versionB); TestFactory c = new TestFactory(versionC); @@ -53,10 +53,10 @@ public class ModelFactoryRegistryTest { @Test public void testThatAllFactoriesAreReturned() { - TestFactory a = new TestFactory(Version.fromIntValues(5, 38, 4)); - TestFactory b = new TestFactory(Version.fromIntValues(5, 58, 1)); - TestFactory c = new TestFactory(Version.fromIntValues(5, 48, 44)); - TestFactory d = new TestFactory(Version.fromIntValues(5, 18, 44)); + TestFactory a = new TestFactory(new Version(5, 38, 4)); + TestFactory b = new TestFactory(new Version(5, 58, 1)); + TestFactory c = new TestFactory(new Version(5, 48, 44)); + TestFactory d = new TestFactory(new Version(5, 18, 44)); ModelFactoryRegistry registry = new ModelFactoryRegistry(Arrays.asList(a, b, c, d)); assertThat(registry.getFactories().size(), is(4)); assertTrue(registry.getFactories().contains(a)); @@ -67,11 +67,12 @@ public class ModelFactoryRegistryTest { @Test(expected = UnknownVespaVersionException.class) public void testThatUnknownVersionGivesError() { - ModelFactoryRegistry registry = new ModelFactoryRegistry(Arrays.asList(new TestFactory(Version.fromIntValues(1, 2, 3)))); - registry.getFactory(Version.fromIntValues(3, 2, 1)); + ModelFactoryRegistry registry = new ModelFactoryRegistry(Arrays.asList(new TestFactory(new Version(1, 2, 3)))); + registry.getFactory(new Version(3, 2, 1)); } private static class TestFactory implements ModelFactory { + private final Version version; public TestFactory(Version version) { @@ -79,7 +80,7 @@ public class ModelFactoryRegistryTest { } @Override - public Version getVersion() { + public Version version() { return version; } @@ -93,4 +94,5 @@ public class ModelFactoryRegistryTest { return null; } } + } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelRequestHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelRequestHandlerTest.java index ebfb8dc622c..3288b418bb1 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelRequestHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelRequestHandlerTest.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.config.server; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.config.model.application.provider.FilesApplicationPackage; import com.yahoo.config.provision.NodeFlavors; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.config.provisioning.FlavorsConfig; import com.yahoo.vespa.config.server.application.Application; import com.yahoo.config.provision.ApplicationId; @@ -124,7 +124,7 @@ public class SuperModelRequestHandlerTest { private static class TestApplication extends Application { TestApplication(VespaModel vespaModel, ServerCache cache, long appGeneration, ApplicationId app) { - super(vespaModel, cache, appGeneration, false, Version.fromIntValues(1, 2, 3), MetricUpdater.createTestUpdater(), app); + super(vespaModel, cache, appGeneration, false, new Version(1, 2, 3), MetricUpdater.createTestUpdater(), app); } } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationMapperTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationMapperTest.java index 233c0e99ed8..284bb716a6e 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationMapperTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationMapperTest.java @@ -7,7 +7,7 @@ import java.util.Arrays; import java.util.Optional; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.vespa.config.server.ModelStub; import com.yahoo.vespa.config.server.NotFoundException; import com.yahoo.vespa.config.server.monitoring.MetricUpdater; @@ -66,4 +66,5 @@ public class ApplicationMapperTest { Optional.of(vespaVersions.get(1)), Instant.now()); } + } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationSetTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationSetTest.java index 94bb81021dc..8ee6a82bd1d 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationSetTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationSetTest.java @@ -8,7 +8,7 @@ import java.util.List; import java.util.Optional; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.vespa.config.server.ModelStub; import com.yahoo.vespa.config.server.monitoring.MetricUpdater; import org.junit.Before; diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java index 97a229750a1..cc30ef09878 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java @@ -10,7 +10,7 @@ import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ApplicationName; import com.yahoo.config.provision.InstanceName; import com.yahoo.config.provision.TenantName; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.jrt.Request; import com.yahoo.vespa.config.ConfigDefinitionKey; import com.yahoo.vespa.config.ConfigKey; @@ -53,7 +53,7 @@ public class ApplicationTest { ApplicationId appId = ApplicationId.from(TenantName.defaultName(), ApplicationName.from("foobar"), InstanceName.defaultName()); ServerCache cache = new ServerCache(); - Version vespaVersion = Version.fromIntValues(1, 2, 3); + Version vespaVersion = new Version(1, 2, 3); Application app = new Application(new ModelStub(), cache, 1337L, false, vespaVersion, MetricUpdater.createTestUpdater(), appId); assertThat(app.getApplicationGeneration(), is(1337l)); assertNotNull(app.getModel()); @@ -73,7 +73,7 @@ public class ApplicationTest { ServerCache cache = createCacheAndAddContent(); VespaModel model = new VespaModel(FilesApplicationPackage.fromFile(testApp)); ApplicationId applicationId = new ApplicationId.Builder().tenant("foo").applicationName("foo").build(); - handler = new Application(model, cache, 1L, false, Version.fromIntValues(1, 2, 3), + handler = new Application(model, cache, 1L, false, new Version(1, 2, 3), new MetricUpdater(Metrics.createTestMetrics(), Metrics.createDimensions(applicationId)), applicationId); } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ConfigConvergenceCheckerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ConfigConvergenceCheckerTest.java index fdea0fced67..871182d75d9 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ConfigConvergenceCheckerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ConfigConvergenceCheckerTest.java @@ -7,7 +7,7 @@ import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ApplicationName; import com.yahoo.config.provision.InstanceName; import com.yahoo.config.provision.TenantName; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.slime.Slime; import com.yahoo.vespa.config.SlimeUtils; @@ -65,7 +65,7 @@ public class ConfigConvergenceCheckerTest { new ServerCache(), 3, false, - Version.fromIntValues(0, 0, 0), + new Version(0, 0, 0), MetricUpdater.createTestUpdater(), appId); checker = new ConfigConvergenceChecker(); } @@ -139,7 +139,7 @@ public class ConfigConvergenceCheckerTest { ); Application application = new Application(model, new ServerCache(), 4, false, - Version.fromIntValues(0, 0, 0), + new Version(0, 0, 0), MetricUpdater.createTestUpdater(), appId); wireMock.stubFor(get(urlEqualTo("/state/v1/config")).willReturn(okJson("{\"config\":{\"generation\":4}}"))); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/FileDistributionStatusTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/FileDistributionStatusTest.java index c2ddec7e795..0c27066dd6b 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/FileDistributionStatusTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/FileDistributionStatusTest.java @@ -6,7 +6,7 @@ import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ApplicationName; import com.yahoo.config.provision.InstanceName; import com.yahoo.config.provision.TenantName; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.vespa.config.server.ServerCache; import com.yahoo.vespa.config.server.http.SessionHandlerTest; @@ -165,7 +165,7 @@ public class FileDistributionStatusTest { new ServerCache(), 3, false, - Version.fromIntValues(0, 0, 0), + new Version(0, 0, 0), MetricUpdater.createTestUpdater(), appId); } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java index 952d757be53..c96113b9462 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java @@ -23,7 +23,7 @@ import com.yahoo.config.provision.AllocatedHosts; import com.yahoo.config.provision.ProvisionLogger; import com.yahoo.config.provision.Provisioner; import com.yahoo.config.provision.TenantName; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.config.provision.Zone; import com.yahoo.transaction.NestedTransaction; import com.yahoo.vespa.config.server.ApplicationRepository; @@ -264,7 +264,7 @@ public class DeployTester { } @Override - public Version getVersion() { return version; } + public Version version() { return version; } @Override public Model createModel(ModelContext modelContext) { @@ -305,7 +305,7 @@ public class DeployTester { public int creationCount() { return creationCount; } @Override - public Version getVersion() { return wrapped.getVersion(); } + public Version version() { return wrapped.version(); } @Override public Model createModel(ModelContext modelContext) { diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java index e2a2bcd830e..c6acbd93241 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java @@ -16,7 +16,7 @@ import com.yahoo.config.model.provision.InMemoryProvisioner; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.RegionName; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.config.provision.Zone; import com.yahoo.test.ManualClock; @@ -210,7 +210,7 @@ public class HostedDeployTest { ManualClock clock = new ManualClock("2016-10-09T00:00:00"); List<ModelFactory> modelFactories = new ArrayList<>(); modelFactories.add(DeployTester.createModelFactory(clock)); - modelFactories.add(DeployTester.createFailingModelFactory(Version.fromIntValues(1, 0, 0))); // older than default + modelFactories.add(DeployTester.createFailingModelFactory(new Version(1, 0, 0))); // older than default DeployTester tester = new DeployTester(modelFactories, createConfigserverConfig()); tester.deployApp("src/test/apps/validationOverride/", clock.instant()); @@ -254,8 +254,8 @@ public class HostedDeployTest { new ServiceInfo("serviceName", "serviceType", null, new HashMap<>(), "configId", "hostName")); List<ModelFactory> modelFactories = Arrays.asList( - new ConfigChangeActionsModelFactory(Version.fromIntValues(6, 1, 0), new MockRestartAction("change", services)), - new ConfigChangeActionsModelFactory(Version.fromIntValues(6, 2, 0), new MockRestartAction("other change", services))); + new ConfigChangeActionsModelFactory(new Version(6, 1, 0), new MockRestartAction("change", services)), + new ConfigChangeActionsModelFactory(new Version(6, 2, 0), new MockRestartAction("other change", services))); DeployTester tester = new DeployTester(modelFactories, createConfigserverConfig(), Clock.systemUTC(), provisioner); PrepareResult prepareResult = tester.deployApp("src/test/apps/hosted/", "6.2.0", Instant.now()); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/RedeployTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/RedeployTest.java index d3380157fb4..adf3ba19fe3 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/RedeployTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/RedeployTest.java @@ -5,7 +5,7 @@ import com.yahoo.config.model.api.ModelFactory; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ApplicationName; import com.yahoo.config.provision.InstanceName; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import org.junit.Test; import java.time.Clock; @@ -46,7 +46,7 @@ public class RedeployTest { public void testNoRedeploy() { List<ModelFactory> modelFactories = new ArrayList<>(); modelFactories.add(DeployTester.createModelFactory(Clock.systemUTC())); - modelFactories.add(DeployTester.createFailingModelFactory(Version.fromIntValues(1, 0, 0))); + modelFactories.add(DeployTester.createFailingModelFactory(new Version(1, 0, 0))); DeployTester tester = new DeployTester(modelFactories); ApplicationId id = ApplicationId.from(tester.tenant().getName(), ApplicationName.from("default"), diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClientTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClientTest.java index c4a0fd9f3f0..e01b2eccb35 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClientTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClientTest.java @@ -2,11 +2,16 @@ package com.yahoo.vespa.config.server.deploy; import com.google.common.collect.ImmutableSet; +import com.yahoo.component.Version; import com.yahoo.config.application.api.ApplicationMetaData; import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.application.api.FileRegistry; -import com.yahoo.config.model.application.provider.*; -import com.yahoo.config.provision.*; +import com.yahoo.config.model.application.provider.BaseDeployLogger; +import com.yahoo.config.model.application.provider.DeployData; +import com.yahoo.config.model.application.provider.FilesApplicationPackage; +import com.yahoo.config.model.application.provider.MockFileRegistry; +import com.yahoo.config.provision.AllocatedHosts; +import com.yahoo.config.provision.HostSpec; import com.yahoo.path.Path; import com.yahoo.vespa.config.server.zookeeper.ZKApplicationPackage; import com.yahoo.vespa.curator.mock.MockCurator; @@ -19,10 +24,16 @@ import org.junit.rules.TemporaryFolder; import java.io.File; import java.io.IOException; -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; import static org.hamcrest.core.Is.is; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertThat; /** * Unit tests for ZooKeeperClient. @@ -62,8 +73,8 @@ public class ZooKeeperClientTest { FileRegistry b = new MockFileRegistry(); b.addFile("fileB"); Map<Version, FileRegistry> registryMap = new HashMap<>(); - registryMap.put(Version.fromIntValues(1, 2, 3), a); - registryMap.put(Version.fromIntValues(3, 2, 1), b); + registryMap.put(new Version(1, 2, 3), a); + registryMap.put(new Version(3, 2, 1), b); return registryMap; } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperDeployerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperDeployerTest.java index f20c07b7f88..d00c0b8dd32 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperDeployerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperDeployerTest.java @@ -5,7 +5,7 @@ import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.config.model.application.provider.*; import com.yahoo.config.provision.AllocatedHosts; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.io.IOUtils; import com.yahoo.path.Path; import com.yahoo.prelude.semantics.parser.ParseException; @@ -53,7 +53,7 @@ public class ZooKeeperDeployerTest { ZooKeeperClient client = new ZooKeeperClient(configCurator, logger, true, appPath); ZooKeeperDeployer deployer = new ZooKeeperDeployer(client); - deployer.deploy(applicationPackage, Collections.singletonMap(Version.fromIntValues(1, 0, 0), new MockFileRegistry()), AllocatedHosts.withHosts(Collections.emptySet())); + deployer.deploy(applicationPackage, Collections.singletonMap(new Version(1, 0, 0), new MockFileRegistry()), AllocatedHosts.withHosts(Collections.emptySet())); assertTrue(configCurator.exists(appPath.getAbsolute())); } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java index aab5fc68d1d..8572854b462 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java @@ -217,7 +217,7 @@ public class SessionActiveHandlerTest extends SessionHandlerTest { zkClient.writeStatus(status); ZooKeeperClient zkC = new ZooKeeperClient(componentRegistry.getConfigCurator(), new BaseDeployLogger(), false, TenantRepository.getSessionsPath(tenantName).append(String.valueOf(sessionId))); - zkC.write(Collections.singletonMap(modelFactory.getVersion(), new MockFileRegistry())); + zkC.write(Collections.singletonMap(modelFactory.version(), new MockFileRegistry())); zkC.write(AllocatedHosts.withHosts(Collections.emptySet())); RemoteSession session = new RemoteSession(tenantName, sessionId, componentRegistry, zkClient, clock); remoteSessionRepo.addSession(session); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/model/TestModelFactory.java b/configserver/src/test/java/com/yahoo/vespa/config/server/model/TestModelFactory.java index 65629f04cbc..691f818020e 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/model/TestModelFactory.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/model/TestModelFactory.java @@ -5,13 +5,14 @@ import com.yahoo.config.model.NullConfigModelRegistry; import com.yahoo.config.model.api.ModelContext; import com.yahoo.config.model.api.ModelCreateResult; import com.yahoo.config.model.api.ValidationParameters; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.vespa.model.VespaModelFactory; /** * @author Ulf Lilleengen */ public class TestModelFactory extends VespaModelFactory { + private final Version vespaVersion; private ModelContext modelContext; @@ -28,11 +29,12 @@ public class TestModelFactory extends VespaModelFactory { } @Override - public Version getVersion() { + public Version version() { return vespaVersion; } public ModelContext getModelContext() { return modelContext; } + } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRequestHandler.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRequestHandler.java index efd96db07d7..bfc06a58b16 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRequestHandler.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRequestHandler.java @@ -2,7 +2,7 @@ package com.yahoo.vespa.config.server.rpc; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.vespa.config.ConfigKey; import com.yahoo.vespa.config.GetConfigRequest; import com.yahoo.vespa.config.protocol.ConfigResponse; @@ -11,7 +11,12 @@ import com.yahoo.vespa.config.server.ReloadHandler; import com.yahoo.vespa.config.server.RequestHandler; import com.yahoo.vespa.config.server.tenant.TenantHandlerProvider; -import java.util.*; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Optional; +import java.util.Set; /** * Test utility class diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRpc.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRpc.java index b4de201bd0b..0f8bfa5068c 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRpc.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRpc.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.config.server.rpc; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.config.provision.TenantName; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.vespa.config.protocol.ConfigResponse; import com.yahoo.vespa.config.protocol.JRTServerConfigRequest; import com.yahoo.vespa.config.server.GetConfigContext; diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java index 6d964daf61b..972446ca267 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java @@ -8,7 +8,7 @@ import com.yahoo.config.codegen.DefParser; import com.yahoo.config.codegen.InnerCNode; import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.config.provision.TenantName; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.jrt.Request; import com.yahoo.config.provision.ApplicationId; import com.yahoo.vespa.config.ConfigKey; @@ -87,7 +87,7 @@ public class RpcServerTest { new ServerCache(), 2L, false, - Version.fromIntValues(1, 2, 3), + new Version(1, 2, 3), MetricUpdater.createTestUpdater(), ApplicationId.defaultId()); ApplicationSet appSet = ApplicationSet.fromSingle(app); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionTest.java index b2cfe3e7575..e49c29e79b4 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionTest.java @@ -2,8 +2,12 @@ package com.yahoo.vespa.config.server.session; import com.google.common.io.Files; +import com.yahoo.component.Version; import com.yahoo.config.application.api.ApplicationFile; -import com.yahoo.config.provision.*; +import com.yahoo.config.provision.AllocatedHosts; +import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.HostSpec; +import com.yahoo.config.provision.TenantName; import com.yahoo.path.Path; import com.yahoo.config.model.application.provider.*; import com.yahoo.slime.Slime; @@ -166,7 +170,7 @@ public class LocalSessionTest { if (allocatedHosts.isPresent()) { zkClient.write(allocatedHosts.get()); } - zkClient.write(Collections.singletonMap(Version.fromIntValues(0, 0, 0), new MockFileRegistry())); + zkClient.write(Collections.singletonMap(new Version(0, 0, 0), new MockFileRegistry())); File sessionDir = new File(tenantFileSystemDirs.sessionsPath(), String.valueOf(sessionId)); sessionDir.createNewFile(); return new LocalSession(tenant, sessionId, preparer, new SessionContext(FilesApplicationPackage.fromFile(testApp), zkc, sessionDir, new MemoryTenantApplications(), new HostRegistry<>(), superModelGenerationCounter)); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionTest.java index 7a70e7958f8..6050b7818c2 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionTest.java @@ -10,7 +10,7 @@ import com.yahoo.config.model.deploy.DeployState; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.TenantName; import com.yahoo.config.model.test.MockApplicationPackage; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.vespa.config.server.application.ApplicationSet; import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry; import com.yahoo.vespa.config.server.TestComponentRegistry; @@ -85,11 +85,11 @@ public class RemoteSessionTest { @Test(expected = IllegalArgumentException.class) public void require_that_new_invalid_application_throws_exception() { MockModelFactory failingFactory = new MockModelFactory(); - failingFactory.vespaVersion = Version.fromIntValues(1, 2, 0); + failingFactory.vespaVersion = new Version(1, 2, 0); failingFactory.throwOnLoad = true; MockModelFactory okFactory = new MockModelFactory(); - okFactory.vespaVersion = Version.fromIntValues(1, 1, 0); + okFactory.vespaVersion = new Version(1, 1, 0); okFactory.throwOnLoad = false; RemoteSession session = createSession(3, Arrays.asList(okFactory, failingFactory), failingFactory.clock()); @@ -99,15 +99,15 @@ public class RemoteSessionTest { @Test public void require_that_application_incompatible_with_latestmajor_is_loaded_on_earlier_major() { MockModelFactory okFactory1 = new MockModelFactory(); - okFactory1.vespaVersion = Version.fromIntValues(1, 1, 0); + okFactory1.vespaVersion = new Version(1, 1, 0); okFactory1.throwOnLoad = false; MockModelFactory okFactory2 = new MockModelFactory(); - okFactory2.vespaVersion = Version.fromIntValues(1, 2, 0); + okFactory2.vespaVersion = new Version(1, 2, 0); okFactory2.throwOnLoad = false; MockModelFactory failingFactory = new MockModelFactory(); - failingFactory.vespaVersion = Version.fromIntValues(2, 0, 0); + failingFactory.vespaVersion = new Version(2, 0, 0); failingFactory.throwOnLoad = true; RemoteSession session = createSession(3, Arrays.asList(okFactory1, failingFactory, okFactory2), failingFactory.clock()); @@ -117,12 +117,12 @@ public class RemoteSessionTest { @Test public void require_that_old_invalid_application_does_not_throw_exception_if_skipped() { MockModelFactory failingFactory = new MockModelFactory(); - failingFactory.vespaVersion = Version.fromIntValues(1, 1, 0); + failingFactory.vespaVersion = new Version(1, 1, 0); failingFactory.throwOnLoad = true; MockModelFactory okFactory = new MockModelFactory("<validation-overrides><allow until='2000-01-30'>skip-old-config-models</allow></validation-overrides>"); - okFactory.vespaVersion = Version.fromIntValues(1, 2, 0); + okFactory.vespaVersion = new Version(1, 2, 0); okFactory.throwOnLoad = false; RemoteSession session = createSession(3, Arrays.asList(okFactory, failingFactory), failingFactory.clock()); @@ -132,12 +132,12 @@ public class RemoteSessionTest { @Test public void require_that_old_invalid_application_does_not_throw_exception_if_skipped_also_across_major_versions() { MockModelFactory failingFactory = new MockModelFactory(); - failingFactory.vespaVersion = Version.fromIntValues(1, 0, 0); + failingFactory.vespaVersion = new Version(1, 0, 0); failingFactory.throwOnLoad = true; MockModelFactory okFactory = new MockModelFactory("<validation-overrides><allow until='2000-01-30'>skip-old-config-models</allow></validation-overrides>"); - okFactory.vespaVersion = Version.fromIntValues(2, 0, 0); + okFactory.vespaVersion = new Version(2, 0, 0); okFactory.throwOnLoad = false; RemoteSession session = createSession(3, Arrays.asList(okFactory, failingFactory), failingFactory.clock()); @@ -147,17 +147,17 @@ public class RemoteSessionTest { @Test public void require_that_old_invalid_application_does_not_throw_exception_if_skipped_also_when_new_major_is_incompatible() { MockModelFactory failingFactory = new MockModelFactory(); - failingFactory.vespaVersion = Version.fromIntValues(1, 0, 0); + failingFactory.vespaVersion = new Version(1, 0, 0); failingFactory.throwOnLoad = true; MockModelFactory okFactory = new MockModelFactory("<validation-overrides><allow until='2000-01-30'>skip-old-config-models</allow></validation-overrides>"); - okFactory.vespaVersion = Version.fromIntValues(1, 1, 0); + okFactory.vespaVersion = new Version(1, 1, 0); okFactory.throwOnLoad = false; MockModelFactory tooNewFactory = new MockModelFactory("<validation-overrides><allow until='2000-01-30'>skip-old-config-models</allow></validation-overrides>"); - tooNewFactory.vespaVersion = Version.fromIntValues(2, 0, 0); + tooNewFactory.vespaVersion = new Version(2, 0, 0); tooNewFactory.throwOnLoad = true; RemoteSession session = createSession(3, Arrays.asList(tooNewFactory, okFactory, failingFactory), failingFactory.clock()); @@ -174,11 +174,11 @@ public class RemoteSessionTest { assertEquals(2, (int)application.getMajorVersion().get()); MockModelFactory failingFactory = new MockModelFactory(); - failingFactory.vespaVersion = Version.fromIntValues(3, 0, 0); + failingFactory.vespaVersion = new Version(3, 0, 0); failingFactory.throwErrorOnLoad = true; MockModelFactory okFactory = new MockModelFactory(); - okFactory.vespaVersion = Version.fromIntValues(2, 0, 0); + okFactory.vespaVersion = new Version(2, 0, 0); okFactory.throwErrorOnLoad = false; SessionZooKeeperClient zkc = new MockSessionZKClient(curator, tenantName, 3, application); @@ -198,11 +198,11 @@ public class RemoteSessionTest { assertEquals(3, (int)application.getMajorVersion().get()); MockModelFactory failingFactory = new MockModelFactory(); - failingFactory.vespaVersion = Version.fromIntValues(4, 0, 0); + failingFactory.vespaVersion = new Version(4, 0, 0); failingFactory.throwErrorOnLoad = true; MockModelFactory okFactory = new MockModelFactory(); - okFactory.vespaVersion = Version.fromIntValues(2, 0, 0); + okFactory.vespaVersion = new Version(2, 0, 0); okFactory.throwErrorOnLoad = false; SessionZooKeeperClient zkc = new MockSessionZKClient(curator, tenantName, 3, application); @@ -279,7 +279,7 @@ public class RemoteSessionTest { public boolean throwErrorOnLoad = false; public ModelContext modelContext; - public Version vespaVersion = Version.fromIntValues(1, 2, 3); + public Version vespaVersion = new Version(1, 2, 3); /** The validation overrides of this, or null if none */ private final String validationOverrides; @@ -293,7 +293,7 @@ public class RemoteSessionTest { } @Override - public Version getVersion() { + public Version version() { return vespaVersion; } @@ -330,4 +330,5 @@ public class RemoteSessionTest { return new ModelCreateResult(loadModel(), new ArrayList<>()); } } + } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java index 07e61048611..42acb1a1a24 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java @@ -5,18 +5,21 @@ import com.yahoo.config.application.api.DeployLogger; import com.yahoo.config.model.api.ModelContext; import com.yahoo.config.model.api.ModelCreateResult; import com.yahoo.config.model.api.ValidationParameters; -import com.yahoo.config.model.application.provider.*; +import com.yahoo.config.model.application.provider.BaseDeployLogger; +import com.yahoo.config.model.application.provider.FilesApplicationPackage; import com.yahoo.config.provision.ApplicationName; import com.yahoo.config.provision.InstanceName; import com.yahoo.config.provision.Rotation; import com.yahoo.config.provision.TenantName; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.io.IOUtils; import com.yahoo.log.LogLevel; import com.yahoo.path.Path; import com.yahoo.slime.Slime; -import com.yahoo.vespa.config.server.*; import com.yahoo.config.provision.ApplicationId; +import com.yahoo.vespa.config.server.SuperModelGenerationCounter; +import com.yahoo.vespa.config.server.TestComponentRegistry; +import com.yahoo.vespa.config.server.TimeoutBudgetTest; import com.yahoo.vespa.config.server.application.MemoryTenantApplications; import com.yahoo.vespa.config.server.application.PermanentApplicationPackage; import com.yahoo.vespa.config.server.configchange.ConfigChangeActions; @@ -38,11 +41,17 @@ import org.junit.rules.TemporaryFolder; import java.io.File; import java.io.IOException; import java.time.Instant; -import java.util.*; +import java.util.Arrays; +import java.util.Collections; +import java.util.Optional; +import java.util.Set; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.Matchers.contains; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertThat; /** * @author Ulf Lilleengen @@ -53,9 +62,9 @@ public class SessionPreparerTest { private static final Path sessionsPath = tenantPath.append("sessions").append("testapp"); private static final File testApp = new File("src/test/apps/app"); private static final File invalidTestApp = new File("src/test/apps/illegalApp"); - private static final Version version123 = Version.fromIntValues(1, 2, 3); - private static final Version version321 = Version.fromIntValues(3, 2, 1); - private static final Version version323 = Version.fromIntValues(3, 2, 3); + private static final Version version123 = new Version(1, 2, 3); + private static final Version version321 = new Version(3, 2, 1); + private static final Version version323 = new Version(3, 2, 3); private MockCurator curator; private ConfigCurator configCurator; @@ -223,7 +232,11 @@ public class SessionPreparerTest { } private SessionContext getContext(FilesApplicationPackage app) throws IOException { - return new SessionContext(app, new SessionZooKeeperClient(curator, sessionsPath), app.getAppDir(), new MemoryTenantApplications(), new HostRegistry<>(), new SuperModelGenerationCounter(curator)); + return new SessionContext(app, + new SessionZooKeeperClient(curator, sessionsPath), + app.getAppDir(), + new MemoryTenantApplications(), new HostRegistry<>(), + new SuperModelGenerationCounter(curator)); } private FilesApplicationPackage getApplicationPackage(File testFile) throws IOException { diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java index 5af37a1f684..4046384005d 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java @@ -8,7 +8,7 @@ import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.SystemName; import com.yahoo.config.provision.TenantName; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.config.provision.Zone; import com.yahoo.vespa.config.server.GlobalComponentRegistry; import com.yahoo.vespa.config.server.application.ApplicationSet; @@ -86,7 +86,7 @@ public class TenantRepositoryTest { new ServerCache(), 4L, false, - Version.fromIntValues(1, 2, 3), + new Version(1, 2, 3), MetricUpdater.createTestUpdater(), ApplicationId.defaultId()))); assertEquals(1, listener.reloaded.get()); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandlerTest.java index d967f346b5c..fab67b25610 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandlerTest.java @@ -11,7 +11,7 @@ import com.yahoo.config.model.application.provider.FilesApplicationPackage; import com.yahoo.config.model.application.provider.MockFileRegistry; import com.yahoo.config.provision.ApplicationName; import com.yahoo.config.provision.AllocatedHosts; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.io.IOUtils; import com.yahoo.vespa.config.ConfigKey; import com.yahoo.vespa.config.ConfigPayload; @@ -60,7 +60,7 @@ import static org.junit.Assert.*; */ public class TenantRequestHandlerTest { - private static final Version vespaVersion = new VespaModelFactory(new NullConfigModelRegistry()).getVersion(); + private static final Version vespaVersion = new VespaModelFactory(new NullConfigModelRegistry()).version(); private TenantRequestHandler server; private MockReloadListener listener = new MockReloadListener(); private File app1 = new File("src/test/apps/cs1"); @@ -120,7 +120,7 @@ public class TenantRequestHandlerTest { private ModelFactoryRegistry createRegistry() { return new ModelFactoryRegistry(Arrays.asList(new TestModelFactory(vespaVersion), - new TestModelFactory(Version.fromIntValues(3, 2, 1)))); + new TestModelFactory(new Version(3, 2, 1)))); } public <T extends ConfigInstance> T resolve(Class<T> clazz, @@ -150,7 +150,7 @@ public class TenantRequestHandlerTest { @Override public Optional<VespaVersion> getVespaVersion() { - return Optional.of(VespaVersion.fromString(vespaVersion.toSerializedForm())); + return Optional.of(VespaVersion.fromString(vespaVersion.toFullString())); } @Override @@ -240,7 +240,7 @@ public class TenantRequestHandlerTest { feedAndReloadApp(app1, 1, appId); SimpletypesConfig config = resolve(SimpletypesConfig.class, server, appId, vespaVersion, ""); assertThat(config.intval(), is(1337)); - config = resolve(SimpletypesConfig.class, server, appId, Version.fromIntValues(3, 2, 1), ""); + config = resolve(SimpletypesConfig.class, server, appId, new Version(3, 2, 1), ""); assertThat(config.intval(), is(1337)); } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/version/VersionStateTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/version/VersionStateTest.java index 84133f486fd..8a1a7fbea20 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/version/VersionStateTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/version/VersionStateTest.java @@ -2,7 +2,7 @@ package com.yahoo.vespa.config.server.version; import com.yahoo.cloud.config.ConfigserverConfig; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.io.IOUtils; import org.junit.Rule; import org.junit.Test; @@ -26,7 +26,7 @@ public class VersionStateTest { @Test public void upgrade() throws IOException { - Version unknownVersion = Version.fromIntValues(0, 0, 0); + Version unknownVersion = new Version(0, 0, 0); File versionFile = tempDir.newFile(); VersionState state = new VersionState(versionFile); assertThat(state.storedVersion(), is(unknownVersion)); @@ -39,7 +39,7 @@ public class VersionStateTest { assertTrue(state.isUpgraded()); IOUtils.writeFile(versionFile, "5.0.0", false); - assertThat(state.storedVersion(), is(Version.fromIntValues(5, 0, 0))); + assertThat(state.storedVersion(), is(new Version(5, 0, 0))); assertTrue(state.isUpgraded()); state.saveNewVersion(); @@ -57,4 +57,5 @@ public class VersionStateTest { Version stored = Version.fromString(IOUtils.readFile(versionFile)); assertThat(stored, is(state.currentVersion())); } + } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackageTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackageTest.java index 22d5901a29a..e8e2dd07756 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackageTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackageTest.java @@ -2,7 +2,10 @@ package com.yahoo.vespa.config.server.zookeeper; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertThat; import java.io.File; import java.io.IOException; @@ -17,7 +20,7 @@ import com.yahoo.config.provision.Flavor; import com.yahoo.config.provision.HostSpec; import com.yahoo.config.provision.NodeFlavors; import com.yahoo.config.provision.AllocatedHosts; -import com.yahoo.config.provision.Version; +import com.yahoo.component.Version; import com.yahoo.config.provisioning.FlavorsConfig; import com.yahoo.path.Path; import com.yahoo.text.Utf8; @@ -69,10 +72,10 @@ public class ZKApplicationPackageTest { } assertTrue(zkApp.getFile(Path.createRoot()).exists()); assertTrue(zkApp.getFile(Path.createRoot()).isDirectory()); - Version goodVersion = Version.fromIntValues(3, 0, 0); - assertTrue(zkApp.getFileRegistryMap().containsKey(goodVersion)); - assertFalse(zkApp.getFileRegistryMap().containsKey(Version.fromIntValues(0, 0, 0))); - assertThat(zkApp.getFileRegistryMap().get(goodVersion).fileSourceHost(), is("dummyfiles")); + Version goodVersion = new Version(3, 0, 0); + assertTrue(zkApp.getFileRegistries().containsKey(goodVersion)); + assertFalse(zkApp.getFileRegistries().containsKey(new Version(0, 0, 0))); + assertThat(zkApp.getFileRegistries().get(goodVersion).fileSourceHost(), is("dummyfiles")); AllocatedHosts readInfo = zkApp.getAllocatedHosts().get(); assertThat(Utf8.toString(readInfo.toJson()), is(Utf8.toString(ALLOCATED_HOSTS.toJson()))); assertThat(readInfo.getHosts().iterator().next().flavor(), is(TEST_FLAVOR)); @@ -100,4 +103,5 @@ public class ZKApplicationPackageTest { ); } } + } |