diff options
author | Jon Bratseth <bratseth@gmail.com> | 2022-04-05 11:55:17 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2022-04-05 11:55:17 +0200 |
commit | c4d5eeab6702354224b06aa41975e49b55cfbf44 (patch) | |
tree | c33db0499d08f4a7f85810b9929b709d6612dcf5 /config-model/src/main | |
parent | 5973587421282738babb1be7fe1cd45acd21ddfc (diff) |
Support rank profile input WIP
Diffstat (limited to 'config-model/src/main')
21 files changed, 256 insertions, 290 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java b/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java index ac99bee93ed..1f6fd1fd022 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java @@ -61,7 +61,7 @@ import com.yahoo.vespa.model.ml.ConvertedModel; import com.yahoo.vespa.model.ml.ModelName; import com.yahoo.vespa.model.ml.OnnxModelInfo; import com.yahoo.vespa.model.routing.Routing; -import com.yahoo.vespa.model.search.AbstractSearchCluster; +import com.yahoo.vespa.model.search.SearchCluster; import com.yahoo.vespa.model.utils.internal.ReflectionUtil; import org.xml.sax.SAXException; @@ -644,7 +644,7 @@ public final class VespaModel extends AbstractConfigProducerRoot implements Seri } /** Returns all search clusters, both in Search and Content */ - public List<AbstractSearchCluster> getSearchClusters() { + public List<SearchCluster> getSearchClusters() { return Content.getSearchClusters(configModelRepo()); } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java index b977e4c657e..8893f976699 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java @@ -2,13 +2,11 @@ package com.yahoo.vespa.model.application.validation; import com.yahoo.config.model.deploy.DeployState; -import com.yahoo.document.DataType; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.ComplexAttributeFieldUtils; import com.yahoo.searchdefinition.document.GeoPos; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.vespa.model.VespaModel; -import com.yahoo.vespa.model.search.AbstractSearchCluster; import com.yahoo.vespa.model.search.SearchCluster; import java.util.ArrayList; @@ -27,14 +25,12 @@ public class ComplexAttributeFieldsValidator extends Validator { @Override public void validate(VespaModel model, DeployState deployState) { - List<AbstractSearchCluster> searchClusters = model.getSearchClusters(); - for (AbstractSearchCluster cluster : searchClusters) { - if (cluster.isStreaming()) { - continue; - } - SearchCluster searchCluster = (SearchCluster) cluster; - for (AbstractSearchCluster.SchemaSpec spec : searchCluster.getLocalSDS()) { - validateComplexFields(searchCluster.getClusterName(), spec.getSchema()); + List<SearchCluster> searchClusters = model.getSearchClusters(); + for (SearchCluster cluster : searchClusters) { + if (cluster.isStreaming()) continue; + + for (SearchCluster.SchemaSpec spec : cluster.schemas()) { + validateComplexFields(cluster.getClusterName(), spec.getSchema()); } } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/NoPrefixForIndexes.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/NoPrefixForIndexes.java index 2b474cb3b1b..32f5fef5eaa 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/NoPrefixForIndexes.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/NoPrefixForIndexes.java @@ -4,12 +4,11 @@ package com.yahoo.vespa.model.application.validation; import com.yahoo.config.model.deploy.DeployState; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.ImmutableSDField; -import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.document.MatchAlgorithm; import com.yahoo.searchdefinition.Index; import com.yahoo.searchdefinition.derived.DerivedConfiguration; import com.yahoo.vespa.model.VespaModel; -import com.yahoo.vespa.model.search.AbstractSearchCluster; +import com.yahoo.vespa.model.search.SearchCluster; import com.yahoo.vespa.model.search.DocumentDatabase; import com.yahoo.vespa.model.search.IndexedSearchCluster; @@ -17,14 +16,14 @@ import java.util.Map; /** * match:prefix for indexed fields not supported - * @author vegardh * + * @author vegardh */ public class NoPrefixForIndexes extends Validator { @Override public void validate(VespaModel model, DeployState deployState) { - for (AbstractSearchCluster cluster : model.getSearchClusters()) { + for (SearchCluster cluster : model.getSearchClusters()) { if (cluster instanceof IndexedSearchCluster) { IndexedSearchCluster sc = (IndexedSearchCluster) cluster; for (DocumentDatabase docDb : sc.getDocumentDbs()) { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankSetupValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankSetupValidator.java index 8aab07a27ad..a76efccc04e 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankSetupValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankSetupValidator.java @@ -24,7 +24,7 @@ import com.yahoo.vespa.config.search.core.RankingConstantsConfig; import com.yahoo.vespa.config.search.core.RankingExpressionsConfig; import com.yahoo.vespa.defaults.Defaults; import com.yahoo.vespa.model.VespaModel; -import com.yahoo.vespa.model.search.AbstractSearchCluster; +import com.yahoo.vespa.model.search.SearchCluster; import com.yahoo.vespa.model.search.DocumentDatabase; import com.yahoo.vespa.model.search.IndexedSearchCluster; import com.yahoo.vespa.model.search.SearchCluster; @@ -68,7 +68,7 @@ public class RankSetupValidator extends Validator { ".") .toFile(); - for (AbstractSearchCluster cluster : model.getSearchClusters()) { + for (SearchCluster cluster : model.getSearchClusters()) { // Skipping rank expression checking for streaming clusters, not implemented yet if (cluster.isStreaming()) continue; diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RoutingSelectorValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RoutingSelectorValidator.java index 7112c4b9a0a..dd0dbc744e1 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RoutingSelectorValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RoutingSelectorValidator.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.model.application.validation; import com.yahoo.config.model.deploy.DeployState; import com.yahoo.document.select.DocumentSelector; import com.yahoo.vespa.model.VespaModel; -import com.yahoo.vespa.model.search.AbstractSearchCluster; +import com.yahoo.vespa.model.search.SearchCluster; import com.yahoo.vespa.model.search.IndexedSearchCluster; @@ -15,7 +15,7 @@ public class RoutingSelectorValidator extends Validator { @Override public void validate(VespaModel model, DeployState deployState) { - for (AbstractSearchCluster cluster : model.getSearchClusters()) { + for (SearchCluster cluster : model.getSearchClusters()) { if (cluster instanceof IndexedSearchCluster) { IndexedSearchCluster sc = (IndexedSearchCluster) cluster; String routingSelector = sc.getRoutingSelector(); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/SearchDataTypeValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/SearchDataTypeValidator.java index 1379ba3fae9..0dfd12f322b 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/SearchDataTypeValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/SearchDataTypeValidator.java @@ -15,7 +15,7 @@ import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.vespa.model.VespaModel; -import com.yahoo.vespa.model.search.AbstractSearchCluster; +import com.yahoo.vespa.model.search.SearchCluster; import java.util.List; @@ -29,12 +29,12 @@ public class SearchDataTypeValidator extends Validator { @Override public void validate(VespaModel model, DeployState deployState) { - List<AbstractSearchCluster> clusters = model.getSearchClusters(); - for (AbstractSearchCluster cluster : clusters) { + List<SearchCluster> clusters = model.getSearchClusters(); + for (SearchCluster cluster : clusters) { if (cluster.isStreaming()) { continue; } - for (AbstractSearchCluster.SchemaSpec spec : cluster.getLocalSDS()) { + for (SearchCluster.SchemaSpec spec : cluster.schemas()) { SDDocumentType docType = spec.getSchema().getDocument(); if (docType == null) { continue; @@ -44,7 +44,7 @@ public class SearchDataTypeValidator extends Validator { } } - private void validateDocument(AbstractSearchCluster cluster, Schema schema, SDDocumentType doc) { + private void validateDocument(SearchCluster cluster, Schema schema, SDDocumentType doc) { for (SDDocumentType child : doc.getTypes()) { validateDocument(cluster, schema, child); } @@ -84,7 +84,7 @@ public class SearchDataTypeValidator extends Validator { } } - private void disallowIndexingOfMaps(AbstractSearchCluster cluster, Schema schema, Field field) { + private void disallowIndexingOfMaps(SearchCluster cluster, Schema schema, Field field) { DataType fieldType = field.getDataType(); if ((fieldType instanceof MapDataType) && (((SDField) field).doesIndexing())) { throw new IllegalArgumentException("Field type '" + fieldType.getName() + "' cannot be indexed for search " + diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/StreamingValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/StreamingValidator.java index 4e3d2cbb61b..e82842dbe67 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/StreamingValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/StreamingValidator.java @@ -8,16 +8,13 @@ import com.yahoo.document.NumericDataType; import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.ImmutableSDField; -import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.document.MatchType; import com.yahoo.vespa.model.VespaModel; -import com.yahoo.vespa.model.search.AbstractSearchCluster; import com.yahoo.vespa.model.search.SearchCluster; import java.util.List; import java.util.logging.Level; - /** * Validates streaming mode */ @@ -25,24 +22,23 @@ public class StreamingValidator extends Validator { @Override public void validate(VespaModel model, DeployState deployState) { - List<AbstractSearchCluster> searchClusters = model.getSearchClusters(); - for (AbstractSearchCluster cluster : searchClusters) { - if (!cluster.isStreaming()) { - continue; - } - SearchCluster sc = (SearchCluster) cluster; - warnStreamingAttributes(sc, deployState.getDeployLogger()); - warnStreamingGramMatching(sc, deployState.getDeployLogger()); - failStreamingDocumentReferences(sc); + List<SearchCluster> searchClusters = model.getSearchClusters(); + for (SearchCluster cluster : searchClusters) { + if ( ! cluster.isStreaming()) continue; + warnStreamingAttributes(cluster, deployState.getDeployLogger()); + warnStreamingGramMatching(cluster, deployState.getDeployLogger()); + failStreamingDocumentReferences(cluster); } } private static void warnStreamingGramMatching(SearchCluster sc, DeployLogger logger) { - if (sc.getSdConfig() != null) { - for (ImmutableSDField sd : sc.getSdConfig().getSearch().allConcreteFields()) { - if (sd.getMatching().getType().equals(MatchType.GRAM)) { - logger.logApplicationPackage(Level.WARNING, "For streaming search cluster '" + sc.getClusterName() + - "', SD field '" + sd.getName() + "': n-gram matching is not supported for streaming search."); + if (sc.getSchemaConfig() != null) { + for (ImmutableSDField sd : sc.getSchemaConfig().getSearch().allConcreteFields()) { + if (sd.getMatching().getType() == MatchType.GRAM) { + logger.logApplicationPackage(Level.WARNING, "For streaming search cluster '" + + sc.getClusterName() + + "', SD field '" + sd.getName() + + "': n-gram matching is not supported for streaming search."); } } } @@ -55,8 +51,8 @@ public class StreamingValidator extends Validator { * @param logger a DeployLogger */ private static void warnStreamingAttributes(SearchCluster sc, DeployLogger logger) { - if (sc.getSdConfig() != null) { - for (ImmutableSDField sd : sc.getSdConfig().getSearch().allConcreteFields()) { + if (sc.getSchemaConfig() != null) { + for (ImmutableSDField sd : sc.getSchemaConfig().getSearch().allConcreteFields()) { if (sd.doesAttributing()) { warnStreamingAttribute(sc, sd, logger); } @@ -69,19 +65,20 @@ public class StreamingValidator extends Validator { // attribute indexing ourselves (IntegerIndex2Attribute) if (sd.getDataType() instanceof NumericDataType) return; logger.logApplicationPackage(Level.WARNING, "For streaming search cluster '" + sc.getClusterName() + - "', SD field '" + sd.getName() + "': 'attribute' has same match semantics as 'index'."); + "', SD field '" + sd.getName() + + "': 'attribute' has same match semantics as 'index'."); } private static void failStreamingDocumentReferences(SearchCluster sc) { - for (Attribute attribute : sc.getSdConfig().getAttributeFields().attributes()) { + for (Attribute attribute : sc.getSchemaConfig().getAttributeFields().attributes()) { DataType dataType = attribute.getDataType(); if (dataType instanceof NewDocumentReferenceDataType) { - String errorMessage = String.format( - "For streaming search cluster '%s': Attribute '%s' has type '%s'. " + - "Document references and imported fields are not allowed in streaming search.", - sc.getClusterName(), attribute.getName(), dataType.getName()); + String errorMessage = String.format("For streaming search cluster '%s': Attribute '%s' has type '%s'. " + + "Document references and imported fields are not allowed in streaming search.", + sc.getClusterName(), attribute.getName(), dataType.getName()); throw new IllegalArgumentException(errorMessage); } } } + } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/StreamingSearchClusterChangeValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/StreamingSearchClusterChangeValidator.java index 11aab9f555b..2820d0984db 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/StreamingSearchClusterChangeValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/StreamingSearchClusterChangeValidator.java @@ -64,11 +64,11 @@ public class StreamingSearchClusterChangeValidator implements ChangeValidator { getDocumentType(currentCluster, currentStreamingCluster), getDocumentType(nextCluster, nextStreamingCluster), overrides, now)); result.addAll(validateAttributeFastAccessAdded(currentCluster.id(), - currentStreamingCluster.getSdConfig().getAttributeFields(), - nextStreamingCluster.getSdConfig().getAttributeFields())); + currentStreamingCluster.getSchemaConfig().getAttributeFields(), + nextStreamingCluster.getSchemaConfig().getAttributeFields())); result.addAll(validateAttributeFastAccessRemoved(currentCluster.id(), - currentStreamingCluster.getSdConfig().getAttributeFields(), - nextStreamingCluster.getSdConfig().getAttributeFields())); + currentStreamingCluster.getSchemaConfig().getAttributeFields(), + nextStreamingCluster.getSchemaConfig().getAttributeFields())); return modifyActions(result, getSearchNodeServices(nextCluster), nextStreamingCluster.getDocTypeName()); } 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 0be3ac01f71..df77d83da83 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 @@ -23,7 +23,7 @@ import com.yahoo.vespa.model.container.docproc.ContainerDocproc; import com.yahoo.vespa.model.content.Content; import com.yahoo.vespa.model.generic.builder.DomServiceClusterBuilder; import com.yahoo.vespa.model.generic.service.ServiceCluster; -import com.yahoo.vespa.model.search.AbstractSearchCluster; +import com.yahoo.vespa.model.search.SearchCluster; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -295,7 +295,7 @@ public class VespaDomBuilder extends VespaModelBuilder { */ private void setContentSearchClusterIndexes(ConfigModelRepo configModelRepo) { int index = 0; - for (AbstractSearchCluster sc : Content.getSearchClusters(configModelRepo)) { + for (SearchCluster sc : Content.getSearchClusters(configModelRepo)) { sc.setClusterIndex(index++); } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java index b6ce1a7f457..6295418ca38 100755 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java @@ -57,7 +57,7 @@ import com.yahoo.vespa.model.container.processing.ProcessingChains; import com.yahoo.vespa.model.container.search.ContainerSearch; import com.yahoo.vespa.model.container.search.searchchain.SearchChains; import com.yahoo.vespa.model.content.Content; -import com.yahoo.vespa.model.search.AbstractSearchCluster; +import com.yahoo.vespa.model.search.SearchCluster; import java.nio.file.Path; import java.util.ArrayList; @@ -537,7 +537,7 @@ public abstract class ContainerCluster<CONTAINER extends Container> if (containerSearch != null) containerSearch.getConfig(builder); } - public void initialize(Map<String, AbstractSearchCluster> clusterMap) { + public void initialize(Map<String, SearchCluster> clusterMap) { if (containerSearch != null) containerSearch.connectSearchClusters(clusterMap); } @@ -548,9 +548,9 @@ public abstract class ContainerCluster<CONTAINER extends Container> @Override public void getConfig(IlscriptsConfig.Builder builder) { - List<AbstractSearchCluster> searchClusters = new ArrayList<>(); + List<SearchCluster> searchClusters = new ArrayList<>(); searchClusters.addAll(Content.getSearchClusters(getRoot().configModelRepo())); - for (AbstractSearchCluster searchCluster : searchClusters) { + for (SearchCluster searchCluster : searchClusters) { searchCluster.getConfig(builder); } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerModel.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerModel.java index 0a073a65ac6..62b326de2df 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerModel.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerModel.java @@ -6,7 +6,7 @@ import com.yahoo.config.model.ConfigModelContext; import com.yahoo.config.model.ConfigModelRepo; import com.yahoo.config.model.deploy.DeployState; import com.yahoo.vespa.model.content.Content; -import com.yahoo.vespa.model.search.AbstractSearchCluster; +import com.yahoo.vespa.model.search.SearchCluster; import java.util.ArrayList; import java.util.Collection; @@ -45,10 +45,10 @@ public class ContainerModel extends ConfigModel { @Override public void initialize(ConfigModelRepo configModelRepo) { - List<AbstractSearchCluster> searchClusters = Content.getSearchClusters(configModelRepo); + List<SearchCluster> searchClusters = Content.getSearchClusters(configModelRepo); - Map<String, AbstractSearchCluster> searchClustersByName = new TreeMap<>(); - for (AbstractSearchCluster c : searchClusters) + Map<String, SearchCluster> searchClustersByName = new TreeMap<>(); + for (SearchCluster c : searchClusters) searchClustersByName.put(c.getClusterName(), c); getCluster().initialize(searchClustersByName); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java index e0b7c3b288a..e7308c6f6ca 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java @@ -12,7 +12,7 @@ import com.yahoo.vespa.model.container.ApplicationContainerCluster; import com.yahoo.vespa.model.container.component.Component; import com.yahoo.vespa.model.container.component.ContainerSubsystem; import com.yahoo.vespa.model.container.search.searchchain.SearchChains; -import com.yahoo.vespa.model.search.AbstractSearchCluster; +import com.yahoo.vespa.model.search.SearchCluster; import com.yahoo.vespa.model.search.IndexedSearchCluster; import com.yahoo.vespa.model.search.StreamingSearchCluster; @@ -40,7 +40,7 @@ public class ContainerSearch extends ContainerSubsystem<SearchChains> public static final String QUERY_PROFILE_REGISTRY_CLASS = CompiledQueryProfileRegistry.class.getName(); private ApplicationContainerCluster owningCluster; - private final List<AbstractSearchCluster> searchClusters = new LinkedList<>(); + private final List<SearchCluster> searchClusters = new LinkedList<>(); private final Options options; private QueryProfiles queryProfiles; @@ -55,15 +55,15 @@ public class ContainerSearch extends ContainerSubsystem<SearchChains> owningCluster.addComponent(Component.fromClassAndBundle(QUERY_PROFILE_REGISTRY_CLASS, searchAndDocprocBundle)); } - public void connectSearchClusters(Map<String, AbstractSearchCluster> searchClusters) { + public void connectSearchClusters(Map<String, SearchCluster> searchClusters) { this.searchClusters.addAll(searchClusters.values()); initializeDispatchers(searchClusters.values()); initializeSearchChains(searchClusters); } /** Adds a Dispatcher component to the owning container cluster for each search cluster */ - private void initializeDispatchers(Collection<AbstractSearchCluster> searchClusters) { - for (AbstractSearchCluster searchCluster : searchClusters) { + private void initializeDispatchers(Collection<SearchCluster> searchClusters) { + for (SearchCluster searchCluster : searchClusters) { if ( ! ( searchCluster instanceof IndexedSearchCluster)) continue; var dispatcher = new DispatcherComponent((IndexedSearchCluster)searchCluster); owningCluster.addComponent(dispatcher); @@ -71,7 +71,7 @@ public class ContainerSearch extends ContainerSubsystem<SearchChains> } // public for testing - public void initializeSearchChains(Map<String, ? extends AbstractSearchCluster> searchClusters) { + public void initializeSearchChains(Map<String, ? extends SearchCluster> searchClusters) { getChains().initialize(searchClusters); } @@ -106,14 +106,14 @@ public class ContainerSearch extends ContainerSubsystem<SearchChains> @Override public void getConfig(IndexInfoConfig.Builder builder) { - for (AbstractSearchCluster sc : searchClusters) { + for (SearchCluster sc : searchClusters) { sc.getConfig(builder); } } @Override public void getConfig(IlscriptsConfig.Builder builder) { - for (AbstractSearchCluster sc : searchClusters) { + for (SearchCluster sc : searchClusters) { sc.getConfig(builder); } } @@ -121,10 +121,10 @@ public class ContainerSearch extends ContainerSubsystem<SearchChains> @Override public void getConfig(QrSearchersConfig.Builder builder) { for (int i = 0; i < searchClusters.size(); i++) { - AbstractSearchCluster sys = findClusterWithId(searchClusters, i); + SearchCluster sys = findClusterWithId(searchClusters, i); QrSearchersConfig.Searchcluster.Builder scB = new QrSearchersConfig.Searchcluster.Builder(). name(sys.getClusterName()); - for (AbstractSearchCluster.SchemaSpec spec : sys.getLocalSDS()) { + for (SearchCluster.SchemaSpec spec : sys.schemas()) { scB.searchdef(spec.getSchema().getName()); } scB.rankprofiles(new QrSearchersConfig.Searchcluster.Rankprofiles.Builder().configid(sys.getConfigId())); @@ -137,8 +137,8 @@ public class ContainerSearch extends ContainerSubsystem<SearchChains> } } - private static AbstractSearchCluster findClusterWithId(List<AbstractSearchCluster> clusters, int index) { - for (AbstractSearchCluster sys : clusters) { + private static SearchCluster findClusterWithId(List<SearchCluster> clusters, int index) { + for (SearchCluster sys : clusters) { if (sys.getClusterIndex() == index) return sys; } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/LocalProvider.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/LocalProvider.java index 7eefa2e5e74..a2ec1013b65 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/LocalProvider.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/LocalProvider.java @@ -12,7 +12,7 @@ import com.yahoo.vespa.config.search.AttributesConfig; import com.yahoo.search.config.ClusterConfig; import com.yahoo.search.searchchain.model.federation.FederationOptions; import com.yahoo.search.searchchain.model.federation.LocalProviderSpec; -import com.yahoo.vespa.model.search.AbstractSearchCluster; +import com.yahoo.vespa.model.search.SearchCluster; import java.util.ArrayList; import java.util.LinkedHashSet; @@ -32,7 +32,7 @@ public class LocalProvider extends Provider implements RankProfilesConfig.Producer { private final LocalProviderSpec providerSpec; - private volatile AbstractSearchCluster searchCluster; + private volatile SearchCluster searchCluster; @Override @@ -99,7 +99,7 @@ public class LocalProvider extends Provider implements return providerSpec.clusterName; } - void setSearchCluster(AbstractSearchCluster searchCluster) { + void setSearchCluster(SearchCluster searchCluster) { this.searchCluster = searchCluster; } @@ -115,7 +115,7 @@ public class LocalProvider extends Provider implements public List<String> getDocumentTypes() { List<String> documentTypes = new ArrayList<>(); - for (AbstractSearchCluster.SchemaSpec spec : searchCluster.getLocalSDS()) { + for (SearchCluster.SchemaSpec spec : searchCluster.schemas()) { documentTypes.add(spec.getSchema().getDocument().getName()); } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/SearchChains.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/SearchChains.java index a71e1936425..739ff0e5e69 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/SearchChains.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/SearchChains.java @@ -5,7 +5,7 @@ import com.yahoo.collections.CollectionUtil; import com.yahoo.component.provider.ComponentRegistry; import com.yahoo.config.model.producer.AbstractConfigProducer; import com.yahoo.vespa.model.container.component.chain.Chains; -import com.yahoo.vespa.model.search.AbstractSearchCluster; +import com.yahoo.vespa.model.search.SearchCluster; import com.yahoo.vespa.model.container.search.searchchain.defaultsearchchains.LocalClustersCreator; import com.yahoo.vespa.model.container.search.searchchain.defaultsearchchains.VespaSearchChainsCreator; @@ -25,7 +25,7 @@ public class SearchChains extends Chains<SearchChain> { super(parent, subId); } - public void initialize(Map<String, ? extends AbstractSearchCluster> searchClustersByName) { + public void initialize(Map<String, ? extends SearchCluster> searchClustersByName) { LocalClustersCreator.addDefaultLocalProviders(this, searchClustersByName.keySet()); VespaSearchChainsCreator.addVespaSearchChains(this); @@ -33,14 +33,14 @@ public class SearchChains extends Chains<SearchChain> { initializeComponents(searchClustersByName); } - private void initializeComponents(Map<String, ? extends AbstractSearchCluster> searchClustersByName) { + private void initializeComponents(Map<String, ? extends SearchCluster> searchClustersByName) { setSearchClusterForLocalProvider(searchClustersByName); initializeComponents(); } - private void setSearchClusterForLocalProvider(Map<String, ? extends AbstractSearchCluster> clusterIndexByName) { + private void setSearchClusterForLocalProvider(Map<String, ? extends SearchCluster> clusterIndexByName) { for (LocalProvider provider : localProviders()) { - AbstractSearchCluster cluster = clusterIndexByName.get(provider.getClusterName()); + SearchCluster cluster = clusterIndexByName.get(provider.getClusterName()); if (cluster == null) throw new IllegalArgumentException("No searchable content cluster with id '" + provider.getClusterName() + "'"); provider.setSearchCluster(cluster); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java b/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java index dcf0be48f7b..d4595b3adfd 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java @@ -26,9 +26,9 @@ import com.yahoo.vespa.model.container.docproc.ContainerDocproc; import com.yahoo.vespa.model.container.docproc.DocprocChain; import com.yahoo.vespa.model.container.docproc.DocprocChains; import com.yahoo.vespa.model.content.cluster.ContentCluster; -import com.yahoo.vespa.model.search.AbstractSearchCluster; import com.yahoo.vespa.model.search.IndexedSearchCluster; import com.yahoo.vespa.model.search.IndexingDocprocChain; +import com.yahoo.vespa.model.search.SearchCluster; import com.yahoo.vespa.model.search.SearchNode; import org.w3c.dom.Element; @@ -130,8 +130,8 @@ public class Content extends ConfigModel { return contents; } - public static List<AbstractSearchCluster> getSearchClusters(ConfigModelRepo pc) { - List<AbstractSearchCluster> clusters = new ArrayList<>(); + public static List<SearchCluster> getSearchClusters(ConfigModelRepo pc) { + List<SearchCluster> clusters = new ArrayList<>(); for (ContentCluster c : getContentClusters(pc)) clusters.addAll(c.getSearch().getClusters().values()); return clusters; diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java index 22b752777e9..4b696f75f11 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java @@ -13,7 +13,6 @@ import com.yahoo.vespa.model.builder.xml.dom.DomSearchTuningBuilder; import com.yahoo.vespa.model.builder.xml.dom.ModelElement; import com.yahoo.vespa.model.builder.xml.dom.VespaDomBuilder; import com.yahoo.vespa.model.content.cluster.ContentCluster; -import com.yahoo.vespa.model.search.AbstractSearchCluster; import com.yahoo.vespa.model.search.IndexedSearchCluster; import com.yahoo.vespa.model.search.NodeSpec; import com.yahoo.vespa.model.search.SchemaDefinitionXMLHandler; @@ -50,7 +49,7 @@ public class ContentSearchCluster extends AbstractConfigProducer<SearchCluster> private final Boolean syncTransactionLog; /** If this is set up for streaming search, it is modelled as one search cluster per search definition */ - private final Map<String, AbstractSearchCluster> clusters = new TreeMap<>(); + private final Map<String, SearchCluster> clusters = new TreeMap<>(); /** The single, indexed search cluster this sets up (supporting multiple document types), or null if none */ private IndexedSearchCluster indexedCluster; @@ -150,7 +149,11 @@ public class ContentSearchCluster extends AbstractConfigProducer<SearchCluster> private void buildStreamingSearchCluster(DeployState deployState, ModelElement clusterElem, String clusterName, ContentSearchCluster search, ModelElement docType) { String docTypeName = docType.stringAttribute("type"); - StreamingSearchCluster cluster = new StreamingSearchCluster(search, clusterName + "." + docTypeName, 0, docTypeName, clusterName); + StreamingSearchCluster cluster = new StreamingSearchCluster(search, + clusterName + "." + docTypeName, + 0, + docTypeName, + clusterName); search.addSearchCluster(deployState, cluster, getQueryTimeout(clusterElem), Arrays.asList(docType)); } @@ -256,7 +259,7 @@ public class ContentSearchCluster extends AbstractConfigProducer<SearchCluster> addCluster(cluster); } - private void addSchemas(DeployState deployState, List<ModelElement> searchDefs, AbstractSearchCluster sc) { + private void addSchemas(DeployState deployState, List<ModelElement> searchDefs, SearchCluster sc) { for (ModelElement e : searchDefs) { SchemaDefinitionXMLHandler schemaDefinitionXMLHandler = new SchemaDefinitionXMLHandler(e); Schema schema = schemaDefinitionXMLHandler.findResponsibleSchema(deployState.getSchemas()); @@ -265,13 +268,13 @@ public class ContentSearchCluster extends AbstractConfigProducer<SearchCluster> this + " does not exist"); // TODO: remove explicit building of user configs when the complete content model is built using builders. - sc.getLocalSDS().add(new AbstractSearchCluster.SchemaSpec(schema, - UserConfigBuilder.build(e.getXml(), deployState, deployState.getDeployLogger()))); + sc.schemas().add(new SearchCluster.SchemaSpec(schema, + UserConfigBuilder.build(e.getXml(), deployState, deployState.getDeployLogger()))); sc.addDocumentNames(schema); } } - private void addCluster(AbstractSearchCluster sc) { + private void addCluster(SearchCluster sc) { if (clusters.containsKey(sc.getClusterName())) { throw new IllegalArgumentException("Duplicate cluster '" + sc.getClusterName() + "'"); } @@ -353,7 +356,7 @@ public class ContentSearchCluster extends AbstractConfigProducer<SearchCluster> return getClusters().values().stream() .filter(StreamingSearchCluster.class::isInstance) .map(StreamingSearchCluster.class::cast) - .filter(ssc -> ssc.getSdConfig().getSearch().getName().equals(docType)) + .filter(ssc -> ssc.getSchemaConfig().getSearch().getName().equals(docType)) .findFirst(); } @@ -466,7 +469,7 @@ public class ContentSearchCluster extends AbstractConfigProducer<SearchCluster> } } - public Map<String, AbstractSearchCluster> getClusters() { return clusters; } + public Map<String, SearchCluster> getClusters() { return clusters; } public IndexedSearchCluster getIndexed() { return indexedCluster; } public boolean hasIndexedCluster() { return indexedCluster != null; } public String getClusterName() { return clusterName; } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/StorageNode.java b/config-model/src/main/java/com/yahoo/vespa/model/content/StorageNode.java index 529f4dbc9fd..1bdd281d38e 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/content/StorageNode.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/content/StorageNode.java @@ -30,11 +30,13 @@ public class StorageNode extends ContentNode implements StorServerConfig.Produce private final StorageCluster cluster; public static class Builder extends VespaDomBuilder.DomConfigProducerBuilder<StorageNode> { + @Override - protected StorageNode doBuild(DeployState deployState, AbstractConfigProducer ancestor, Element producerSpec) { + protected StorageNode doBuild(DeployState deployState, AbstractConfigProducer<?> ancestor, Element producerSpec) { ModelElement e = new ModelElement(producerSpec); return new StorageNode(deployState.getProperties(), (StorageCluster)ancestor, e.doubleAttribute("capacity"), e.integerAttribute("distribution-key"), false); } + } StorageNode(ModelContext.Properties properties, StorageCluster cluster, Double capacity, int distributionKey, boolean retired) { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/AbstractSearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/search/AbstractSearchCluster.java deleted file mode 100644 index 93a264ae4bb..00000000000 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/AbstractSearchCluster.java +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.search; - -import com.yahoo.config.model.producer.AbstractConfigProducer; -import com.yahoo.config.model.producer.UserConfigRepo; -import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig; -import com.yahoo.search.config.IndexInfoConfig; -import com.yahoo.searchdefinition.Schema; -import com.yahoo.vespa.config.search.AttributesConfig; -import com.yahoo.vespa.config.search.RankProfilesConfig; -import com.yahoo.vespa.configdefinition.IlscriptsConfig; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * Superclass for search clusters. - * - * @author Peter Boros - */ -public abstract class AbstractSearchCluster extends AbstractConfigProducer<AbstractSearchCluster> - implements - DocumentdbInfoConfig.Producer, - IndexInfoConfig.Producer, - IlscriptsConfig.Producer { - - private Double queryTimeout; - protected String clusterName; - protected int index; - private Double visibilityDelay = 0.0; - private final List<String> documentNames = new ArrayList<>(); - private final List<SchemaSpec> localSDS = new LinkedList<>(); - - public AbstractSearchCluster(AbstractConfigProducer<?> parent, String clusterName, int index) { - super(parent, "cluster." + clusterName); - this.clusterName = clusterName; - this.index = index; - } - - public void addDocumentNames(Schema schema) { - documentNames.add(schema.getDocument().getDocumentName().getName()); - } - - /** Returns a List with document names used in this search cluster */ - public List<String> getDocumentNames() { return documentNames; } - - public List<SchemaSpec> getLocalSDS() { - return localSDS; - } - - public String getClusterName() { return clusterName; } - public final String getIndexingModeName() { return getIndexingMode().getName(); } - public final boolean isStreaming() { return getIndexingMode() == IndexingMode.STREAMING; } - - public final AbstractSearchCluster setQueryTimeout(Double to) { - this.queryTimeout = to; - return this; - } - - public final AbstractSearchCluster setVisibilityDelay(double delay) { - this.visibilityDelay = delay; - return this; - } - - protected abstract IndexingMode getIndexingMode(); - public final Double getVisibilityDelay() { return visibilityDelay; } - public final Double getQueryTimeout() { return queryTimeout; } - public abstract int getRowBits(); - public final void setClusterIndex(int index) { this.index = index; } - public final int getClusterIndex() { return index; } - - @Override - public abstract void getConfig(DocumentdbInfoConfig.Builder builder); - @Override - public abstract void getConfig(IndexInfoConfig.Builder builder); - @Override - public abstract void getConfig(IlscriptsConfig.Builder builder); - public abstract void getConfig(RankProfilesConfig.Builder builder); - public abstract void getConfig(AttributesConfig.Builder builder); - - @Override - public String toString() { return "search-capable cluster '" + clusterName + "'"; } - - public static final class IndexingMode { - - public static final IndexingMode REALTIME = new IndexingMode("REALTIME"); - public static final IndexingMode STREAMING = new IndexingMode("STREAMING"); - - private final String name; - - private IndexingMode(String name) { - this.name = name; - } - - public String getName() { return name; } - - public String toString() { - return "indexingmode: " + name; - } - } - - public static final class SchemaSpec { - - private final Schema schema; - private final UserConfigRepo userConfigRepo; - - public SchemaSpec(Schema schema, UserConfigRepo userConfigRepo) { - this.schema = schema; - this.userConfigRepo = userConfigRepo; - } - - public Schema getSchema() { - return schema; - } - - public UserConfigRepo getUserConfigs() { - return userConfigRepo; - } - } - -} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java index ddd4656484d..95a2e89a610 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java @@ -6,6 +6,7 @@ import com.yahoo.config.model.producer.AbstractConfigProducer; import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig; import com.yahoo.search.config.IndexInfoConfig; import com.yahoo.searchdefinition.DocumentOnlySchema; +import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.derived.DerivedConfiguration; import com.yahoo.vespa.config.search.AttributesConfig; import com.yahoo.vespa.config.search.DispatchConfig; @@ -56,7 +57,7 @@ public class IndexedSearchCluster extends SearchCluster * Returns the document selector that is able to resolve what documents are to be routed to this search cluster. * This string uses the document selector language as defined in the "document" module. * - * @return The document selector. + * @return the document selector */ public String getRoutingSelector() { return routingSelector; @@ -119,7 +120,7 @@ public class IndexedSearchCluster extends SearchCluster * @param chain the chain that is to run indexing for this cluster * @return this, to allow chaining */ - public AbstractSearchCluster setIndexingChain(DocprocChain chain) { + public SearchCluster setIndexingChain(DocprocChain chain) { indexingChain = chain; return this; } @@ -166,8 +167,8 @@ public class IndexedSearchCluster extends SearchCluster } } - public void setRoutingSelector(String sel) { - this.routingSelector=sel; + public void setRoutingSelector(String selector) { + this.routingSelector = selector; if (this.routingSelector != null) { try { new DocumentSelectionConverter(this.routingSelector); @@ -193,8 +194,8 @@ public class IndexedSearchCluster extends SearchCluster } @Override - protected void deriveAllSchemas(List<SchemaSpec> localSearches, DeployState deployState) { - for (SchemaSpec spec : localSearches) { + protected void deriveAllSchemas(List<SchemaSpec> localSchemas, DeployState deployState) { + for (SchemaSpec spec : localSchemas) { if ( ! (spec.getSchema() instanceof DocumentOnlySchema)) { DocumentDatabase db = new DocumentDatabase(this, spec.getSchema().getName(), new DerivedConfiguration(spec.getSchema(), @@ -228,7 +229,7 @@ public class IndexedSearchCluster extends SearchCluster } @Override - public DerivedConfiguration getSdConfig() { return null; } + public DerivedConfiguration getSchemaConfig() { return null; } @Override public void getConfig(IndexInfoConfig.Builder builder) { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java index b128f391e72..b188f22053d 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java @@ -2,6 +2,8 @@ package com.yahoo.vespa.model.search; import com.yahoo.config.model.deploy.DeployState; +import com.yahoo.config.model.producer.UserConfigRepo; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.derived.RawRankProfile; import com.yahoo.searchdefinition.derived.SummaryMap; import com.yahoo.vespa.config.search.RankProfilesConfig; @@ -14,8 +16,7 @@ import com.yahoo.vespa.configdefinition.IlscriptsConfig; import com.yahoo.searchdefinition.derived.DerivedConfiguration; import com.yahoo.config.model.producer.AbstractConfigProducer; -import java.io.File; -import java.io.IOException; +import java.util.ArrayList; import java.util.List; /** @@ -23,44 +24,33 @@ import java.util.List; * * @author arnej27959 */ -public abstract class SearchCluster extends AbstractSearchCluster +public abstract class SearchCluster extends AbstractConfigProducer<SearchCluster> implements DocumentdbInfoConfig.Producer, IndexInfoConfig.Producer, IlscriptsConfig.Producer { - protected SearchCluster(AbstractConfigProducer<SearchCluster> parent, String clusterName, int index) { - super(parent, clusterName, index); + private final String clusterName; + private int index; + private Double queryTimeout; + private Double visibilityDelay = 0.0; + private final List<String> documentNames = new ArrayList<>(); + private final List<SchemaSpec> schemas = new ArrayList<>(); + + public SearchCluster(AbstractConfigProducer<?> parent, String clusterName, int index) { + super(parent, "cluster." + clusterName); + this.clusterName = clusterName; + this.index = index; } - /** - * Must be called after cluster is built, to derive SD configs - * Derives the search definitions from the application package.. + /** + * Must be called after cluster is built, to derive schema configs + * Derives the search definitions from the application package. * Also stores the document names contained in the search * definitions. */ public void deriveSchemas(DeployState deployState) { - deriveAllSchemas(getLocalSDS(), deployState); - } - - @Override - public void getConfig(IndexInfoConfig.Builder builder) { - if (getSdConfig()!=null) getSdConfig().getIndexInfo().getConfig(builder); - } - - @Override - public void getConfig(IlscriptsConfig.Builder builder) { - if (getSdConfig()!=null) getSdConfig().getIndexingScript().getConfig(builder); - } - - @Override - public void getConfig(AttributesConfig.Builder builder) { - if (getSdConfig()!=null) getSdConfig().getConfig(builder); - } - - @Override - public void getConfig(RankProfilesConfig.Builder builder) { - if (getSdConfig()!=null) getSdConfig().getRankProfileList().getConfig(builder); + deriveAllSchemas(schemas(), deployState); } /** @@ -130,9 +120,103 @@ public abstract class SearchCluster extends AbstractSearchCluster return false; } - protected abstract void deriveAllSchemas(List<SchemaSpec> localSearches, DeployState deployState); + public void addDocumentNames(Schema schema) { + documentNames.add(schema.getDocument().getDocumentName().getName()); + } + + /** Returns a List with document names used in this search cluster */ + public List<String> getDocumentNames() { return documentNames; } + + /** Returns the schemas active in this cluster. */ + public List<SchemaSpec> schemas() { return schemas; } + + public String getClusterName() { return clusterName; } + public final String getIndexingModeName() { return getIndexingMode().getName(); } + public final boolean isStreaming() { return getIndexingMode() == IndexingMode.STREAMING; } + + public final SearchCluster setQueryTimeout(Double to) { + this.queryTimeout = to; + return this; + } + + public final SearchCluster setVisibilityDelay(double delay) { + this.visibilityDelay = delay; + return this; + } + + protected abstract IndexingMode getIndexingMode(); + public final Double getVisibilityDelay() { return visibilityDelay; } + public final Double getQueryTimeout() { return queryTimeout; } + public abstract int getRowBits(); + public final void setClusterIndex(int index) { this.index = index; } + public final int getClusterIndex() { return index; } + + protected abstract void deriveAllSchemas(List<SchemaSpec> localSchemas, DeployState deployState); public abstract void defaultDocumentsConfig(); - public abstract DerivedConfiguration getSdConfig(); + public abstract DerivedConfiguration getSchemaConfig(); + + @Override + public void getConfig(IndexInfoConfig.Builder builder) { + if (getSchemaConfig() != null) getSchemaConfig().getIndexInfo().getConfig(builder); + } + + @Override + public void getConfig(IlscriptsConfig.Builder builder) { + if (getSchemaConfig() != null) getSchemaConfig().getIndexingScript().getConfig(builder); + } + + // TODO: Remove? + public void getConfig(AttributesConfig.Builder builder) { + if (getSchemaConfig() != null) getSchemaConfig().getConfig(builder); + } + + // TODO: Remove? + public void getConfig(RankProfilesConfig.Builder builder) { + if (getSchemaConfig() != null) getSchemaConfig().getRankProfileList().getConfig(builder); + } + + @Override + public abstract void getConfig(DocumentdbInfoConfig.Builder builder); + + @Override + public String toString() { return "search-capable cluster '" + clusterName + "'"; } + + public static final class IndexingMode { + + public static final IndexingMode REALTIME = new IndexingMode("REALTIME"); + public static final IndexingMode STREAMING = new IndexingMode("STREAMING"); + + private final String name; + + private IndexingMode(String name) { + this.name = name; + } + + public String getName() { return name; } + + public String toString() { + return "indexingmode: " + name; + } + } + + public static final class SchemaSpec { + + private final Schema schema; + private final UserConfigRepo userConfigRepo; + + public SchemaSpec(Schema schema, UserConfigRepo userConfigRepo) { + this.schema = schema; + this.userConfigRepo = userConfigRepo; + } + + public Schema getSchema() { + return schema; + } + + public UserConfigRepo getUserConfigs() { + return userConfigRepo; + } + } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/StreamingSearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/search/StreamingSearchCluster.java index 42bb2a1da29..2dd58bbf94e 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/StreamingSearchCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/search/StreamingSearchCluster.java @@ -27,28 +27,18 @@ public class StreamingSearchCluster extends SearchCluster implements VsmsummaryConfig.Producer, VsmfieldsConfig.Producer, SummarymapConfig.Producer, - SummaryConfig.Producer -{ - - private class AttributesProducer extends AbstractConfigProducer<AttributesProducer> implements AttributesConfig.Producer { - AttributesProducer(AbstractConfigProducer<?> parent, String docType) { - super(parent, docType); - } - - @Override - public void getConfig(AttributesConfig.Builder builder) { - if (getSdConfig() != null) { - getSdConfig().getConfig(builder, AttributeFields.FieldSet.FAST_ACCESS); - } - } - } + SummaryConfig.Producer { private final String storageRouteSpec; private final AttributesProducer attributesConfig; private final String docTypeName; private DerivedConfiguration sdConfig = null; - public StreamingSearchCluster(AbstractConfigProducer<SearchCluster> parent, String clusterName, int index, String docTypeName, String storageRouteSpec) { + public StreamingSearchCluster(AbstractConfigProducer<SearchCluster> parent, + String clusterName, + int index, + String docTypeName, + String storageRouteSpec) { super(parent, clusterName, index); attributesConfig = new AttributesProducer(parent, docTypeName); this.docTypeName = docTypeName; @@ -86,10 +76,11 @@ public class StreamingSearchCluster extends SearchCluster implements protected void deriveAllSchemas(List<SchemaSpec> local, DeployState deployState) { if (local.size() == 1) { deriveSingleSearchDefinition(local.get(0).getSchema(), deployState); - } else if (local.size() > 1){ + } else if (local.size() > 1) { throw new IllegalArgumentException("Only a single schema is supported, got " + local.size()); } } + private void deriveSingleSearchDefinition(Schema localSchema, DeployState deployState) { if (!localSchema.getName().equals(docTypeName)) { throw new IllegalArgumentException("Document type name '" + docTypeName + @@ -102,8 +93,9 @@ public class StreamingSearchCluster extends SearchCluster implements deployState.getImportedModels(), deployState.getExecutor()); } + @Override - public DerivedConfiguration getSdConfig() { + public DerivedConfiguration getSchemaConfig() { return sdConfig; } @@ -112,35 +104,49 @@ public class StreamingSearchCluster extends SearchCluster implements @Override public void getConfig(AttributesConfig.Builder builder) { - if (getSdConfig()!=null) getSdConfig().getConfig(builder); + if (getSchemaConfig() != null) getSchemaConfig().getConfig(builder); } @Override public void getConfig(VsmsummaryConfig.Builder builder) { - if (getSdConfig()!=null) - if (getSdConfig().getVsmSummary()!=null) - getSdConfig().getVsmSummary().getConfig(builder); + if (getSchemaConfig() != null) + if (getSchemaConfig().getVsmSummary() != null) + getSchemaConfig().getVsmSummary().getConfig(builder); } @Override public void getConfig(VsmfieldsConfig.Builder builder) { - if (getSdConfig()!=null) - if (getSdConfig().getVsmFields()!=null) - getSdConfig().getVsmFields().getConfig(builder); + if (getSchemaConfig() != null) + if (getSchemaConfig().getVsmFields() != null) + getSchemaConfig().getVsmFields().getConfig(builder); } @Override public void getConfig(SummarymapConfig.Builder builder) { - if (getSdConfig()!=null) - if (getSdConfig().getSummaryMap()!=null) - getSdConfig().getSummaryMap().getConfig(builder); + if (getSchemaConfig() != null) + if (getSchemaConfig().getSummaryMap() != null) + getSchemaConfig().getSummaryMap().getConfig(builder); } @Override public void getConfig(SummaryConfig.Builder builder) { - if (getSdConfig()!=null) - if (getSdConfig().getSummaries()!=null) - getSdConfig().getSummaries().getConfig(builder); + if (getSchemaConfig() != null) + if (getSchemaConfig().getSummaries() != null) + getSchemaConfig().getSummaries().getConfig(builder); + } + + private class AttributesProducer extends AbstractConfigProducer<AttributesProducer> implements AttributesConfig.Producer { + + AttributesProducer(AbstractConfigProducer<?> parent, String docType) { + super(parent, docType); + } + + @Override + public void getConfig(AttributesConfig.Builder builder) { + if (getSchemaConfig() != null) { + getSchemaConfig().getConfig(builder, AttributeFields.FieldSet.FAST_ACCESS); + } + } } } |