diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2021-01-15 20:46:13 +0100 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2021-01-15 20:46:13 +0100 |
commit | ed79699c3758a7dd6483492d8f7bcccb2882fd17 (patch) | |
tree | 5529b2959fe1df4d1dff84d020ef1dc4ec4ee304 /configserver | |
parent | 03801fa884fd8e3f351de2364526cc3170fb5a38 (diff) |
Move logic for indexed document types inside config model api wrapping
Diffstat (limited to 'configserver')
3 files changed, 7 insertions, 39 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationReindexing.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationReindexing.java index 1736b23012d..c603b4af6a5 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationReindexing.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationReindexing.java @@ -50,40 +50,6 @@ public class ApplicationReindexing implements Reindexing { return new ApplicationReindexing(true, new Status(now), Map.of()); } - /** Returns the set of document types in each content cluster, in the given application */ - public static Map<String, Set<String>> documentTypes(Application application) { - Map<String, ContentCluster> contentClusters = ((VespaModel) application.getModel()).getContentClusters(); - return contentClusters.entrySet().stream() - .collect(toMap(cluster -> cluster.getKey(), - cluster -> cluster.getValue().getDocumentDefinitions().keySet())); - } - - /** Returns the set of document types in each cluster, in the given application, that have an index for one of more fields. */ - public static Map<String, Set<String>> documentTypesWithIndex(Application application) { - Map<String, ContentCluster> contentClusters = ((VespaModel) application.getModel()).getContentClusters(); - return contentClusters.entrySet().stream() - .collect(toUnmodifiableMap(cluster -> cluster.getKey(), - cluster -> documentTypesWithIndex(cluster.getValue()))); - } - - private static Set<String> documentTypesWithIndex(ContentCluster content) { - Set<String> typesWithIndexMode = content.getSearch().getDocumentTypesWithIndexedCluster().stream() - .map(type -> type.getFullName().getName()) - .collect(toSet()); - - Set<String> typesWithIndexedFields = content.getSearch().getIndexed() == null - ? Set.of() - : content.getSearch().getIndexed().getDocumentDbs().stream() - .filter(database -> database.getDerivedConfiguration() - .getSearch() - .allConcreteFields() - .stream().anyMatch(SDField::doesIndexing)) - .map(database -> database.getInputDocType()) - .collect(toSet()); - - return typesWithIndexMode.stream().filter(typesWithIndexedFields::contains).collect(toUnmodifiableSet()); - } - /** Returns a copy of this with reindexing for the whole application ready at the given instant. */ public ApplicationReindexing withReady(Instant readyAt) { return new ApplicationReindexing(enabled, diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java index 401823aa6cd..0da377d889b 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java @@ -28,6 +28,7 @@ import com.yahoo.vespa.config.server.http.HttpHandler; import com.yahoo.vespa.config.server.http.JSONResponse; import com.yahoo.vespa.config.server.http.NotFoundException; import com.yahoo.vespa.config.server.tenant.Tenant; +import com.yahoo.vespa.model.VespaModel; import java.io.IOException; import java.net.URLDecoder; @@ -232,10 +233,10 @@ public class ApplicationHandler extends HttpHandler { private HttpResponse triggerReindexing(HttpRequest request, ApplicationId applicationId) { Application application = applicationRepository.getActiveApplicationSet(applicationId) - .orElseThrow(() -> new NotFoundException(applicationId + " not found")) - .getForVersionOrLatest(Optional.empty(), applicationRepository.clock().instant()); - Map<String, Set<String>> documentTypes = ApplicationReindexing.documentTypes(application); - Map<String, Set<String>> indexedDocumentTypes = ApplicationReindexing.documentTypesWithIndex(application); + .orElseThrow(() -> new NotFoundException(applicationId + " not found")) + .getForVersionOrLatest(Optional.empty(), applicationRepository.clock().instant()); + Map<String, Set<String>> documentTypes = application.getModel().documentTypesByCluster(); + Map<String, Set<String>> indexedDocumentTypes = application.getModel().indexedDocumentTypesByCluster(); boolean indexedOnly = request.getBooleanProperty("indexedOnly"); Set<String> clusters = StringUtilities.split(request.getProperty("clusterId")); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/ReindexingMaintainer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/ReindexingMaintainer.java index 34e4a5becfb..971c2c20ae9 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/ReindexingMaintainer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/ReindexingMaintainer.java @@ -11,6 +11,7 @@ import com.yahoo.vespa.config.server.application.ConfigConvergenceChecker; import com.yahoo.vespa.config.server.tenant.Tenant; import com.yahoo.vespa.curator.Curator; import com.yahoo.vespa.flags.FlagSource; +import com.yahoo.vespa.model.VespaModel; import com.yahoo.yolean.Exceptions; import java.time.Clock; @@ -98,7 +99,7 @@ public class ReindexingMaintainer extends ConfigServerMaintainer { } static ApplicationReindexing withOnlyCurrentData(ApplicationReindexing reindexing, Application application) { - return withOnlyCurrentData(reindexing, ApplicationReindexing.documentTypes(application)); + return withOnlyCurrentData(reindexing, application.getModel().documentTypesByCluster()); } static ApplicationReindexing withOnlyCurrentData(ApplicationReindexing reindexing, Map<String, ? extends Collection<String>> clusterDocumentTypes) { |