summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2024-03-13 15:46:15 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2024-03-13 16:16:31 +0100
commit4f7338e2778a8780996a8a610db527cb4ab392af (patch)
tree190aea2455a5136dbcb0fde924cf718d0fb64376 /container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java
parent4e1726d12d155c5d64266b0103828f20cd81ec3a (diff)
Do all construction in constructor and make members final.
Diffstat (limited to 'container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java')
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java45
1 files changed, 15 insertions, 30 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java b/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java
index 0d9935af43d..855a524473d 100644
--- a/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java
@@ -12,7 +12,6 @@ import com.yahoo.container.handler.VipStatus;
import com.yahoo.prelude.fastsearch.ClusterParams;
import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig;
import com.yahoo.prelude.fastsearch.IndexedBackend;
-import com.yahoo.prelude.fastsearch.SummaryParameters;
import com.yahoo.prelude.fastsearch.VespaBackend;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
@@ -92,23 +91,19 @@ public class ClusterSearcher extends Searcher {
maxQueryTimeout = ParameterParser.asMilliSeconds(clusterConfig.maxQueryTimeout(), DEFAULT_MAX_QUERY_TIMEOUT);
maxQueryCacheTimeout = ParameterParser.asMilliSeconds(clusterConfig.maxQueryCacheTimeout(), DEFAULT_MAX_QUERY_CACHE_TIMEOUT);
- SummaryParameters docSumParams = new SummaryParameters(qrsConfig
- .com().yahoo().prelude().fastsearch().IndexedBackend().docsum()
- .defaultclass());
-
- String uniqueServerId = UUID.randomUUID().toString();
VespaBackend streaming = null, indexed = null;
+ ClusterParams clusterParams = makeClusterParams(searchClusterIndex, qrsConfig
+ .com().yahoo().prelude().fastsearch().IndexedBackend().docsum()
+ .defaultclass(), documentDbConfig, schemaInfo);
for (DocumentdbInfoConfig.Documentdb docDb : documentDbConfig.documentdb()) {
if (docDb.mode() == DocumentdbInfoConfig.Documentdb.Mode.Enum.INDEX) {
if (indexed == null) {
- indexed = searchDispatch(searchClusterIndex, searchClusterName, uniqueServerId,
- docSumParams, documentDbConfig, schemaInfo, dispatchers);
+ indexed = searchDispatch(clusterParams, searchClusterName, dispatchers);
}
schema2Searcher.put(docDb.name(), indexed);
} else if (docDb.mode() == DocumentdbInfoConfig.Documentdb.Mode.Enum.STREAMING) {
if (streaming == null) {
- streaming = streamingCluster(uniqueServerId, searchClusterIndex,
- searchClusterConfig, docSumParams, documentDbConfig, schemaInfo, access);
+ streaming = streamingCluster(clusterParams, searchClusterConfig, access);
vipStatus.addToRotation(streaming.getName());
}
schema2Searcher.put(docDb.name(), streaming);
@@ -126,40 +121,30 @@ public class ClusterSearcher extends Searcher {
config.searchcluster().stream().map(QrSearchersConfig.Searchcluster::name).toList());
}
- private static ClusterParams makeClusterParams(int searchclusterIndex) {
- return new ClusterParams("sc" + searchclusterIndex + ".num" + 0);
+ private static ClusterParams makeClusterParams(int searchclusterIndex, String defaultSummary,
+ DocumentdbInfoConfig documentDbConfig, SchemaInfo schemaInfo)
+ {
+ return new ClusterParams("sc" + searchclusterIndex + ".num" + 0, UUID.randomUUID().toString(),
+ defaultSummary, documentDbConfig, schemaInfo);
}
- private static IndexedBackend searchDispatch(int searchclusterIndex,
+ private static IndexedBackend searchDispatch(ClusterParams clusterParams,
String searchClusterName,
- String serverId,
- SummaryParameters docSumParams,
- DocumentdbInfoConfig documentdbInfoConfig,
- SchemaInfo schemaInfo,
ComponentRegistry<Dispatcher> dispatchers)
{
- ClusterParams clusterParams = makeClusterParams(searchclusterIndex);
ComponentId dispatcherComponentId = new ComponentId("dispatcher." + searchClusterName);
Dispatcher dispatcher = dispatchers.getComponent(dispatcherComponentId);
if (dispatcher == null)
throw new IllegalArgumentException("Configuration error: No dispatcher " + dispatcherComponentId + " is configured");
- return new IndexedBackend(serverId, dispatcher, docSumParams, clusterParams, documentdbInfoConfig, schemaInfo);
+ return new IndexedBackend(clusterParams, dispatcher);
}
- private static StreamingBackend streamingCluster(String serverId,
- int searchclusterIndex,
+ private static StreamingBackend streamingCluster(ClusterParams clusterParams,
QrSearchersConfig.Searchcluster searchClusterConfig,
- SummaryParameters docSumParams,
- DocumentdbInfoConfig documentdbInfoConfig,
- SchemaInfo schemaInfo,
VespaDocumentAccess access)
{
- ClusterParams clusterParams = makeClusterParams(searchclusterIndex);
- StreamingBackend searcher = new StreamingBackend(access);
- searcher.setSearchClusterName(searchClusterConfig.rankprofiles_configid());
- searcher.setStorageClusterRouteSpec(searchClusterConfig.storagecluster().routespec());
- searcher.init(serverId, docSumParams, clusterParams, documentdbInfoConfig, schemaInfo);
- return searcher;
+ return new StreamingBackend(clusterParams, searchClusterConfig.rankprofiles_configid(),
+ access, searchClusterConfig.storagecluster().routespec());
}
/** Do not use, for internal testing purposes only. **/