<commit_before>// 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);
        if (!reindexing.enabled()) {
            builder.enabled(false);
            return;
        }
        builder.enabled(true);
        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())));
        }
    }
}
<commit_msg>Specify document type status even when reindexing is disabled<commit_after>// 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())));
        }
    }
}

{'fraction_non_alphanumeric': 0.08319467554076539, 'fraction_numerical': 0.0009507962918944616, 'mean_word_length': 2.8534798534798536, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5836884', 'n_tokens_mistral': 1104, 'n_tokens_neox': 1069, 'n_words': 202}