Skip to content

Commit

Permalink
Merge pull request #30472 from vespa-engine/balder/no-need-to-be-a-pr…
Browse files Browse the repository at this point in the history
…oducer

Simplify MultipleDocumentDatabasesConfigProducer according to doc.
  • Loading branch information
baldersheim authored Mar 4, 2024
2 parents dfdf287 + 94d01c8 commit ac065ac
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
public abstract class AnyConfigProducer
implements ConfigProducer, ConfigInstance.Producer, Serializable {

private static final long serialVersionUID = 1L;
public static final Logger log = Logger.getLogger(AnyConfigProducer.class.getPackage().toString());
private final String subId;
private String configId = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
public abstract class TreeConfigProducer<CHILD extends AnyConfigProducer>
extends AnyConfigProducer
{
private static final long serialVersionUID = 1L;
private final List<Service> descendantServices = new ArrayList<>();
private final FreezableMap<String, CHILD> childrenBySubId = new FreezableMap<>(LinkedHashMap.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
* @author bratseth
*/
public class DerivedConfiguration implements AttributesConfig.Producer {
public class DerivedConfiguration {

private final Schema schema;
private Summaries summaries;
Expand Down Expand Up @@ -74,8 +74,6 @@ public DerivedConfiguration(Schema schema, DeployState deployState, boolean isSt
if (!schema.isDocumentsOnly()) {
streamingFields = new VsmFields(schema);
streamingSummary = new VsmSummary(schema);
}
if (!schema.isDocumentsOnly()) {
attributeFields = new AttributeFields(schema);
summaries = new Summaries(schema, deployState.getDeployLogger(), deployState.getProperties().featureFlags());
juniperrc = new Juniperrc(schema);
Expand Down Expand Up @@ -154,7 +152,6 @@ public AttributeFields getAttributeFields() {
return attributeFields;
}

@Override
public void getConfig(AttributesConfig.Builder builder) {
getConfig(builder, AttributeFields.FieldSet.ALL);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.yahoo.vespa.defaults.Defaults;
import com.yahoo.vespa.model.application.validation.Validation.Context;
import com.yahoo.vespa.model.search.DocumentDatabase;
import com.yahoo.vespa.model.search.IndexedSearchCluster;
import com.yahoo.vespa.model.search.SearchCluster;
import com.yahoo.yolean.Exceptions;

Expand Down Expand Up @@ -111,31 +110,31 @@ private void writeConfigs(String dir, DocumentDatabase producer) throws IOExcept
writeConfig(dir, VsmfieldsConfig.getDefName() + ".cfg", vsmFB.build());

RankProfilesConfig.Builder rpcb = new RankProfilesConfig.Builder();
((RankProfilesConfig.Producer) producer).getConfig(rpcb);
producer.getConfig(rpcb);
writeConfig(dir, RankProfilesConfig.getDefName() + ".cfg", rpcb.build());

IndexschemaConfig.Builder iscb = new IndexschemaConfig.Builder();
((IndexschemaConfig.Producer) producer).getConfig(iscb);
producer.getConfig(iscb);
writeConfig(dir, IndexschemaConfig.getDefName() + ".cfg", iscb.build());

AttributesConfig.Builder acb = new AttributesConfig.Builder();
((AttributesConfig.Producer) producer).getConfig(acb);
producer.getConfig(acb);
writeConfig(dir, AttributesConfig.getDefName() + ".cfg", acb.build());

RankingConstantsConfig.Builder rccb = new RankingConstantsConfig.Builder();
((RankingConstantsConfig.Producer) producer).getConfig(rccb);
producer.getConfig(rccb);
writeConfig(dir, RankingConstantsConfig.getDefName() + ".cfg", rccb.build());

RankingExpressionsConfig.Builder recb = new RankingExpressionsConfig.Builder();
((RankingExpressionsConfig.Producer) producer).getConfig(recb);
producer.getConfig(recb);
writeConfig(dir, RankingExpressionsConfig.getDefName() + ".cfg", recb.build());

OnnxModelsConfig.Builder omcb = new OnnxModelsConfig.Builder();
((OnnxModelsConfig.Producer) producer).getConfig(omcb);
producer.getConfig(omcb);
writeConfig(dir, OnnxModelsConfig.getDefName() + ".cfg", omcb.build());

ImportedFieldsConfig.Builder ifcb = new ImportedFieldsConfig.Builder();
((ImportedFieldsConfig.Producer) producer).getConfig(ifcb);
producer.getConfig(ifcb);
writeConfig(dir, ImportedFieldsConfig.getDefName() + ".cfg", ifcb.build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,15 @@
/**
* @author baldersheim
*/
public class IndexedSearchCluster extends SearchCluster
implements
DocumentdbInfoConfig.Producer,
IndexInfoConfig.Producer,
SchemaInfoConfig.Producer,
IlscriptsConfig.Producer,
public class IndexedSearchCluster extends SearchCluster implements
DispatchConfig.Producer,
DispatchNodesConfig.Producer,
ConfigInstance.Producer {
DispatchNodesConfig.Producer
{

private Tuning tuning;
private SearchCoverage searchCoverage;

private final List<DocumentDatabase> documentDbs = new LinkedList<>();
private final MultipleDocumentDatabasesConfigProducer documentDbsConfigProducer;

private final Redundancy.Provider redundancyProvider;

Expand All @@ -57,7 +51,6 @@ public class IndexedSearchCluster extends SearchCluster
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();
Expand Down Expand Up @@ -132,25 +125,25 @@ public void getConfig(DocumentdbInfoConfig.Builder builder) {

@Override
public void getConfig(IndexInfoConfig.Builder builder) {
documentDbsConfigProducer.getConfig(builder);
new Join(documentDbs).getConfig(builder);
}

@Override
public void getConfig(SchemaInfoConfig.Builder builder) {
documentDbsConfigProducer.getConfig(builder);
new Join(documentDbs).getConfig(builder);
}

@Override
public void getConfig(IlscriptsConfig.Builder builder) {
documentDbsConfigProducer.getConfig(builder);
new Join(documentDbs).getConfig(builder);
}

public void getConfig(AttributesConfig.Builder builder) {
documentDbsConfigProducer.getConfig(builder);
new Join(documentDbs).getConfig(builder);
}

public void getConfig(RankProfilesConfig.Builder builder) {
documentDbsConfigProducer.getConfig(builder);
new Join(documentDbs).getConfig(builder);
}

private static DistributionPolicy.Enum toDistributionPolicy(DispatchTuning.DispatchPolicy tuning) {
Expand Down Expand Up @@ -216,53 +209,36 @@ public String toString() {

/**
* Class used to retrieve combined configuration from multiple document databases.
* It is not a direct {@link com.yahoo.config.ConfigInstance.Producer} of those configs,
* It is not a direct {@link ConfigInstance.Producer} of those configs,
* that is handled (by delegating to this) by the {@link IndexedSearchCluster}
* which is the parent to this. This avoids building the config multiple times.
*/
public static class MultipleDocumentDatabasesConfigProducer
extends TreeConfigProducer<MultipleDocumentDatabasesConfigProducer>
implements AttributesConfig.Producer,
IndexInfoConfig.Producer,
IlscriptsConfig.Producer,
SchemaInfoConfig.Producer,
RankProfilesConfig.Producer {
private final List<DocumentDatabase> docDbs;

private MultipleDocumentDatabasesConfigProducer(TreeConfigProducer<?> parent, List<DocumentDatabase> docDbs) {
super(parent, "union");
this.docDbs = docDbs;
}
private record Join(List<DocumentDatabase> docDbs) {

@Override
public void getConfig(IndexInfoConfig.Builder builder) {
for (DocumentDatabase docDb : docDbs) {
docDb.getConfig(builder);
}
}

@Override
public void getConfig(SchemaInfoConfig.Builder builder) {
for (DocumentDatabase docDb : docDbs) {
docDb.getConfig(builder);
}
}

@Override
public void getConfig(IlscriptsConfig.Builder builder) {
for (DocumentDatabase docDb : docDbs) {
docDb.getConfig(builder);
}
}

@Override
public void getConfig(AttributesConfig.Builder builder) {
for (DocumentDatabase docDb : docDbs) {
docDb.getConfig(builder);
}
}

@Override
public void getConfig(RankProfilesConfig.Builder builder) {
for (DocumentDatabase docDb : docDbs) {
docDb.getConfig(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
* @author vegardh
*/
public class StreamingSearchCluster extends SearchCluster implements
DocumentdbInfoConfig.Producer,
RankProfilesConfig.Producer,
RankingConstantsConfig.Producer,
RankingExpressionsConfig.Producer,
OnnxModelsConfig.Producer,
VsmsummaryConfig.Producer,
VsmfieldsConfig.Producer,
SummaryConfig.Producer {
SummaryConfig.Producer
{

private final String storageRouteSpec;
private final AttributesProducer attributesConfig;
Expand Down Expand Up @@ -129,20 +129,17 @@ public void getConfig(RankProfilesConfig.Builder builder) {

@Override
public void getConfig(VsmsummaryConfig.Builder builder) {
if (derivedConfig.getVsmSummary() != null)
derivedConfig.getVsmSummary().getConfig(builder);
derivedConfig.getVsmSummary().getConfig(builder);
}

@Override
public void getConfig(VsmfieldsConfig.Builder builder) {
if (derivedConfig.getVsmFields() != null)
derivedConfig.getVsmFields().getConfig(builder);
derivedConfig.getVsmFields().getConfig(builder);
}

@Override
public void getConfig(SummaryConfig.Builder builder) {
if (derivedConfig.getSummaries() != null)
derivedConfig.getSummaries().getConfig(builder);
derivedConfig.getSummaries().getConfig(builder);
}

private class AttributesProducer extends AnyConfigProducer implements AttributesConfig.Producer {
Expand Down

0 comments on commit ac065ac

Please sign in to comment.