blob: 2f20c5009ae0470b2a91d0f04fa1b4df740c4c30 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.search;
import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.search.config.SchemaInfoConfig;
import com.yahoo.schema.derived.SchemaInfo;
import com.yahoo.vespa.config.search.AttributesConfig;
import com.yahoo.vespa.config.search.RankProfilesConfig;
import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig;
import com.yahoo.search.config.IndexInfoConfig;
import com.yahoo.vespa.configdefinition.IlscriptsConfig;
import com.yahoo.config.model.producer.AnyConfigProducer;
import com.yahoo.config.model.producer.TreeConfigProducer;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* Represents a search cluster.
*
* @author arnej27959
*/
public abstract class SearchCluster extends TreeConfigProducer<AnyConfigProducer>
implements
DocumentdbInfoConfig.Producer,
IndexInfoConfig.Producer,
IlscriptsConfig.Producer,
SchemaInfoConfig.Producer {
private final String clusterName;
private int index;
private Double queryTimeout;
private Double visibilityDelay = 0.0;
private final Map<String, SchemaInfo> schemas = new LinkedHashMap<>();
public SearchCluster(TreeConfigProducer<?> parent, String clusterName, int index) {
super(parent, "cluster." + clusterName);
this.clusterName = clusterName;
this.index = index;
}
public void add(SchemaInfo schema) {
schemas.put(schema.name(), schema);
}
/** Returns the schemas that should be active in this cluster. Note: These are added during processing. */
public Map<String, SchemaInfo> schemas() { return Collections.unmodifiableMap(schemas); }
/**
* Must be called after cluster is built, to derive schema configs.
* Derives the schemas from the application package.
* Also stores the document names contained in the schemas.
*/
public abstract void deriveFromSchemas(DeployState deployState);
/** Returns the document databases contained in this cluster */
public abstract List<DocumentDatabase> getDocumentDbs();
/** Returns a list of the document type names used in this search cluster */
public List<String> getDocumentNames() {
return schemas.values()
.stream()
.map(schema -> schema.fullSchema().getDocument().getDocumentName().getName())
.toList();
}
public String getClusterName() { return clusterName; }
public final String getIndexingModeName() { return getIndexingMode().getName(); }
public final boolean isStreaming() { return getIndexingMode() == IndexingMode.STREAMING; }
public final void setQueryTimeout(Double to) { this.queryTimeout = to; }
public final void setVisibilityDelay(double delay) { this.visibilityDelay = delay; }
protected abstract IndexingMode getIndexingMode();
public final Double getVisibilityDelay() { return visibilityDelay; }
public final Double getQueryTimeout() { return queryTimeout; }
public abstract int getRowBits();
public final void setClusterIndex(int index) { this.index = index; }
public final int getClusterIndex() { return index; }
public abstract void defaultDocumentsConfig();
public abstract void getConfig(AttributesConfig.Builder builder);
public abstract void getConfig(RankProfilesConfig.Builder builder);
@Override
public String toString() { return "search-capable cluster '" + clusterName + "'"; }
public static final class IndexingMode {
public static final IndexingMode REALTIME = new IndexingMode("REALTIME");
public static final IndexingMode STREAMING = new IndexingMode("STREAMING");
private final String name;
private IndexingMode(String name) {
this.name = name;
}
public String getName() { return name; }
public String toString() {
return "indexingmode: " + name;
}
}
}
|