summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorGeir Storli <geirst@oath.com>2017-11-23 14:04:42 +0100
committerGeir Storli <geirst@oath.com>2017-11-23 14:08:32 +0100
commit290d7d6cbafb948b60c571d33d0e0e8a072aac66 (patch)
treeadd0893e6342a3468a0bc2b28ce03eb207ce7b1d /config-model
parent68407f968b57fbdff0cccb469e5e49481d4d2508 (diff)
Produce new bucket spaces config for distributor nodes.
This config contains all document types handled by a content cluster and the bucket space each document type belongs to.
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/DistributorCluster.java24
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java4
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/DistributorTest.java38
3 files changed, 59 insertions, 7 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/DistributorCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/content/DistributorCluster.java
index 2bfa8fa93a0..81aca977400 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/DistributorCluster.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/DistributorCluster.java
@@ -1,6 +1,8 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.content;
+import com.yahoo.documentmodel.NewDocumentType;
+import com.yahoo.vespa.config.content.core.BucketspacesConfig;
import com.yahoo.vespa.config.content.core.StorDistributormanagerConfig;
import com.yahoo.vespa.config.content.core.StorServerConfig;
import com.yahoo.document.select.DocumentSelector;
@@ -18,11 +20,15 @@ import java.util.logging.Logger;
/**
* Generates distributor-specific configuration.
*/
-public class DistributorCluster extends AbstractConfigProducer<Distributor>
- implements StorDistributormanagerConfig.Producer, StorServerConfig.Producer, MetricsmanagerConfig.Producer {
+public class DistributorCluster extends AbstractConfigProducer<Distributor> implements
+ StorDistributormanagerConfig.Producer,
+ StorServerConfig.Producer,
+ MetricsmanagerConfig.Producer,
+ BucketspacesConfig.Producer {
public static final Logger log = Logger.getLogger(DistributorCluster.class.getPackage().toString());
+
private static class GcOptions {
public final int interval;
public final String selection;
@@ -145,6 +151,20 @@ public class DistributorCluster extends AbstractConfigProducer<Distributor>
builder.is_distributor(true);
}
+ private static final String DEFAULT_BUCKET_SPACE = "default";
+ private static final String GLOBAL_BUCKET_SPACE = "global";
+
+ @Override
+ public void getConfig(BucketspacesConfig.Builder builder) {
+ for (NewDocumentType docType : parent.getDocumentDefinitions().values()) {
+ BucketspacesConfig.Documenttype.Builder docTypeBuilder = new BucketspacesConfig.Documenttype.Builder();
+ docTypeBuilder.name(docType.getName());
+ String bucketSpace = (parent.isGloballyDistributed(docType) ? GLOBAL_BUCKET_SPACE : DEFAULT_BUCKET_SPACE);
+ docTypeBuilder.bucketspace(bucketSpace);
+ builder.documenttype(docTypeBuilder);
+ }
+ }
+
public String getClusterName() {
return parent.getName();
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java
index c7755d3de5a..7889b857fff 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java
@@ -524,6 +524,10 @@ public class ContentCluster extends AbstractConfigProducer implements StorDistri
*/
public Map<String, NewDocumentType> getDocumentDefinitions() { return documentDefinitions; }
+ public boolean isGloballyDistributed(NewDocumentType docType) {
+ return globallyDistributedDocuments.contains(docType);
+ }
+
public final ContentSearchCluster getSearch() { return search; }
public Redundancy redundancy() { return redundancy; }
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/DistributorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/DistributorTest.java
index 624d3e8ded8..d4e804d3f95 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/DistributorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/DistributorTest.java
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.content;
+import com.yahoo.vespa.config.content.core.BucketspacesConfig;
import com.yahoo.vespa.config.content.core.StorCommunicationmanagerConfig;
import com.yahoo.vespa.config.content.core.StorDistributormanagerConfig;
import com.yahoo.vespa.config.content.core.StorServerConfig;
@@ -305,22 +306,28 @@ public class DistributorTest {
private static class DocDef {
public final String type;
public final String mode;
+ public final boolean global;
- private DocDef(String type, String mode) {
+ private DocDef(String type, String mode, boolean global) {
this.type = type;
this.mode = mode;
+ this.global = global;
}
public static DocDef storeOnly(String type) {
- return new DocDef(type, "store-only");
+ return new DocDef(type, "store-only", false);
}
public static DocDef index(String type) {
- return new DocDef(type, "index");
+ return new DocDef(type, "index", false);
+ }
+
+ public static DocDef indexGlobal(String type) {
+ return new DocDef(type, "index", true);
}
public static DocDef streaming(String type) {
- return new DocDef(type, "streaming");
+ return new DocDef(type, "streaming", false);
}
}
@@ -328,7 +335,8 @@ public class DistributorTest {
return "<content id='storage'>\n" +
" <documents>\n" +
Arrays.stream(defs)
- .map(def -> String.format(" <document type='%s' mode='%s'/>", def.type, def.mode))
+ .map(def -> String.format(" <document type='%s' mode='%s' global='%s'/>",
+ def.type, def.mode, (def.global ? "true" : "false")))
.collect(Collectors.joining("\n")) +
"\n </documents>\n" +
"</content>";
@@ -371,4 +379,24 @@ public class DistributorTest {
generateXmlForDocDefs(DocDef.streaming("music")));
assertThat(config.disable_bucket_activation(), is(true));
}
+
+ private BucketspacesConfig clusterXmlToBucketspacesConfig(String xml) {
+ BucketspacesConfig.Builder builder = new BucketspacesConfig.Builder();
+ parse(xml).getConfig(builder);
+ return new BucketspacesConfig(builder);
+ }
+
+ private void assertDocumentType(String expName, String expBucketSpace, BucketspacesConfig.Documenttype docType) {
+ assertEquals(expName, docType.name());
+ assertEquals(expBucketSpace, docType.bucketspace());
+ }
+
+ @Test
+ public void bucket_spaces_config_is_produced_for_distributor_cluster() {
+ BucketspacesConfig config = clusterXmlToBucketspacesConfig(
+ generateXmlForDocDefs(DocDef.index("music"), DocDef.indexGlobal("movies")));
+ assertEquals(2, config.documenttype().size());
+ assertDocumentType("movies", "global", config.documenttype(0));
+ assertDocumentType("music", "default", config.documenttype(1));
+ }
}