diff options
Diffstat (limited to 'config-model/src/main/java/com/yahoo/config/model')
4 files changed, 42 insertions, 51 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/ConfigDefinitionStore.java b/config-model/src/main/java/com/yahoo/config/model/deploy/ConfigDefinitionStore.java index 140cb3001a0..b9ad830090c 100644 --- a/config-model/src/main/java/com/yahoo/config/model/deploy/ConfigDefinitionStore.java +++ b/config-model/src/main/java/com/yahoo/config/model/deploy/ConfigDefinitionStore.java @@ -8,7 +8,6 @@ import java.util.Optional; /** * @author Ulf Lilleengen - * @since 5.1 */ public interface ConfigDefinitionStore { diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java index 074b19d7238..01809faa2f6 100644 --- a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java +++ b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java @@ -36,9 +36,8 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; import com.yahoo.vespa.model.container.search.QueryProfilesBuilder; import com.yahoo.vespa.model.container.search.SemanticRuleBuilder; import com.yahoo.vespa.model.container.search.SemanticRules; -import com.yahoo.vespa.model.search.SearchDefinition; +import com.yahoo.vespa.model.search.NamedSchema; -import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.Reader; @@ -62,7 +61,7 @@ public class DeployState implements ConfigDefinitionStore { private final DeployLogger logger; private final FileRegistry fileRegistry; private final DocumentModel documentModel; - private final List<SearchDefinition> searchDefinitions; + private final List<NamedSchema> schemas; private final ApplicationPackage applicationPackage; private final Optional<ConfigDefinitionRepo> configDefinitionRepo; private final Optional<ApplicationPackage> permanentApplicationPackage; @@ -122,7 +121,7 @@ public class DeployState implements ConfigDefinitionStore { this.previousModel = previousModel; this.accessLoggingEnabledByDefault = accessLoggingEnabledByDefault; this.provisioner = hostProvisioner.orElse(getDefaultModelHostProvisioner(applicationPackage)); - this.searchDefinitions = searchDocumentModel.getSearchDefinitions(); + this.schemas = searchDocumentModel.getSchemas(); this.documentModel = searchDocumentModel.getDocumentModel(); this.permanentApplicationPackage = permanentApplicationPackage; this.configDefinitionRepo = configDefinitionRepo; @@ -209,8 +208,8 @@ public class DeployState implements ConfigDefinitionStore { return applicationPackage; } - public List<SearchDefinition> getSearchDefinitions() { - return searchDefinitions; + public List<NamedSchema> getSchemas() { + return schemas; } public DocumentModel getDocumentModel() { @@ -427,20 +426,18 @@ public class DeployState implements ConfigDefinitionStore { for (NamedReader reader : readers) { try { String readerName = reader.getName(); - String searchName = builder.importReader(reader, readerName, logger); + String topLevelName = builder.importReader(reader, readerName, logger); String sdName = stripSuffix(readerName, ApplicationPackage.SD_NAME_SUFFIX); - names.put(searchName, sdName); - if ( ! sdName.equals(searchName)) { - throw new IllegalArgumentException("Search definition file name ('" + sdName + "') and name of " + - "search element ('" + searchName + + names.put(topLevelName, sdName); + if ( ! sdName.equals(topLevelName)) { + throw new IllegalArgumentException("Schema definition file name ('" + sdName + "') and name of " + + "top level element ('" + topLevelName + "') are not equal for file '" + readerName + "'"); } } catch (ParseException e) { - throw new IllegalArgumentException("Could not parse search definition file '" + - getSearchDefinitionRelativePath(reader.getName()) + "': " + e.getMessage(), e); + throw new IllegalArgumentException("Could not parse sd file '" + reader.getName(), e); } catch (IOException e) { - throw new IllegalArgumentException("Could not read search definition file '" + - getSearchDefinitionRelativePath(reader.getName()) + "': " + e.getMessage(), e); + throw new IllegalArgumentException("Could not read sd file '" + reader.getName(), e); } finally { closeIgnoreException(reader.getReader()); } @@ -449,10 +446,6 @@ public class DeployState implements ConfigDefinitionStore { return SearchDocumentModel.fromBuilderAndNames(builder, names); } - private String getSearchDefinitionRelativePath(String name) { - return ApplicationPackage.SEARCH_DEFINITIONS_DIR + File.separator + name; - } - private static String stripSuffix(String nodeName, String postfix) { assert (nodeName.endsWith(postfix)); return nodeName.substring(0, nodeName.length() - postfix.length()); diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/SearchDocumentModel.java b/config-model/src/main/java/com/yahoo/config/model/deploy/SearchDocumentModel.java index cdd4f6f8e8a..9b9729dddb3 100644 --- a/config-model/src/main/java/com/yahoo/config/model/deploy/SearchDocumentModel.java +++ b/config-model/src/main/java/com/yahoo/config/model/deploy/SearchDocumentModel.java @@ -3,7 +3,7 @@ package com.yahoo.config.model.deploy; import com.yahoo.searchdefinition.SearchBuilder; import com.yahoo.vespa.documentmodel.DocumentModel; -import com.yahoo.vespa.model.search.SearchDefinition; +import com.yahoo.vespa.model.search.NamedSchema; import java.util.ArrayList; import java.util.List; @@ -13,16 +13,15 @@ import java.util.Map; * Internal helper class to retrieve document model and search definitions. * * @author Ulf Lilleengen - * @since 5.1 */ public class SearchDocumentModel { private final DocumentModel documentModel; - private final List<SearchDefinition> searchDefinitions; + private final List<NamedSchema> schemas; - public SearchDocumentModel(DocumentModel documentModel, List<SearchDefinition> searchDefinitions) { + public SearchDocumentModel(DocumentModel documentModel, List<NamedSchema> schemas) { this.documentModel = documentModel; - this.searchDefinitions = searchDefinitions; + this.schemas = schemas; } @@ -30,22 +29,22 @@ public class SearchDocumentModel { return documentModel; } - public List<SearchDefinition> getSearchDefinitions() { - return searchDefinitions; + public List<NamedSchema> getSchemas() { + return schemas; } public static SearchDocumentModel fromBuilderAndNames(SearchBuilder builder, Map<String, String> names) { - List<SearchDefinition> ret = new ArrayList<>(); + List<NamedSchema> ret = new ArrayList<>(); for (com.yahoo.searchdefinition.Search search : builder.getSearchList()) { - ret.add(new SearchDefinition(names.get(search.getName()), search)); + ret.add(new NamedSchema(names.get(search.getName()), search)); } return new SearchDocumentModel(builder.getModel(), ret); } public static SearchDocumentModel fromBuilder(SearchBuilder builder) { - List<SearchDefinition> ret = new ArrayList<>(); + List<NamedSchema> ret = new ArrayList<>(); for (com.yahoo.searchdefinition.Search search : builder.getSearchList()) { - ret.add(new SearchDefinition(search.getName(), search)); + ret.add(new NamedSchema(search.getName(), search)); } return new SearchDocumentModel(builder.getModel(), ret); } 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 eb61bda83a6..10649df88e1 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 @@ -55,23 +55,23 @@ public class MockApplicationPackage implements ApplicationPackage { private final File root; private final String hostsS; private final String servicesS; - private final List<String> searchDefinitions; - private final String searchDefinitionDir; + private final List<String> schemas; + private final String schemaDir; private final Optional<String> deploymentSpec; private final Optional<String> validationOverrides; private final boolean failOnValidateXml; private final QueryProfileRegistry queryProfileRegistry; private final ApplicationMetaData applicationMetaData; - protected MockApplicationPackage(File root, String hosts, String services, List<String> searchDefinitions, - String searchDefinitionDir, + protected MockApplicationPackage(File root, String hosts, String services, List<String> schemas, + String schemaDir, String deploymentSpec, String validationOverrides, boolean failOnValidateXml, String queryProfile, String queryProfileType) { this.root = root; this.hostsS = hosts; this.servicesS = services; - this.searchDefinitions = searchDefinitions; - this.searchDefinitionDir = searchDefinitionDir; + this.schemas = schemas; + this.schemaDir = schemaDir; this.deploymentSpec = Optional.ofNullable(deploymentSpec); this.validationOverrides = Optional.ofNullable(validationOverrides); this.failOnValidateXml = failOnValidateXml; @@ -108,7 +108,7 @@ public class MockApplicationPackage implements ApplicationPackage { @Override public Reader getHosts() { - if (hostsS==null) return null; + if (hostsS == null) return null; return new StringReader(hostsS); } @@ -118,7 +118,7 @@ public class MockApplicationPackage implements ApplicationPackage { SearchBuilder searchBuilder = new SearchBuilder(this, new RankProfileRegistry(), queryProfileRegistry); - for (String sd : searchDefinitions) { + for (String sd : schemas) { try { String name = searchBuilder.importString(sd); readers.add(new NamedReader(name + ApplicationPackage.SD_NAME_SUFFIX, new StringReader(sd))); @@ -184,7 +184,7 @@ public class MockApplicationPackage implements ApplicationPackage { @Override public Reader getRankingExpression(String name) { - File expressionFile = new File(searchDefinitionDir, name); + File expressionFile = new File(schemaDir, name); try { return IOUtils.createReader(expressionFile, "utf-8"); } @@ -200,9 +200,9 @@ public class MockApplicationPackage implements ApplicationPackage { public static ApplicationPackage fromSearchDefinitionDirectory(String dir) { return new MockApplicationPackage.Builder() - .withEmptyHosts() - .withEmptyServices() - .withSearchDefinitionDir(dir).build(); + .withEmptyHosts() + .withEmptyServices() + .withSchemaDir(dir).build(); } public static class Builder { @@ -210,8 +210,8 @@ public class MockApplicationPackage implements ApplicationPackage { private File root = new File("nonexisting"); private String hosts = null; private String services = null; - private List<String> searchDefinitions = Collections.emptyList(); - private String searchDefinitionDir = null; + private List<String> schemas = Collections.emptyList(); + private String schemaDir = null; private String deploymentSpec = null; private String validationOverrides = null; private boolean failOnValidateXml = false; @@ -245,17 +245,17 @@ public class MockApplicationPackage implements ApplicationPackage { } public Builder withSearchDefinition(String searchDefinition) { - this.searchDefinitions = Collections.singletonList(searchDefinition); + this.schemas = Collections.singletonList(searchDefinition); return this; } - public Builder withSearchDefinitions(List<String> searchDefinition) { - this.searchDefinitions = Collections.unmodifiableList(searchDefinition); + public Builder withSchemas(List<String> searchDefinition) { + this.schemas = Collections.unmodifiableList(searchDefinition); return this; } - public Builder withSearchDefinitionDir(String searchDefinitionDir) { - this.searchDefinitionDir = searchDefinitionDir; + public Builder withSchemaDir(String schemaDir) { + this.schemaDir = schemaDir; return this; } @@ -285,7 +285,7 @@ public class MockApplicationPackage implements ApplicationPackage { } public ApplicationPackage build() { - return new MockApplicationPackage(root, hosts, services, searchDefinitions, searchDefinitionDir, + return new MockApplicationPackage(root, hosts, services, schemas, schemaDir, deploymentSpec, validationOverrides, failOnValidateXml, queryProfile, queryProfileType); } |