diff options
author | Bjørn Christian Seime <bjorn.christian@seime.no> | 2020-11-11 09:30:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-11 09:30:51 +0100 |
commit | 8898c57ea0a2376b8ab77aa9e675f51afac99b84 (patch) | |
tree | 65285952c77699cbfbe26fc599b17d7b8d8fb866 /config-model/src/main/java/com/yahoo/vespa/model/admin | |
parent | 601043a29452896635a0122bf20d358f7a02875c (diff) |
Revert "Revert "Bjorncs/install clustercontroller reindexer" MERGEOK"
Diffstat (limited to 'config-model/src/main/java/com/yahoo/vespa/model/admin')
4 files changed, 100 insertions, 2 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerContainer.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerContainer.java index 8bd4506aedc..1364d74fa11 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerContainer.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerContainer.java @@ -6,6 +6,7 @@ import com.yahoo.component.ComponentSpecification; import com.yahoo.config.model.api.container.ContainerServiceType; import com.yahoo.config.model.producer.AbstractConfigProducer; import com.yahoo.container.bundle.BundleInstantiationSpecification; +import com.yahoo.container.core.documentapi.DocumentAccessProvider; import com.yahoo.container.di.config.PlatformBundlesConfig; import com.yahoo.osgi.provider.model.ComponentModel; import com.yahoo.vespa.config.content.FleetcontrollerConfig; @@ -14,6 +15,7 @@ import com.yahoo.vespa.model.container.Container; import com.yahoo.vespa.model.container.component.AccessLogComponent; import com.yahoo.vespa.model.container.component.Component; import com.yahoo.vespa.model.container.component.Handler; +import com.yahoo.vespa.model.container.component.SimpleComponent; import com.yahoo.vespa.model.container.component.SystemBindingPattern; import com.yahoo.vespa.model.container.xml.PlatformBundles; @@ -33,7 +35,12 @@ public class ClusterControllerContainer extends Container implements private final Set<String> bundles = new TreeSet<>(); - public ClusterControllerContainer(AbstractConfigProducer parent, int index, boolean runStandaloneZooKeeper, boolean isHosted) { + public ClusterControllerContainer( + AbstractConfigProducer<?> parent, + int index, + boolean runStandaloneZooKeeper, + boolean isHosted, + ReindexingContext reindexingContext) { super(parent, "" + index, index, isHosted); addHandler("clustercontroller-status", "com.yahoo.vespa.clustercontroller.apps.clustercontroller.StatusHandler", @@ -61,6 +68,7 @@ public class ClusterControllerContainer extends Container implements addFileBundle("clustercontroller-core"); addFileBundle("clustercontroller-utils"); addFileBundle("zookeeper-server"); + configureReindexing(reindexingContext); } @Override @@ -101,6 +109,15 @@ public class ClusterControllerContainer extends Container implements addHandler(new Handler(createComponentModel(id, className, CLUSTERCONTROLLER_BUNDLE)), path); } + private void configureReindexing(ReindexingContext context) { + if (context != null) { + addFileBundle(ReindexingController.REINDEXING_CONTROLLER_BUNDLE); + addComponent(new ReindexingController(context)); + addComponent(new SimpleComponent(DocumentAccessProvider.class.getName())); + } + } + + @Override public void getConfig(PlatformBundlesConfig.Builder builder) { bundles.forEach(builder::bundlePaths); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerContainerCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerContainerCluster.java index 5cee73dff1b..3ee2a840f20 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerContainerCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerContainerCluster.java @@ -20,6 +20,6 @@ public class ClusterControllerContainerCluster extends ContainerCluster<ClusterC @Override protected void doPrepare(DeployState deployState) { } - protected boolean messageBusEnabled() { return false; } + @Override protected boolean messageBusEnabled() { return false; } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ReindexingContext.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ReindexingContext.java new file mode 100644 index 00000000000..fdd12088d04 --- /dev/null +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ReindexingContext.java @@ -0,0 +1,33 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.model.admin.clustercontroller; + +import com.yahoo.config.model.api.Reindexing; +import com.yahoo.documentmodel.NewDocumentType; + +import java.util.Collection; +import java.util.Objects; + +/** + * Context required to configure automatic reindexing for a given cluster controller cluster (for a given content cluster). + * + * @author bjorncs + */ +public class ReindexingContext { + + private final Reindexing reindexing; + private final String contentClusterName; + private final Collection<NewDocumentType> documentTypes; + + public ReindexingContext( + Reindexing reindexing, + String contentClusterName, + Collection<NewDocumentType> documentTypes) { + this.reindexing = Objects.requireNonNull(reindexing); + this.contentClusterName = Objects.requireNonNull(contentClusterName); + this.documentTypes = Objects.requireNonNull(documentTypes); + } + + public Reindexing reindexing() { return reindexing; } + public String contentClusterName() { return contentClusterName; } + public Collection<NewDocumentType> documentTypes() { return documentTypes; } +} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ReindexingController.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ReindexingController.java new file mode 100644 index 00000000000..24909ddbc8d --- /dev/null +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ReindexingController.java @@ -0,0 +1,48 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.model.admin.clustercontroller; + +import com.yahoo.config.model.api.Reindexing; +import com.yahoo.container.bundle.BundleInstantiationSpecification; +import com.yahoo.documentmodel.NewDocumentType; +import com.yahoo.osgi.provider.model.ComponentModel; +import com.yahoo.vespa.config.content.reindexing.ReindexingConfig; +import com.yahoo.vespa.model.container.component.SimpleComponent; + +import java.util.Collection; + +/** + * @author bjorncs + */ +class ReindexingController extends SimpleComponent implements ReindexingConfig.Producer { + + static final String REINDEXING_CONTROLLER_BUNDLE = "clustercontroller-reindexer"; + + private final Reindexing reindexing; + private final String contentClusterName; + private final Collection<NewDocumentType> documentTypes; + + ReindexingController(ReindexingContext context) { + super(new ComponentModel( + BundleInstantiationSpecification.getFromStrings( + "reindexing-maintainer", + "ai.vespa.reindexing.ReindexingMaintainer", + REINDEXING_CONTROLLER_BUNDLE))); + this.reindexing = context.reindexing(); + this.contentClusterName = context.contentClusterName(); + this.documentTypes = context.documentTypes(); + } + + @Override + public void getConfig(ReindexingConfig.Builder builder) { + builder.clusterName(contentClusterName); + builder.enabled(reindexing.enabled()); + for (NewDocumentType type : documentTypes) { + String typeName = type.getFullName().getName(); + reindexing.status(contentClusterName, typeName).ifPresent(status -> + builder.status( + typeName, + new ReindexingConfig.Status.Builder() + .readyAtMillis(status.ready().toEpochMilli()))); + } + } +} |