From 3bb4e64b105a3f1e1bed478d5cceab99a4323926 Mon Sep 17 00:00:00 2001 From: Martin Polden Date: Fri, 7 Jun 2019 12:57:34 +0200 Subject: Remove support for element --- .../model/builder/xml/dom/NodesSpecification.java | 13 +---- .../vespa/model/builder/xml/dom/Rotations.java | 52 ------------------- .../model/container/xml/ContainerModelBuilder.java | 23 +++------ .../src/main/resources/schema/container.rnc | 6 --- .../src/main/resources/schema/containercluster.rnc | 3 +- .../vespa/model/builder/xml/dom/RotationsTest.java | 59 ---------------------- .../src/test/schema-test-files/services-hosted.xml | 8 --- 7 files changed, 9 insertions(+), 155 deletions(-) delete mode 100644 config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/Rotations.java delete mode 100644 config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/RotationsTest.java (limited to 'config-model') diff --git a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/NodesSpecification.java b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/NodesSpecification.java index bf32b944410..27a266e76e1 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/NodesSpecification.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/NodesSpecification.java @@ -8,14 +8,11 @@ import com.yahoo.config.provision.Capacity; import com.yahoo.config.provision.ClusterMembership; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.NodeResources; -import com.yahoo.config.provision.RotationName; import com.yahoo.vespa.model.HostResource; import com.yahoo.vespa.model.HostSystem; -import java.util.Collections; import java.util.Map; import java.util.Optional; -import java.util.Set; /** * A common utility class to represent a requirement for nodes during model building. @@ -161,15 +158,7 @@ public class NodesSpecification { ClusterSpec.Type clusterType, ClusterSpec.Id clusterId, DeployLogger logger) { - return provision(hostSystem, clusterType, clusterId, logger, Collections.emptySet()); - } - - public Map provision(HostSystem hostSystem, - ClusterSpec.Type clusterType, - ClusterSpec.Id clusterId, - DeployLogger logger, - Set rotations) { - ClusterSpec cluster = ClusterSpec.request(clusterType, clusterId, version, exclusive, rotations); + ClusterSpec cluster = ClusterSpec.request(clusterType, clusterId, version, exclusive); return hostSystem.allocateHosts(cluster, Capacity.fromCount(count, resources, required, canFail), groups, logger); } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/Rotations.java b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/Rotations.java deleted file mode 100644 index 2071f2a1ac3..00000000000 --- a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/Rotations.java +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.builder.xml.dom; - -import com.yahoo.config.provision.RotationName; -import com.yahoo.text.XML; -import org.w3c.dom.Element; - -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; -import java.util.regex.Pattern; - -/** - * Read rotations from the rotations element in services.xml. - * - * @author mpolden - */ -public class Rotations { - - /* - * Rotation names must be: - * - lowercase - * - alphanumeric - * - begin with a character - * - contain zero consecutive dashes - * - have a length between 1 and 12 - */ - private static final Pattern pattern = Pattern.compile("^[a-z](?:-?[a-z0-9]+)*$"); - private static final int maxLength = 12; - - private Rotations() {} - - /** Set the rotations the given cluster should be member of */ - public static Set from(Element rotationsElement) { - Set rotations = new TreeSet<>(); - List children = XML.getChildren(rotationsElement, "rotation"); - for (Element el : children) { - String name = el.getAttribute("id"); - if (name == null || name.length() > maxLength || !pattern.matcher(name).matches()) { - throw new IllegalArgumentException("Rotation ID '" + name + "' is missing or has invalid format"); - } - RotationName rotation = RotationName.from(name); - if (rotations.contains(rotation)) { - throw new IllegalArgumentException("Rotation ID '" + name + "' is duplicated"); - } - rotations.add(rotation); - } - return Collections.unmodifiableSet(rotations); - } - -} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java index 39187d7d5d1..eea93c6b32b 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java @@ -22,7 +22,6 @@ import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.NodeType; import com.yahoo.config.provision.Rotation; -import com.yahoo.config.provision.RotationName; import com.yahoo.config.provision.SystemName; import com.yahoo.config.provision.Zone; import com.yahoo.search.rendering.RendererRegistry; @@ -37,7 +36,6 @@ import com.yahoo.vespa.model.builder.xml.dom.DomComponentBuilder; import com.yahoo.vespa.model.builder.xml.dom.DomHandlerBuilder; import com.yahoo.vespa.model.builder.xml.dom.ModelElement; import com.yahoo.vespa.model.builder.xml.dom.NodesSpecification; -import com.yahoo.vespa.model.builder.xml.dom.Rotations; import com.yahoo.vespa.model.builder.xml.dom.ServletBuilder; import com.yahoo.vespa.model.builder.xml.dom.VespaDomBuilder; import com.yahoo.vespa.model.builder.xml.dom.chains.docproc.DomDocprocChainsBuilder; @@ -493,7 +491,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder { node.initService(context.getDeployLogger()); cluster.addContainers(Collections.singleton(node)); } else { - List nodes = createNodes(cluster, nodesElement, rotationsElement, context); + List nodes = createNodes(cluster, nodesElement, context); Element jvmElement = XML.getChild(nodesElement, "jvm"); if (jvmElement == null) { @@ -524,9 +522,9 @@ public class ContainerModelBuilder extends ConfigModelBuilder { return sb.toString(); } - private List createNodes(ApplicationContainerCluster cluster, Element nodesElement, Element rotationsElement, ConfigModelContext context) { + private List createNodes(ApplicationContainerCluster cluster, Element nodesElement, ConfigModelContext context) { if (nodesElement.hasAttribute("count")) // regular, hosted node spec - return createNodesFromNodeCount(cluster, nodesElement, rotationsElement, context); + return createNodesFromNodeCount(cluster, nodesElement, context); else if (nodesElement.hasAttribute("type")) // internal use for hosted system infrastructure nodes return createNodesFromNodeType(cluster, nodesElement, context); else if (nodesElement.hasAttribute("of")) // hosted node spec referencing a content cluster @@ -579,8 +577,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder { ClusterSpec clusterSpec = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from(cluster.getName()), deployState.getWantedNodeVespaVersion(), - false, - Collections.emptySet()); + false); Capacity capacity = Capacity.fromNodeCount(1, Optional.empty(), false, @@ -592,17 +589,12 @@ public class ContainerModelBuilder extends ConfigModelBuilder { } } - private List createNodesFromNodeCount(ApplicationContainerCluster cluster, Element nodesElement, Element rotationsElement, ConfigModelContext context) { + private List createNodesFromNodeCount(ApplicationContainerCluster cluster, Element nodesElement, ConfigModelContext context) { NodesSpecification nodesSpecification = NodesSpecification.from(new ModelElement(nodesElement), context); - Set rotations = Set.of(); - if (zoneHasActiveRotation(context.getDeployState().zone())) { - rotations = Rotations.from(rotationsElement); - } Map hosts = nodesSpecification.provision(cluster.getRoot().getHostSystem(), ClusterSpec.Type.container, ClusterSpec.Id.from(cluster.getName()), - log, - rotations); + log); return createNodesFromHosts(context.getDeployLogger(), hosts, cluster); } @@ -611,8 +603,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder { ClusterSpec clusterSpec = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from(cluster.getName()), context.getDeployState().getWantedNodeVespaVersion(), - false, - Collections.emptySet()); + false); Map hosts = cluster.getRoot().getHostSystem().allocateHosts(clusterSpec, Capacity.fromRequiredNodeType(type), 1, log); diff --git a/config-model/src/main/resources/schema/container.rnc b/config-model/src/main/resources/schema/container.rnc index 54d030e6bc0..3f0e1f626ac 100644 --- a/config-model/src/main/resources/schema/container.rnc +++ b/config-model/src/main/resources/schema/container.rnc @@ -50,9 +50,3 @@ FilterConfig = element filter-config { Renderer = element renderer { ComponentDefinition } - -Rotations = element rotations { - element rotation { - attribute id { xsd:Name } - }+ -} diff --git a/config-model/src/main/resources/schema/containercluster.rnc b/config-model/src/main/resources/schema/containercluster.rnc index 73492f6d650..d5de3c11124 100644 --- a/config-model/src/main/resources/schema/containercluster.rnc +++ b/config-model/src/main/resources/schema/containercluster.rnc @@ -7,8 +7,7 @@ ContainerCluster = element container | jdisc { ContainerServices & DocumentBinding* & Aliases? & - NodesOfContainerCluster? & - Rotations? + NodesOfContainerCluster? } ContainerServices = diff --git a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/RotationsTest.java b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/RotationsTest.java deleted file mode 100644 index 3063b1aabc2..00000000000 --- a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/RotationsTest.java +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.builder.xml.dom; - -import com.yahoo.config.provision.RotationName; -import com.yahoo.text.XML; -import org.junit.Test; - -import java.util.Arrays; -import java.util.Set; -import java.util.stream.Collectors; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -/** - * @author mpolden - */ -public class RotationsTest { - - @Test - public void invalid_ids() { - assertInvalid(""); // Unset - assertInvalid(""); // Blank - assertInvalid(""); // Uppercaes - assertInvalid(""); // Starting with non-character - assertInvalid(""); // Non-alphanumeric - assertInvalid(""); // Multiple consecutive dashes - assertInvalid(""); // Trailing dash - assertInvalid(""); // Too long - assertInvalid(""); // Duplicate ID - } - - @Test - public void valid_ids() { - assertEquals(rotations(), xml("")); - assertEquals(rotations("f"), xml("")); - assertEquals(rotations("foo"), xml("")); - assertEquals(rotations("foo-bar"), xml("")); - assertEquals(rotations("foo", "bar"), xml("")); - assertEquals(rotations("fooooooooooo"), xml("")); - } - - private static Set rotations(String... rotation) { - return Arrays.stream(rotation).map(RotationName::from).collect(Collectors.toSet()); - } - - private static void assertInvalid(String rotations) { - try { - xml(rotations); - fail("Expected exception for input '" + rotations + "'"); - } catch (IllegalArgumentException ignored) {} - } - - private static Set xml(String rotations) { - return Rotations.from(XML.getDocument("" + rotations + "") - .getDocumentElement()); - } - -} diff --git a/config-model/src/test/schema-test-files/services-hosted.xml b/config-model/src/test/schema-test-files/services-hosted.xml index f7f20d003ee..d62857d67b0 100644 --- a/config-model/src/test/schema-test-files/services-hosted.xml +++ b/config-model/src/test/schema-test-files/services-hosted.xml @@ -20,14 +20,6 @@ - - - - - - - - 2 -- cgit v1.2.3