diff options
author | Harald Musum <musum@yahooinc.com> | 2022-10-23 19:36:01 +0200 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2022-10-23 19:36:01 +0200 |
commit | b4cca6e14d8deb627bcbdc314550ec43fb94c5b2 (patch) | |
tree | c238418596b47470b563c10a4386d14647010ddb /config-model/src/main/java/com | |
parent | 1579514b4a757e9038728dbbeecd27a8b812ce66 (diff) |
Move method
Diffstat (limited to 'config-model/src/main/java/com')
-rw-r--r-- | config-model/src/main/java/com/yahoo/config/model/provision/Hosts.java | 34 | ||||
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/VespaDomBuilder.java | 34 |
2 files changed, 31 insertions, 37 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/provision/Hosts.java b/config-model/src/main/java/com/yahoo/config/model/provision/Hosts.java index 2ef8cb4a0bf..b351073bd25 100644 --- a/config-model/src/main/java/com/yahoo/config/model/provision/Hosts.java +++ b/config-model/src/main/java/com/yahoo/config/model/provision/Hosts.java @@ -5,14 +5,15 @@ import com.google.common.collect.ImmutableMap; import com.yahoo.config.model.builder.xml.XmlHelper; import com.yahoo.net.HostName; import com.yahoo.text.XML; -import com.yahoo.vespa.model.builder.xml.dom.VespaDomBuilder; import org.w3c.dom.Document; import org.w3c.dom.Element; - +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; import java.io.Reader; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; +import java.util.LinkedList; import java.util.List; import java.util.Set; import java.util.logging.Logger; @@ -73,7 +74,7 @@ public class Hosts { if ("localhost".equals(name)) { name = HostName.getLocalhost(); } - List<String> hostAliases = VespaDomBuilder.getHostAliases(hostE.getChildNodes()); + List<String> hostAliases = getHostAliases(hostE.getChildNodes()); if (hostAliases.isEmpty()) { throw new IllegalArgumentException("No host aliases defined for host '" + name + "'"); } @@ -90,4 +91,31 @@ public class Hosts { return "Hosts: " + hosts.keySet(); } + /** + * Get all aliases for one host from a list of 'alias' xml nodes. + * + * @param hostAliases List of xml nodes, each representing one hostalias + * @return a list of alias strings. + */ + private static List<String> getHostAliases(NodeList hostAliases) { + List<String> aliases = new LinkedList<>(); + for (int i = 0; i < hostAliases.getLength(); i++) { + Node n = hostAliases.item(i); + if (! (n instanceof Element e)) { + continue; + } + if (! e.getNodeName().equals("alias")) { + throw new IllegalArgumentException("Unexpected tag: '" + e.getNodeName() + "' at node " + + XML.getNodePath(e, " > ") + ", expected 'alias'."); + } + String alias = e.getFirstChild().getNodeValue(); + if ((alias == null) || (alias.equals(""))) { + throw new IllegalArgumentException("Missing value for the alias tag at node " + + XML.getNodePath(e, " > ") + "'."); + } + aliases.add(alias); + } + return aliases; + } + } 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 c6fa7b8a69d..cb3c43074fc 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 @@ -22,11 +22,6 @@ import com.yahoo.vespa.model.container.docproc.ContainerDocproc; import com.yahoo.vespa.model.content.Content; import com.yahoo.vespa.model.search.SearchCluster; import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import java.util.LinkedList; -import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -54,35 +49,6 @@ public class VespaDomBuilder extends VespaModelBuilder { public static final Logger log = Logger.getLogger(VespaDomBuilder.class.getPackage().toString()); - /** - * Get all aliases for one host from a list of 'alias' xml nodes. - * - * @param hostAliases List of xml nodes, each representing one hostalias - * @return a list of alias strings. - */ - // TODO Move and change scope - public static List<String> getHostAliases(NodeList hostAliases) { - List<String> aliases = new LinkedList<>(); - for (int i = 0; i < hostAliases.getLength(); i++) { - Node n = hostAliases.item(i); - if (! (n instanceof Element)) { - continue; - } - Element e = (Element)n; - if (! e.getNodeName().equals("alias")) { - throw new IllegalArgumentException("Unexpected tag: '" + e.getNodeName() + "' at node " + - XML.getNodePath(e, " > ") + ", expected 'alias'."); - } - String alias = e.getFirstChild().getNodeValue(); - if ((alias == null) || (alias.equals(""))) { - throw new IllegalArgumentException("Missing value for the alias tag at node " + - XML.getNodePath(e, " > ") + "'."); - } - aliases.add(alias); - } - return aliases; - } - @Override public ApplicationConfigProducerRoot getRoot(String name, DeployState deployState, AbstractConfigProducer parent) { |