aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2024-03-04 15:31:04 +0100
committerGitHub <noreply@github.com>2024-03-04 15:31:04 +0100
commitfbe017f7b123f7787a7bbe622dbce7a97d0eb42c (patch)
tree6a801512411c3868daa576c5c299e1f6e2cc6821
parentd888d06261e427205d95b67a03ee02051e4dad30 (diff)
parent9f7542ea60c40e86ac6315f42b1c03b76d602f03 (diff)
Merge pull request #30469 from vespa-engine/balder/use-redundancy-provider
Use the redunacy provider.
-rw-r--r--config-model/src/main/java/com/yahoo/schema/derived/VsmSummary.java2
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/SearchChain.java3
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java18
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java13
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java8
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java38
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/search/test/SearchNodeTest.java5
7 files changed, 31 insertions, 56 deletions
diff --git a/config-model/src/main/java/com/yahoo/schema/derived/VsmSummary.java b/config-model/src/main/java/com/yahoo/schema/derived/VsmSummary.java
index a2c220b6cbc..e3d7becd86a 100644
--- a/config-model/src/main/java/com/yahoo/schema/derived/VsmSummary.java
+++ b/config-model/src/main/java/com/yahoo/schema/derived/VsmSummary.java
@@ -38,7 +38,7 @@ public class VsmSummary extends Derived implements VsmsummaryConfig.Producer {
if (doMapField(schema, summaryField)) {
SDField sdField = schema.getConcreteField(summaryField.getName());
if (sdField != null && GeoPos.isAnyPos(sdField)) {
- summaryMap.put(summaryField, Collections.singletonList(summaryField.getName()));
+ summaryMap.put(summaryField, List.of(summaryField.getName()));
} else {
summaryMap.put(summaryField, from);
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/SearchChain.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/SearchChain.java
index 6f9e72117c8..0a8ae69ccf0 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/SearchChain.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/SearchChain.java
@@ -5,7 +5,6 @@ import com.yahoo.component.chain.model.ChainSpecification;
import com.yahoo.search.searchchain.model.federation.FederationOptions;
import com.yahoo.vespa.model.container.component.chain.Chain;
-import java.util.Collections;
import java.util.List;
/**
@@ -25,7 +24,7 @@ public class SearchChain extends Chain<Searcher<?>> {
//A list of documents types that this search chain provides results for, empty if unknown
public List<String> getDocumentTypes() {
- return Collections.emptyList();
+ return List.of();
}
@Override
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 99630c5f048..fc5b5c25e6d 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
@@ -70,7 +70,7 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer>
private final List<SearchNode> nonIndexed = new ArrayList<>();
private final Map<StorageGroup, NodeSpec> groupToSpecMap = new LinkedHashMap<>();
- private Optional<ResourceLimits> resourceLimits = Optional.empty();
+ private ResourceLimits resourceLimits;
private final ProtonConfig.Indexing.Optimize.Enum feedSequencerType;
private final double defaultFeedConcurrency;
private final double defaultFeedNiceness;
@@ -160,7 +160,7 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer>
String clusterName, ContentSearchCluster search) {
List<ModelElement> indexedDefs = getIndexedSchemas(clusterElem);
if (!indexedDefs.isEmpty()) {
- IndexedSearchCluster isc = new IndexedSearchCluster(search, clusterName, 0, deployState.featureFlags());
+ IndexedSearchCluster isc = new IndexedSearchCluster(search, clusterName, 0, search, deployState.featureFlags());
Double visibilityDelay = clusterElem.childAsDouble("engine.proton.visibility-delay");
if (visibilityDelay != null) {
@@ -292,11 +292,10 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer>
NodeSpec spec = getNextSearchNodeSpec(parentGroup);
SearchNode searchNode;
TransactionLogServer tls;
- Optional<Tuning> tuning = Optional.ofNullable(this.tuning);
if (element == null) {
searchNode = SearchNode.create(parent, "" + node.getDistributionKey(), node.getDistributionKey(), spec,
clusterName, node, flushOnShutdown, tuning, resourceLimits, deployState.isHosted(),
- fractionOfMemoryReserved, this, deployState.featureFlags());
+ fractionOfMemoryReserved, deployState.featureFlags());
searchNode.setHostResource(node.getHostResource());
searchNode.initService(deployState);
@@ -305,7 +304,7 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer>
tls.initService(deployState);
} else {
searchNode = new SearchNode.Builder(""+node.getDistributionKey(), spec, clusterName, node, flushOnShutdown,
- tuning, resourceLimits, fractionOfMemoryReserved, this)
+ tuning, resourceLimits, fractionOfMemoryReserved)
.build(deployState, parent, element.getXml());
tls = new TransactionLogServer.Builder(clusterName, syncTransactionLog).build(deployState, searchNode, element.getXml());
}
@@ -334,7 +333,7 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer>
public void setTuning(Tuning tuning) { this.tuning = tuning; }
private void setResourceLimits(ResourceLimits resourceLimits) {
- this.resourceLimits = Optional.of(resourceLimits);
+ this.resourceLimits = resourceLimits;
}
public boolean usesHierarchicDistribution() {
@@ -342,11 +341,6 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer>
}
public void handleRedundancy(Redundancy redundancy) {
- if (hasIndexedCluster()) {
- // Important: these must all be the normalized "within a single leaf group" values,
- // _not_ the cluster-wide, cross-group values.
- indexedCluster.setRedundancy(redundancy.finalRedundancy());
- }
this.redundancy = redundancy;
}
@@ -434,7 +428,7 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer>
int numDocumentDbs = builder.documentdb.size();
builder.initialize(new ProtonConfig.Initialize.Builder().threads(numDocumentDbs + 1));
- resourceLimits.ifPresent(limits -> limits.getConfig(builder));
+ if (resourceLimits != null) resourceLimits.getConfig(builder);
if (tuning != null) {
tuning.getConfig(builder);
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 c9057c16499..885cb53a148 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
@@ -20,6 +20,7 @@ import com.yahoo.vespa.config.search.RankProfilesConfig;
import com.yahoo.vespa.config.search.core.ProtonConfig;
import com.yahoo.vespa.configdefinition.IlscriptsConfig;
import com.yahoo.vespa.model.content.DispatchTuning;
+import com.yahoo.vespa.model.content.Redundancy;
import com.yahoo.vespa.model.content.SearchCoverage;
import java.util.ArrayList;
@@ -46,16 +47,18 @@ public class IndexedSearchCluster extends SearchCluster
private final List<DocumentDatabase> documentDbs = new LinkedList<>();
private final MultipleDocumentDatabasesConfigProducer documentDbsConfigProducer;
- private int redundancy = 1;
+ private final Redundancy.Provider redundancyProvider;
private final List<SearchNode> searchNodes = new ArrayList<>();
private final DispatchTuning.DispatchPolicy defaultDispatchPolicy;
private final double dispatchWarmup;
private final String summaryDecodePolicy;
- public IndexedSearchCluster(TreeConfigProducer<AnyConfigProducer> parent, String clusterName, int index, ModelContext.FeatureFlags featureFlags) {
+ public IndexedSearchCluster(TreeConfigProducer<AnyConfigProducer> parent, String clusterName, int index,
+ Redundancy.Provider redundancyProvider, ModelContext.FeatureFlags featureFlags) {
super(parent, clusterName, index);
documentDbsConfigProducer = new MultipleDocumentDatabasesConfigProducer(this, documentDbs);
+ this.redundancyProvider = redundancyProvider;
defaultDispatchPolicy = DispatchTuning.Builder.toDispatchPolicy(featureFlags.queryDispatchPolicy());
dispatchWarmup = featureFlags.queryDispatchWarmup();
summaryDecodePolicy = featureFlags.summaryDecodePolicy();
@@ -150,10 +153,6 @@ public class IndexedSearchCluster extends SearchCluster
documentDbsConfigProducer.getConfig(builder);
}
- public void setRedundancy(int redundancy) {
- this.redundancy = redundancy;
- }
-
private static DistributionPolicy.Enum toDistributionPolicy(DispatchTuning.DispatchPolicy tuning) {
return switch (tuning) {
case ADAPTIVE: yield DistributionPolicy.ADAPTIVE;
@@ -189,7 +188,7 @@ public class IndexedSearchCluster extends SearchCluster
if (tuning.dispatch.getMaxHitsPerPartition() != null)
builder.maxHitsPerNode(tuning.dispatch.getMaxHitsPerPartition());
- builder.redundancy(redundancy);
+ builder.redundancy(redundancyProvider.redundancy().finalRedundancy());
if (searchCoverage != null) {
if (searchCoverage.getMinimum() != null)
builder.minSearchCoverage(searchCoverage.getMinimum() * 100.0);
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 9ccc6abfc35..2ab11e31f59 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
@@ -58,14 +58,6 @@ public abstract class SearchCluster extends TreeConfigProducer<AnyConfigProducer
/** Returns the document databases contained in this cluster */
public abstract List<DocumentDatabase> getDocumentDbs();
- /** Returns a list of the document type names used in this search cluster */
- public List<String> getDocumentNames() {
- return schemas.values()
- .stream()
- .map(schema -> schema.fullSchema().getDocument().getDocumentName().getName())
- .toList();
- }
-
public String getClusterName() { return clusterName; }
public final String getIndexingModeName() { return getIndexingMode().getName(); }
public final boolean isStreaming() { return getIndexingMode() == IndexingMode.STREAMING; }
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java
index dc4f9273868..61933c10504 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java
@@ -21,7 +21,6 @@ import com.yahoo.vespa.model.admin.monitoring.Monitoring;
import com.yahoo.vespa.model.application.validation.RestartConfigs;
import com.yahoo.vespa.model.builder.xml.dom.VespaDomBuilder;
import com.yahoo.vespa.model.content.ContentNode;
-import com.yahoo.vespa.model.content.Redundancy;
import com.yahoo.vespa.model.content.ResourceLimits;
import org.w3c.dom.Element;
@@ -64,10 +63,9 @@ public class SearchNode extends AbstractService implements
private final String clusterName;
private TransactionLogServer tls;
private final AbstractService serviceLayerService;
- private final Optional<Tuning> tuning;
- private final Optional<ResourceLimits> resourceLimits;
+ private final Tuning tuning;
+ private final ResourceLimits resourceLimits;
private final double fractionOfMemoryReserved;
- private final Redundancy.Provider redundancyProvider;
public static class Builder extends VespaDomBuilder.DomConfigProducerBuilderBase<SearchNode> {
@@ -76,14 +74,13 @@ public class SearchNode extends AbstractService implements
private final String clusterName;
private final ContentNode contentNode;
private final boolean flushOnShutdown;
- private final Optional<Tuning> tuning;
- private final Optional<ResourceLimits> resourceLimits;
+ private final Tuning tuning;
+ private final ResourceLimits resourceLimits;
private final double fractionOfMemoryReserved;
- private final Redundancy.Provider redundancyProvider;
public Builder(String name, NodeSpec nodeSpec, String clusterName, ContentNode node,
- boolean flushOnShutdown, Optional<Tuning> tuning, Optional<ResourceLimits> resourceLimits,
- double fractionOfMemoryReserved, Redundancy.Provider redundancyprovider) {
+ boolean flushOnShutdown, Tuning tuning, ResourceLimits resourceLimits,
+ double fractionOfMemoryReserved) {
this.name = name;
this.nodeSpec = nodeSpec;
this.clusterName = clusterName;
@@ -92,7 +89,6 @@ public class SearchNode extends AbstractService implements
this.tuning = tuning;
this.resourceLimits = resourceLimits;
this.fractionOfMemoryReserved = fractionOfMemoryReserved;
- this.redundancyProvider = redundancyprovider;
}
@Override
@@ -100,18 +96,18 @@ public class SearchNode extends AbstractService implements
Element producerSpec) {
return SearchNode.create(ancestor, name, contentNode.getDistributionKey(), nodeSpec, clusterName, contentNode,
flushOnShutdown, tuning, resourceLimits, deployState.isHosted(),
- fractionOfMemoryReserved, redundancyProvider, deployState.featureFlags());
+ fractionOfMemoryReserved, deployState.featureFlags());
}
}
public static SearchNode create(TreeConfigProducer<?> parent, String name, int distributionKey, NodeSpec nodeSpec,
String clusterName, AbstractService serviceLayerService, boolean flushOnShutdown,
- Optional<Tuning> tuning, Optional<ResourceLimits> resourceLimits,
- boolean isHostedVespa, double fractionOfMemoryReserved, Redundancy.Provider redundancyProvider,
+ Tuning tuning, ResourceLimits resourceLimits,
+ boolean isHostedVespa, double fractionOfMemoryReserved,
ModelContext.FeatureFlags featureFlags) {
SearchNode node = new SearchNode(parent, name, distributionKey, nodeSpec, clusterName, serviceLayerService, flushOnShutdown,
- tuning, resourceLimits, isHostedVespa, fractionOfMemoryReserved, redundancyProvider);
+ tuning, resourceLimits, isHostedVespa, fractionOfMemoryReserved);
if (featureFlags.loadCodeAsHugePages()) {
node.addEnvironmentVariable("VESPA_LOAD_CODE_AS_HUGEPAGES", true);
}
@@ -123,8 +119,8 @@ public class SearchNode extends AbstractService implements
private SearchNode(TreeConfigProducer<?> parent, String name, int distributionKey, NodeSpec nodeSpec,
String clusterName, AbstractService serviceLayerService, boolean flushOnShutdown,
- Optional<Tuning> tuning, Optional<ResourceLimits> resourceLimits, boolean isHostedVespa,
- double fractionOfMemoryReserved, Redundancy.Provider redundancyProvider) {
+ Tuning tuning, ResourceLimits resourceLimits, boolean isHostedVespa,
+ double fractionOfMemoryReserved) {
super(parent, name);
this.distributionKey = distributionKey;
this.serviceLayerService = serviceLayerService;
@@ -141,7 +137,6 @@ public class SearchNode extends AbstractService implements
// Properties are set in DomSearchBuilder
this.tuning = tuning;
this.resourceLimits = resourceLimits;
- this.redundancyProvider = redundancyProvider;
setPropertiesElastic(clusterName, distributionKey);
addEnvironmentVariable("OMP_NUM_THREADS", 1);
}
@@ -277,13 +272,12 @@ public class SearchNode extends AbstractService implements
}
Optional<NodeResources> nodeResources = getSpecifiedNodeResources();
if (nodeResources.isPresent()) {
- var nodeResourcesTuning = new NodeResourcesTuning(nodeResources.get(),
- tuning.map(Tuning::threadsPerSearch).orElse(1),
- fractionOfMemoryReserved);
+ int threadsPerSearch = tuning != null ? tuning.threadsPerSearch() : 1;
+ var nodeResourcesTuning = new NodeResourcesTuning(nodeResources.get(), threadsPerSearch, fractionOfMemoryReserved);
nodeResourcesTuning.getConfig(builder);
- tuning.ifPresent(t -> t.getConfig(builder));
- resourceLimits.ifPresent(l -> l.getConfig(builder));
+ if (tuning != null) tuning.getConfig(builder);
+ if (resourceLimits != null) resourceLimits.getConfig(builder);
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SearchNodeTest.java b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SearchNodeTest.java
index 55a55075625..bc981c3de7c 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SearchNodeTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SearchNodeTest.java
@@ -10,14 +10,11 @@ import com.yahoo.vespa.config.search.core.ProtonConfig;
import com.yahoo.vespa.defaults.Defaults;
import com.yahoo.vespa.model.Host;
import com.yahoo.vespa.model.HostResource;
-import com.yahoo.vespa.model.content.Redundancy;
import com.yahoo.vespa.model.search.NodeSpec;
import com.yahoo.vespa.model.search.SearchNode;
import com.yahoo.vespa.model.search.TransactionLogServer;
import org.junit.jupiter.api.Test;
-import java.util.Optional;
-
import static org.junit.jupiter.api.Assertions.*;
/**
@@ -50,7 +47,7 @@ public class SearchNodeTest {
private static SearchNode createSearchNode(MockRoot root, String name, int distributionKey, NodeSpec nodeSpec,
boolean flushOnShutDown, boolean isHosted, ModelContext.FeatureFlags featureFlags) {
return SearchNode.create(root, name, distributionKey, nodeSpec, "mycluster", null, flushOnShutDown,
- Optional.empty(), Optional.empty(), isHosted, 0.0, () -> new Redundancy(1,1,1,1,1), featureFlags);
+ null, null, isHosted, 0.0, featureFlags);
}
private static SearchNode createSearchNode(MockRoot root) {