summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2020-11-04 11:14:50 +0100
committerBjørn Christian Seime <bjorncs@verizonmedia.com>2020-11-04 11:14:50 +0100
commit8b5422be3a3e339540573fbed8063636644af603 (patch)
tree84afe28381397a7cc34b8a8c5fc5a1484ee81ed1 /config-model
parent6ba4a6ebd5f18fa9156527fce782a5f5fc0d68a3 (diff)
Deduplicate and simplify logic for determing indexing mode
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java81
1 files changed, 34 insertions, 47 deletions
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 7cd171f1e91..1f5646ebabb 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
@@ -3,10 +3,10 @@ package com.yahoo.vespa.model.content;
import com.yahoo.config.model.api.ModelContext;
import com.yahoo.config.model.deploy.DeployState;
+import com.yahoo.config.model.producer.AbstractConfigProducer;
+import com.yahoo.documentmodel.NewDocumentType;
import com.yahoo.vespa.config.search.DispatchConfig;
import com.yahoo.vespa.config.search.core.ProtonConfig;
-import com.yahoo.documentmodel.NewDocumentType;
-import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.vespa.model.builder.UserConfigBuilder;
import com.yahoo.vespa.model.builder.xml.dom.DomSearchTuningBuilder;
import com.yahoo.vespa.model.builder.xml.dom.ModelElement;
@@ -15,10 +15,10 @@ import com.yahoo.vespa.model.content.cluster.ContentCluster;
import com.yahoo.vespa.model.content.cluster.DomResourceLimitsBuilder;
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.SearchCluster;
import com.yahoo.vespa.model.search.NamedSchema;
+import com.yahoo.vespa.model.search.NodeSpec;
import com.yahoo.vespa.model.search.SchemaDefinitionXMLHandler;
+import com.yahoo.vespa.model.search.SearchCluster;
import com.yahoo.vespa.model.search.SearchNode;
import com.yahoo.vespa.model.search.StreamingSearchCluster;
import com.yahoo.vespa.model.search.TransactionLogServer;
@@ -33,8 +33,11 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.TreeMap;
+import java.util.function.Predicate;
import java.util.stream.Collectors;
+import static java.util.stream.Collectors.toList;
+
/**
* Encapsulates the various options for search in a content model.
* Wraps a search cluster from com.yahoo.vespa.model.search.
@@ -332,41 +335,31 @@ public class ContentSearchCluster extends AbstractConfigProducer implements Prot
return getClusters().values().stream()
.filter(StreamingSearchCluster.class::isInstance)
.map(StreamingSearchCluster.class::cast)
+ .collect(toList());
+ }
+
+ public List<NewDocumentType> getDocumentTypesWithStreamingCluster() { return documentTypes(this::hasIndexingModeStreaming); }
+ public List<NewDocumentType> getDocumentTypesWithIndexedCluster() { return documentTypes(this::hasIndexingModeIndexed); }
+ public List<NewDocumentType> getDocumentTypesWithStoreOnly() { return documentTypes(this::hasIndexingModeStoreOnly); }
+
+ private List<NewDocumentType> documentTypes(Predicate<NewDocumentType> filter) {
+ return documentDefinitions.values().stream()
+ .filter(filter)
.collect(Collectors.toList());
}
- public List<NewDocumentType> getDocumentTypesWithStreamingCluster() {
- List<NewDocumentType> streamingDocTypes = new ArrayList<>();
- for (NewDocumentType type : documentDefinitions.values()) {
- if (findStreamingCluster(type.getFullName().getName()).isPresent()) {
- streamingDocTypes.add(type);
- }
- }
- return streamingDocTypes;
+ private boolean hasIndexingModeStreaming(NewDocumentType type) {
+ return findStreamingCluster(type.getFullName().getName()).isPresent();
}
- public List<NewDocumentType> getDocumentTypesWithIndexedCluster() {
- List<NewDocumentType> indexedDocTypes = new ArrayList<>();
- for (NewDocumentType type : documentDefinitions.values()) {
- if (findStreamingCluster(type.getFullName().getName()).isEmpty()
- && hasIndexedCluster()
- && getIndexed().hasDocumentDB(type.getFullName().getName())) {
- indexedDocTypes.add(type);
- }
- }
- return indexedDocTypes;
+ private boolean hasIndexingModeIndexed(NewDocumentType type) {
+ return !hasIndexingModeStreaming(type)
+ && hasIndexedCluster()
+ && getIndexed().hasDocumentDB(type.getFullName().getName());
}
- public List<NewDocumentType> getDocumentTypesWithStoreOnly() {
- List<NewDocumentType> indexedDocTypes = new ArrayList<>();
- for (NewDocumentType type : documentDefinitions.values()) {
- if (findStreamingCluster(type.getFullName().getName()).isEmpty() &&
- (hasIndexedCluster() && !getIndexed().hasDocumentDB(type.getFullName().getName()) ||
- !hasIndexedCluster())) {
- indexedDocTypes.add(type);
- }
- }
- return indexedDocTypes;
+ private boolean hasIndexingModeStoreOnly(NewDocumentType type) {
+ return !hasIndexingModeStreaming(type) && !hasIndexingModeIndexed(type);
}
@Override
@@ -381,25 +374,19 @@ public class ContentSearchCluster extends AbstractConfigProducer implements Prot
.configid(getConfigId())
.visibilitydelay(visibilityDelay)
.global(globalDocType);
- Optional<StreamingSearchCluster> ssc = findStreamingCluster(docTypeName);
- if (ssc.isPresent()) {
+
+ if (hasIndexingModeStreaming(type)) {
hasAnyNonIndexedCluster = true;
ddbB.inputdoctypename(type.getFullName().getName())
- .configid(ssc.get().getDocumentDBConfigId())
+ .configid(findStreamingCluster(docTypeName).get().getDocumentDBConfigId())
.mode(ProtonConfig.Documentdb.Mode.Enum.STREAMING)
- .feeding.concurrency(0.0);
- } else if (hasIndexedCluster()) {
- if (getIndexed().hasDocumentDB(type.getFullName().getName())) {
- getIndexed().fillDocumentDBConfig(type.getFullName().getName(), ddbB);
- if (tuning != null && tuning.searchNode != null && tuning.searchNode.feeding != null) {
- ddbB.feeding.concurrency(tuning.searchNode.feeding.concurrency / 2);
- } else {
- ddbB.feeding.concurrency(builder.feeding.build().concurrency());
- }
+ .feeding.concurrency(0.0);
+ } else if (hasIndexingModeIndexed(type)) {
+ getIndexed().fillDocumentDBConfig(type.getFullName().getName(), ddbB);
+ if (tuning != null && tuning.searchNode != null && tuning.searchNode.feeding != null) {
+ ddbB.feeding.concurrency(tuning.searchNode.feeding.concurrency / 2);
} else {
- hasAnyNonIndexedCluster = true;
- ddbB.feeding.concurrency(0.0);
- ddbB.mode(ProtonConfig.Documentdb.Mode.Enum.STORE_ONLY);
+ ddbB.feeding.concurrency(builder.feeding.build().concurrency());
}
} else {
hasAnyNonIndexedCluster = true;