diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2017-08-23 13:11:29 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-23 13:11:29 +0000 |
commit | d0130bf3826707a0ba55d6e170d423838525030b (patch) | |
tree | 0ccecb2e6fff6c3267a1cef0fa2f51907bf79b33 /config-model | |
parent | c9714fd5f0da37b73c075b81da8fe55c007afcc8 (diff) | |
parent | 8bb6723b6b4deeac34d8ad75930c6adf2dba924b (diff) |
Merge pull request #3195 from vespa-engine/geirst/zero-visibility-delay-for-global-doc-types
Geirst/zero visibility delay for global doc types
Diffstat (limited to 'config-model')
-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 | 91 |
2 files changed, 60 insertions, 37 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 1339fb5a5a6..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 @@ -17,6 +17,7 @@ import org.junit.Test; import java.util.List; +import static com.yahoo.config.model.test.TestUtil.joinLines; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -27,31 +28,27 @@ public class ClusterTest { @Test public void requireThatContentSearchIsApplied() throws ParseException { - ContentCluster cluster = newContentCluster( - "<search>" + - " <query-timeout>1.1</query-timeout>" + - " <visibility-delay>2.3</visibility-delay>" + - "</search>"); + ContentCluster cluster = newContentCluster(joinLines("<search>", + " <query-timeout>1.1</query-timeout>", + " <visibility-delay>2.3</visibility-delay>", + "</search>")); IndexedSearchCluster searchCluster = cluster.getSearch().getIndexed(); 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); } @Test public void requireThatSearchCoverageIsApplied() throws ParseException { - ContentCluster cluster = newContentCluster( - "<search>" + - " <coverage>" + - " <minimum>0.11</minimum>" + - " <min-wait-after-coverage-factor>0.23</min-wait-after-coverage-factor>" + - " <max-wait-after-coverage-factor>0.58</max-wait-after-coverage-factor>" + - " </coverage>" + - "</search>"); + ContentCluster cluster = newContentCluster(joinLines("<search>", + " <coverage>", + " <minimum>0.11</minimum>", + " <min-wait-after-coverage-factor>0.23</min-wait-after-coverage-factor>", + " <max-wait-after-coverage-factor>0.58</max-wait-after-coverage-factor>", + " </coverage>", + "</search>")); for (Dispatch tld : cluster.getSearch().getIndexed().getTLDs()) { PartitionsConfig.Builder builder = new PartitionsConfig.Builder(); tld.getConfig(builder); @@ -62,28 +59,39 @@ 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( - "<hosts>" + - " <host name='localhost'><alias>my_host</alias></host>" + - "</hosts>") - .withServices( - "<services version='1.0'>" + - " <admin version='2.0'>" + - " <adminserver hostalias='my_host' />" + - " </admin>" + - " <content version='1.0'>" + - " <documents>" + - " <document mode='index' type='my_document' />" + - " </documents>" + - " <engine><proton /></engine>" + - " <group>" + - " <node hostalias='my_host' distribution-key='0' />" + - " </group>" + - contentSearchXml + - " </content>" + - "</services>") + .withHosts(joinLines("<hosts>", + " <host name='localhost'><alias>my_host</alias></host>", + "</hosts>")) + .withServices(joinLines("<services version='1.0'>", + " <admin version='2.0'>", + " <adminserver hostalias='my_host' />", + " </admin>", + " <content version='1.0'>", + " <documents>", + " " + getDocumentXml(globalDocType), + " </documents>", + " <engine><proton /></engine>", + " <group>", + " <node hostalias='my_host' distribution-key='0' />", + " </group>", + contentSearchXml, + " </content>", + "</services>")) .withSearchDefinitions(ApplicationPackageUtils.generateSearchDefinition("my_document")) .build(); List<Content> contents = new TestDriver().buildModel(app).getConfigModels(Content.class); @@ -91,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); + } + } |