diff options
author | Jon Bratseth <bratseth@gmail.com> | 2023-03-01 11:58:09 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2023-03-01 11:58:09 +0100 |
commit | aac4ee4d7fa305cdbda4ab82db7f9dc45aa9f090 (patch) | |
tree | 72f1f8437a53ad7330d6d61e05f5e17b3352044e /config-model-api/src/main/java/com/yahoo/config/application/api | |
parent | 42f5944056ed2b9d46b1b5538cbcccf0b369ca44 (diff) |
Pass ClusterInfo
Diffstat (limited to 'config-model-api/src/main/java/com/yahoo/config/application/api')
4 files changed, 25 insertions, 34 deletions
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 0ce09c454a0..f05dfeceed0 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,6 +2,7 @@ package com.yahoo.config.application.api; import com.yahoo.component.Version; +import com.yahoo.config.application.api.xml.DeploymentSpecXmlReader; import com.yahoo.config.provision.AllocatedHosts; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.Zone; @@ -71,9 +72,6 @@ public interface ApplicationPackage { String RULES_NAME_SUFFIX = ".sr"; String EXT_DIR = "ext"; - // TODO: Remove when oldest model version is 8.95 - String PERMANENT_SERVICES = "permanent-services.xml"; - ApplicationId getApplicationId(); /** @@ -128,20 +126,7 @@ public interface ApplicationPackage { /** Returns the major version this application is valid for, or empty if it is valid for all versions */ default Optional<Integer> getMajorVersion() { - if (getDeployment().isEmpty()) return Optional.empty(); - - Element deployElement = XML.getDocument(getDeployment().get()).getDocumentElement(); - if (deployElement == null) return Optional.empty(); - - String majorVersionString = deployElement.getAttribute("major-version"); - if (majorVersionString == null || majorVersionString.isEmpty()) - return Optional.empty(); - try { - return Optional.of(Integer.parseInt(majorVersionString)); - } - catch (NumberFormatException e) { - throw new IllegalArgumentException("major-version must be an integer number, not '" + majorVersionString + "'"); - } + return getDeploymentSpec().majorVersion(); } /** @@ -168,6 +153,19 @@ public interface ApplicationPackage { String getServicesSource(); Optional<Reader> getDeployment(); + + /** + * Returns the parsed deployment spec of this, + * without validating it, and without reparsing on each request. + */ + DeploymentSpec getDeploymentSpec(); + + default DeploymentSpec parseDeploymentSpec(boolean validate) { + return getDeployment() + .map(new DeploymentSpecXmlReader(validate)::read) + .orElse(DeploymentSpec.empty); + } + Optional<Reader> getValidationOverrides(); List<ComponentInfo> getComponentsInfo(Version vespaVersion); @@ -226,6 +224,7 @@ public interface ApplicationPackage { /** * Readers for all the schema files. + * * @return a collection of readers for schemas */ Collection<NamedReader> getSchemas(); @@ -235,10 +234,9 @@ public interface ApplicationPackage { * application package. This is the entry point for the multi environment application package support. This method * will not mutate the existing application package. * - * @param zone A valid {@link Zone} instance, used to decide which parts of services to keep and remove - * @param logger A {@link DeployLogger} to add output that will be returned to the user - * - * @return A new application package instance pointing to a new location + * @param zone a valid {@link Zone} instance, used to decide which parts of services to keep and remove + * @param logger a {@link DeployLogger} to add output that will be returned to the user + * @return a new application package instance pointing to a new location */ default ApplicationPackage preprocess(Zone zone, DeployLogger logger) throws IOException { throw new UnsupportedOperationException("This application package does not support preprocessing"); diff --git a/config-model-api/src/main/java/com/yahoo/config/application/api/Bcp.java b/config-model-api/src/main/java/com/yahoo/config/application/api/Bcp.java index 8f88b1ba74c..48464904f44 100644 --- a/config-model-api/src/main/java/com/yahoo/config/application/api/Bcp.java +++ b/config-model-api/src/main/java/com/yahoo/config/application/api/Bcp.java @@ -87,27 +87,18 @@ public class Bcp { public static class Group { private final List<RegionMember> members; - private final List<Endpoint> endpoints; + private final Set<RegionName> memberRegions; private final Duration deadline; public Group(List<RegionMember> members, Duration deadline) { - this(members, List.of(), deadline); - } - - public Group(List<RegionMember> members, List<Endpoint> endpoints, Duration deadline) { this.members = List.copyOf(members); - this.endpoints = endpoints; + this.memberRegions = members.stream().map(member -> member.region()).collect(Collectors.toSet()); this.deadline = deadline; } public List<RegionMember> members() { return members; } - /** - * Returns the endpoints defined in this. - * These will be added to instances during XML import post processing - * and should not otherwise be exposed from here. - */ - List<Endpoint> endpoints() { return endpoints; } + public Set<RegionName> memberRegions() { return memberRegions; } /** * Returns the max time until the other regions must be able to handle the additional traffic diff --git a/config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java b/config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java index 41644ebc87d..699010417bf 100644 --- a/config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java +++ b/config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java @@ -88,6 +88,8 @@ public class DeploymentSpec { validateBcp(); } + public boolean isEmpty() { return this == empty; } + /** Throw an IllegalArgumentException if the total delay exceeds 24 hours */ private void validateTotalDelay(List<Step> steps) { long totalDelaySeconds = steps.stream().mapToLong(step -> (step.delay().getSeconds())).sum(); diff --git a/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java b/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java index 91cb2f2622e..d04bb7ecfe0 100644 --- a/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java +++ b/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java @@ -519,7 +519,7 @@ public class DeploymentSpecXmlReader { } Duration deadline = XML.attribute("deadline", groupElement).map(value -> toDuration(value, "deadline")).orElse(Duration.ZERO); - groups.add(new Bcp.Group(regions, endpoints, deadline)); + groups.add(new Bcp.Group(regions, deadline)); } validateAndConsolidate(endpointsByZone, zoneEndpoints); return new Bcp(groups); |