diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-08-09 15:34:40 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-08-09 15:34:40 +0200 |
commit | 18a7c06bb20ff38ef9d6254e6707eedf6f730e02 (patch) | |
tree | 80f325f2a4b1a40bd1f63122f6290dc79474782a /config-model/src/main/java/com | |
parent | c1895eb19f3bd646bcffaad085c84b15d28fdb3b (diff) |
Cleanup
Diffstat (limited to 'config-model/src/main/java/com')
5 files changed, 12 insertions, 21 deletions
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 46ec84caf24..e6df94c8855 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 @@ -130,7 +130,7 @@ public class ApplicationConfigProducerRoot extends AbstractConfigProducer<Abstra if (admin != null) { Routing routing = configModels.getRouting(); if (routing == null) { - routing = new Routing(ConfigModelContext.create(configModels, this, "routing", Optional.empty())); + routing = new Routing(ConfigModelContext.create(configModels, this, "routing")); configModels.add(routing); } this.routing = routing; diff --git a/config-model/src/main/java/com/yahoo/config/model/ConfigModelContext.java b/config-model/src/main/java/com/yahoo/config/model/ConfigModelContext.java index edd0ed4bf29..b5382b09193 100644 --- a/config-model/src/main/java/com/yahoo/config/model/ConfigModelContext.java +++ b/config-model/src/main/java/com/yahoo/config/model/ConfigModelContext.java @@ -22,15 +22,13 @@ public class ConfigModelContext { private final String producerId; private final DeployState deployState; private final ConfigModelRepoAdder configModelRepoAdder; - private final Optional<Element> servicesElement; private ConfigModelContext(DeployState deployState, ConfigModelRepoAdder configModelRepoAdder, - AbstractConfigProducer parent, String producerId, Optional<Element> servicesElement) { + AbstractConfigProducer parent, String producerId) { this.deployState = deployState; this.configModelRepoAdder = configModelRepoAdder; this.parent = parent; this.producerId = producerId; - this.servicesElement = servicesElement; } public ApplicationPackage getApplicationPackage() { return deployState.getApplicationPackage(); } @@ -38,20 +36,18 @@ public class ConfigModelContext { public AbstractConfigProducer getParentProducer() { return parent; } public DeployLogger getDeployLogger() { return deployState.getDeployLogger(); } public DeployState getDeployState() { return deployState; } - /** Returns the services element (root) in which this model needs to be built, if any */ - public Optional<Element> servicesElement() { return servicesElement; } /** Returns write access to the config model repo, or null (only) if this is improperly initialized during testing */ public ConfigModelRepoAdder getConfigModelRepoAdder() { return configModelRepoAdder; } /** Create a new context with a different parent */ public ConfigModelContext withParent(AbstractConfigProducer newParent) { - return ConfigModelContext.create(deployState, configModelRepoAdder, newParent, producerId, servicesElement); + return ConfigModelContext.create(deployState, configModelRepoAdder, newParent, producerId); } /** Create a new context with a different config model producer id */ public ConfigModelContext withId(String producerId) { - return ConfigModelContext.create(deployState, configModelRepoAdder, parent, producerId, servicesElement); + return ConfigModelContext.create(deployState, configModelRepoAdder, parent, producerId); } /** @@ -60,12 +56,11 @@ public class ConfigModelContext { * @param deployState the global deploy state for this model * @param parent the parent to be used for the config model * @param producerId the id to be used for the config model - * @param servicesElement the services element (root) in which this model needs to be built, if any * @return a model context that can be passed to a model */ public static ConfigModelContext create(DeployState deployState, ConfigModelRepoAdder configModelRepoAdder, - AbstractConfigProducer parent, String producerId, Optional<Element> servicesElement) { - return new ConfigModelContext(deployState, configModelRepoAdder, parent, producerId, servicesElement); + AbstractConfigProducer parent, String producerId) { + return new ConfigModelContext(deployState, configModelRepoAdder, parent, producerId); } /** @@ -73,12 +68,11 @@ public class ConfigModelContext { * * @param parent the parent to be used for the config model. * @param producerId the id to be used for the config model. - * @param servicesElement the services element (root) in which this model needs to be built, if any * @return a model context that can be passed to a model. */ public static ConfigModelContext create(ConfigModelRepoAdder configModelRepoAdder, - AbstractConfigProducer parent, String producerId, Optional<Element> servicesElement) { - return create(parent.getRoot().getDeployState(), configModelRepoAdder, parent, producerId, servicesElement); + AbstractConfigProducer parent, String producerId) { + return create(parent.getRoot().getDeployState(), configModelRepoAdder, parent, producerId); } } diff --git a/config-model/src/main/java/com/yahoo/config/model/ConfigModelRepo.java b/config-model/src/main/java/com/yahoo/config/model/ConfigModelRepo.java index 91142ccbeae..d4b6751c356 100644 --- a/config-model/src/main/java/com/yahoo/config/model/ConfigModelRepo.java +++ b/config-model/src/main/java/com/yahoo/config/model/ConfigModelRepo.java @@ -174,8 +174,7 @@ public class ConfigModelRepo implements ConfigModelRepoAdder, Serializable, Iter private ConfigModel buildModel(ModelNode node, DeployState deployState, AbstractConfigProducer parent, Element servicesElement) { ConfigModelBuilder builder = node.builder; - ConfigModelContext context = ConfigModelContext.create(deployState, this, parent, - getIdString(servicesElement), Optional.of(servicesElement)); + ConfigModelContext context = ConfigModelContext.create(deployState, this, parent, getIdString(servicesElement)); return builder.build(node, servicesElement, context); } diff --git a/config-model/src/main/java/com/yahoo/config/model/builder/xml/ConfigModelBuilder.java b/config-model/src/main/java/com/yahoo/config/model/builder/xml/ConfigModelBuilder.java index 4fed0a8aa41..37da769ae33 100644 --- a/config-model/src/main/java/com/yahoo/config/model/builder/xml/ConfigModelBuilder.java +++ b/config-model/src/main/java/com/yahoo/config/model/builder/xml/ConfigModelBuilder.java @@ -57,8 +57,7 @@ public abstract class ConfigModelBuilder<MODEL extends ConfigModel> extends Abst */ public final MODEL build(DeployState deployState, ConfigModelRepo configModelRepo, AbstractConfigProducer parent, Element spec) { - ConfigModelContext context = ConfigModelContext.create(deployState, configModelRepo, parent, - getIdString(spec), Optional.empty()); + ConfigModelContext context = ConfigModelContext.create(deployState, configModelRepo, parent, getIdString(spec)); return build(new DefaultModelInstanceFactory(), spec, context); } 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 f4f720f5add..ae42da60df0 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 @@ -435,6 +435,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { } private List<Container> createNodesFromClusterReference(ContainerCluster cluster, Element nodesElement, ConfigModelContext context) { + // Resolve references to content clusters at the XML level because content clusters must be built after container clusters String referenceId = nodesElement.getAttribute("of"); Element services = servicesRootOf(nodesElement).orElseThrow(() -> clusterReferenceNotFoundException(cluster, referenceId)); Element referencedCluster = findChildById(services, referenceId).orElseThrow(() -> clusterReferenceNotFoundException(cluster, referenceId)); @@ -490,10 +491,8 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { } private Optional<Element> findChildById(Element parent, String id) { - for (Element child : XML.getChildren(parent)) { - System.out.println("Checking if " + id + " equals id of " + child.getTagName() + ": " + child.getAttribute("id")); + for (Element child : XML.getChildren(parent)) if (id.equals(child.getAttribute("id"))) return Optional.of(child); - } return Optional.empty(); } |