diff options
author | Geir Storli <geirst@oath.com> | 2017-08-23 14:43:30 +0200 |
---|---|---|
committer | Geir Storli <geirst@oath.com> | 2017-08-23 14:43:30 +0200 |
commit | 8bb6723b6b4deeac34d8ad75930c6adf2dba924b (patch) | |
tree | 002a23529b0807237739b6e48f772a7b5734e040 | |
parent | fd040bb34edc8224cf8cb4f874d7c19f70e50318 (diff) |
Set visibility delay to zero for all global document types.
This is to ensure consistency between parent and child document types
in the search core when using parent-child features.
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java | 6 | ||||
-rw-r--r-- | config-model/src/test/java/com/yahoo/vespa/model/content/cluster/ClusterTest.java | 30 |
2 files changed, 31 insertions, 5 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java index 10f9983bdfb..4481c53e248 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java @@ -279,16 +279,20 @@ public class ContentSearchCluster extends AbstractConfigProducer implements Prot for (NewDocumentType type : documentDefinitions.values()) { ProtonConfig.Documentdb.Builder ddbB = new ProtonConfig.Documentdb.Builder(); String docTypeName = type.getFullName().getName(); + boolean globalDocType = isGloballyDistributed(type); ddbB.inputdoctypename(docTypeName) .configid(getConfigId()) .visibilitydelay(visibilityDelay) - .global(isGloballyDistributed(type)); + .global(globalDocType); Optional<StreamingSearchCluster> ssc = findStreamingCluster(docTypeName); if (ssc.isPresent()) { ddbB.inputdoctypename(type.getFullName().getName()).configid(ssc.get().getDocumentDBConfigId()); } else if (hasIndexedCluster()) { getIndexed().fillDocumentDBConfig(type.getFullName().getName(), ddbB); } + if (globalDocType) { + ddbB.visibilitydelay(0.0); + } builder.documentdb(ddbB); } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/ClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/ClusterTest.java index 60d13c3e4c7..eb62788380f 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/ClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/ClusterTest.java @@ -36,9 +36,7 @@ public class ClusterTest { assertNotNull(searchCluster); assertEquals(1.1, searchCluster.getQueryTimeout(), 1E-6); assertEquals(2.3, searchCluster.getVisibilityDelay(), 1E-6); - ProtonConfig.Builder builder = new ProtonConfig.Builder(); - cluster.getSearch().getConfig(builder); - ProtonConfig proton = new ProtonConfig(builder); + ProtonConfig proton = getProtonConfig(cluster); assertEquals(searchCluster.getVisibilityDelay(), proton.documentdb(0).visibilitydelay(), 1E-6); } @@ -61,7 +59,20 @@ public class ClusterTest { } } + @Test + public void requireThatVisibilityDelayIsZeroForGlobalDocumentType() throws ParseException { + ContentCluster cluster = newContentCluster(joinLines("<search>", + " <visibility-delay>2.3</visibility-delay>", + "</search>"), true); + ProtonConfig proton = getProtonConfig(cluster); + assertEquals(0.0, proton.documentdb(0).visibilitydelay(), 1E-6); + } + private static ContentCluster newContentCluster(String contentSearchXml) throws ParseException { + return newContentCluster(contentSearchXml, false); + } + + private static ContentCluster newContentCluster(String contentSearchXml, boolean globalDocType) throws ParseException { ApplicationPackage app = new MockApplicationPackage.Builder() .withHosts(joinLines("<hosts>", " <host name='localhost'><alias>my_host</alias></host>", @@ -72,7 +83,7 @@ public class ClusterTest { " </admin>", " <content version='1.0'>", " <documents>", - " <document mode='index' type='my_document' />", + " " + getDocumentXml(globalDocType), " </documents>", " <engine><proton /></engine>", " <group>", @@ -88,10 +99,21 @@ public class ClusterTest { return contents.get(0).getCluster(); } + private static String getDocumentXml(boolean globalDocType) { + return "<document mode='index' type='my_document' " + (globalDocType ? "global='true' " : "") + "/>"; + } + private static SearchDefinition newSearchDefinition(String name) throws ParseException { SearchBuilder builder = new SearchBuilder(); builder.importString("search " + name + " { document " + name + " { } }"); builder.build(); return new SearchDefinition(name, builder.getSearch(name)); } + + private static ProtonConfig getProtonConfig(ContentCluster cluster) { + ProtonConfig.Builder builder = new ProtonConfig.Builder(); + cluster.getSearch().getConfig(builder); + return new ProtonConfig(builder); + } + } |