diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-06-01 11:31:13 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-06-01 11:31:13 +0200 |
commit | cd6e2dd7ab638487c462c40293a0d8db43fdb530 (patch) | |
tree | edf9cec58f4a0e995fd713089779ec5d0a14d134 /config-model | |
parent | f7d0fe5fdfad579e867f01acc1d41b2ec77bd785 (diff) | |
parent | 5c57852b26126d72b080fb6e0893dc3d633c28c1 (diff) |
Merge with master
Diffstat (limited to 'config-model')
13 files changed, 210 insertions, 164 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java index c7ca1a33ff2..fc75f7a19fc 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java @@ -5,6 +5,7 @@ import com.yahoo.config.subscription.ConfigInstanceUtil; import com.yahoo.document.ArrayDataType; import com.yahoo.document.DataType; import com.yahoo.document.Field; +import com.yahoo.document.MapDataType; import com.yahoo.document.PositionDataType; import com.yahoo.document.StructDataType; import com.yahoo.searchdefinition.Search; @@ -44,39 +45,59 @@ public class AttributeFields extends Derived implements AttributesConfig.Produce /** Derives everything from a field */ @Override protected void derive(ImmutableSDField field, Search search) { - boolean fieldIsArrayOfSimpleStruct = isArrayOfSimpleStruct(field); - if (field.usesStructOrMap() && - !fieldIsArrayOfSimpleStruct && - !field.getDataType().equals(PositionDataType.INSTANCE) && - !field.getDataType().equals(DataType.getArray(PositionDataType.INSTANCE))) { - return; // Ignore struct fields for indexed search (only implemented for streaming search) + if (unsupportedFieldType(field)) { + return; // Ignore majority of struct fields for indexed search (only implemented for streaming search) } if (field.isImportedField()) { deriveImportedAttributes(field); - } else if (fieldIsArrayOfSimpleStruct) { + } else if (isArrayOfSimpleStruct(field)) { deriveArrayOfSimpleStruct(field); + } else if (isMapOfSimpleStruct(field)) { + deriveMapOfSimpleStruct(field); } else { deriveAttributes(field); } } + private static boolean unsupportedFieldType(ImmutableSDField field) { + return (field.usesStructOrMap() && + !isArrayOfSimpleStruct(field) && + !isMapOfSimpleStruct(field) && + !field.getDataType().equals(PositionDataType.INSTANCE) && + !field.getDataType().equals(DataType.getArray(PositionDataType.INSTANCE))); + } + private static boolean isArrayOfSimpleStruct(ImmutableSDField field) { DataType fieldType = field.getDataType(); if (fieldType instanceof ArrayDataType) { ArrayDataType arrayType = (ArrayDataType)fieldType; - DataType nestedType = arrayType.getNestedType(); - if (nestedType instanceof StructDataType && - !(nestedType.equals(PositionDataType.INSTANCE))) { - StructDataType structType = (StructDataType)nestedType; - for (Field innerField : structType.getFields()) { - if (!isPrimitiveType(innerField.getDataType())) { - return false; - } + return isSimpleStruct(arrayType.getNestedType()); + } else { + return false; + } + } + + private static boolean isMapOfSimpleStruct(ImmutableSDField field) { + DataType fieldType = field.getDataType(); + if (fieldType instanceof MapDataType) { + MapDataType mapType = (MapDataType)fieldType; + return isPrimitiveType(mapType.getKeyType()) && + isSimpleStruct(mapType.getValueType()); + } else { + return false; + } + } + + private static boolean isSimpleStruct(DataType type) { + if (type instanceof StructDataType && + !(type.equals(PositionDataType.INSTANCE))) { + StructDataType structType = (StructDataType) type; + for (Field innerField : structType.getFields()) { + if (!isPrimitiveType(innerField.getDataType())) { + return false; } - return true; - } else { - return false; } + return true; } else { return false; } @@ -138,14 +159,33 @@ public class AttributeFields extends Derived implements AttributesConfig.Produce private void deriveArrayOfSimpleStruct(ImmutableSDField field) { for (ImmutableSDField structField : field.getStructFields()) { - for (Attribute attribute : structField.getAttributes().values()) { - if (structField.getName().equals(attribute.getName())) { - attributes.put(attribute.getName(), attribute.convertToArray()); - } + deriveAttributesAsArrayType(structField); + } + } + + private void deriveAttributesAsArrayType(ImmutableSDField field) { + for (Attribute attribute : field.getAttributes().values()) { + if (field.getName().equals(attribute.getName())) { + attributes.put(attribute.getName(), attribute.convertToArray()); } } } + private void deriveMapOfSimpleStruct(ImmutableSDField field) { + deriveMapKeyField(field.getStructField("key")); + deriveMapValueField(field.getStructField("value")); + } + + private void deriveMapKeyField(ImmutableSDField keyField) { + deriveAttributesAsArrayType(keyField); + } + + private void deriveMapValueField(ImmutableSDField valueField) { + for (ImmutableSDField structField : valueField.getStructFields()) { + deriveAttributesAsArrayType(structField); + } + } + /** Returns a read only attribute iterator */ public Iterator attributeIterator() { return attributes().iterator(); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/GlobalDistributionValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/content/GlobalDistributionValidator.java index 4bdef0607a2..0661ef67131 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/content/GlobalDistributionValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/content/GlobalDistributionValidator.java @@ -21,45 +21,11 @@ import static java.util.stream.Collectors.toSet; public class GlobalDistributionValidator { public void validate(Map<String, NewDocumentType> documentDefinitions, - Set<NewDocumentType> globallyDistributedDocuments, - Redundancy redundancy, - boolean enableMultipleBucketSpaces) { - if (!enableMultipleBucketSpaces) { - verifyGlobalDocumentsHaveRequiredRedundancy(globallyDistributedDocuments, redundancy); - verifySearchableCopiesIsSameAsRedundancy(globallyDistributedDocuments, redundancy); - } + Set<NewDocumentType> globallyDistributedDocuments) { verifyReferredDocumentsArePresent(documentDefinitions); verifyReferredDocumentsAreGlobal(documentDefinitions, globallyDistributedDocuments); } - private static void verifyGlobalDocumentsHaveRequiredRedundancy(Set<NewDocumentType> globallyDistributedDocuments, - Redundancy redundancy) { - if (!globallyDistributedDocuments.isEmpty() && !redundancy.isEffectivelyGloballyDistributed()) { - throw new IllegalArgumentException( - String.format( - "The following document types are marked as global, " + - "but do not have high enough redundancy to make the documents globally distributed: %s. " + - "Redundancy is %d, expected %d.", - asPrintableString(toDocumentNameStream(globallyDistributedDocuments)), - redundancy.effectiveFinalRedundancy(), - redundancy.totalNodes())); - } - } - - private static void verifySearchableCopiesIsSameAsRedundancy(Set<NewDocumentType> globallyDistributedDocuments, - Redundancy redundancy) { - if (!globallyDistributedDocuments.isEmpty() && - redundancy.effectiveReadyCopies() != redundancy.effectiveFinalRedundancy()) { - throw new IllegalArgumentException( - String.format( - "The following document types have the number of searchable copies less than redundancy: %s. " + - "Searchable copies is %d, while redundancy is %d.", - asPrintableString(toDocumentNameStream(globallyDistributedDocuments)), - redundancy.effectiveReadyCopies(), - redundancy.effectiveFinalRedundancy())); - } - } - private static void verifyReferredDocumentsArePresent(Map<String, NewDocumentType> documentDefinitions) { Set<NewDocumentType.Name> unknowDocuments = getReferencedDocuments(documentDefinitions) .filter(name -> !documentDefinitions.containsKey(name.toString())) 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 0119bced095..68ae4d2b242 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 @@ -61,14 +61,12 @@ public class ContentCluster extends AbstractConfigProducer implements MessagetyperouteselectorpolicyConfig.Producer, BucketspacesConfig.Producer { - // TODO: Make private private String documentSelection; private ContentSearchCluster search; private final boolean isHostedVespa; private final Map<String, NewDocumentType> documentDefinitions; private final Set<NewDocumentType> globallyDistributedDocuments; - // Experimental flag (TODO: remove when feature is enabled by default) - private boolean enableMultipleBucketSpaces = false; + private boolean forceEnableMultipleBucketSpaces = false; private com.yahoo.vespa.model.content.StorageGroup rootGroup; private StorageCluster storageNodes; private DistributorCluster distributorNodes; @@ -250,7 +248,7 @@ public class ContentCluster extends AbstractConfigProducer implements private void setupExperimental(ContentCluster cluster, ModelElement experimental) { Boolean enableMultipleBucketSpaces = experimental.childAsBoolean("enable-multiple-bucket-spaces"); if (enableMultipleBucketSpaces != null) { - cluster.enableMultipleBucketSpaces = enableMultipleBucketSpaces; + cluster.forceEnableMultipleBucketSpaces = enableMultipleBucketSpaces; } } @@ -596,13 +594,13 @@ public class ContentCluster extends AbstractConfigProducer implements builder.min_distributor_up_ratio(0); builder.min_storage_up_ratio(0); } - builder.enable_multiple_bucket_spaces(enableMultipleBucketSpaces); + builder.enable_multiple_bucket_spaces(true); // Telling the controller whether we actually _have_ global document types lets // it selectively enable or disable constraints that aren't needed when these // are not are present, even if full protocol and backend support is enabled // for multiple bucket spaces. Basically, if you don't use it, you don't // pay for it. - builder.cluster_has_global_document_types(enableMultipleBucketSpaces && !globallyDistributedDocuments.isEmpty()); + builder.cluster_has_global_document_types(!globallyDistributedDocuments.isEmpty()); } @Override @@ -646,7 +644,7 @@ public class ContentCluster extends AbstractConfigProducer implements } } new ReservedDocumentTypeNameValidator().validate(documentDefinitions); - new GlobalDistributionValidator().validate(documentDefinitions, globallyDistributedDocuments, redundancy, enableMultipleBucketSpaces); + new GlobalDistributionValidator().validate(documentDefinitions, globallyDistributedDocuments); } public static Map<String, Integer> METRIC_INDEX_MAP = new TreeMap<>(); @@ -727,11 +725,13 @@ public class ContentCluster extends AbstractConfigProducer implements for (NewDocumentType docType : getDocumentDefinitions().values()) { BucketspacesConfig.Documenttype.Builder docTypeBuilder = new BucketspacesConfig.Documenttype.Builder(); docTypeBuilder.name(docType.getName()); - String bucketSpace = ((enableMultipleBucketSpaces && isGloballyDistributed(docType)) - ? GLOBAL_BUCKET_SPACE : DEFAULT_BUCKET_SPACE); + String bucketSpace = (isGloballyDistributed(docType) ? GLOBAL_BUCKET_SPACE : DEFAULT_BUCKET_SPACE); docTypeBuilder.bucketspace(bucketSpace); builder.documenttype(docTypeBuilder); } - builder.enable_multiple_bucket_spaces(enableMultipleBucketSpaces); + // NOTE: this config is kept around to allow the use of multiple bucket spaces + // on older versions of Vespa. It is for all intents and purposes a no-op in + // newer versions where multiple bucket spaces are enabled by default. + builder.enable_multiple_bucket_spaces(forceEnableMultipleBucketSpaces); } } diff --git a/config-model/src/test/derived/map_of_struct_attribute/attributes.cfg b/config-model/src/test/derived/map_of_struct_attribute/attributes.cfg new file mode 100644 index 00000000000..604fc1f6ea7 --- /dev/null +++ b/config-model/src/test/derived/map_of_struct_attribute/attributes.cfg @@ -0,0 +1,60 @@ +attribute[0].name "elem_map.key" +attribute[0].datatype STRING +attribute[0].collectiontype ARRAY +attribute[0].removeifzero false +attribute[0].createifnonexistent false +attribute[0].fastsearch false +attribute[0].huge false +attribute[0].sortascending true +attribute[0].sortfunction UCA +attribute[0].sortstrength PRIMARY +attribute[0].sortlocale "" +attribute[0].enablebitvectors false +attribute[0].enableonlybitvector false +attribute[0].fastaccess false +attribute[0].arity 8 +attribute[0].lowerbound -9223372036854775808 +attribute[0].upperbound 9223372036854775807 +attribute[0].densepostinglistthreshold 0.4 +attribute[0].tensortype "" +attribute[0].imported false +attribute[1].name "elem_map.value.name" +attribute[1].datatype STRING +attribute[1].collectiontype ARRAY +attribute[1].removeifzero false +attribute[1].createifnonexistent false +attribute[1].fastsearch false +attribute[1].huge false +attribute[1].sortascending true +attribute[1].sortfunction UCA +attribute[1].sortstrength PRIMARY +attribute[1].sortlocale "" +attribute[1].enablebitvectors false +attribute[1].enableonlybitvector false +attribute[1].fastaccess false +attribute[1].arity 8 +attribute[1].lowerbound -9223372036854775808 +attribute[1].upperbound 9223372036854775807 +attribute[1].densepostinglistthreshold 0.4 +attribute[1].tensortype "" +attribute[1].imported false +attribute[2].name "elem_map.value.weight" +attribute[2].datatype INT32 +attribute[2].collectiontype ARRAY +attribute[2].removeifzero false +attribute[2].createifnonexistent false +attribute[2].fastsearch false +attribute[2].huge false +attribute[2].sortascending true +attribute[2].sortfunction UCA +attribute[2].sortstrength PRIMARY +attribute[2].sortlocale "" +attribute[2].enablebitvectors false +attribute[2].enableonlybitvector false +attribute[2].fastaccess false +attribute[2].arity 8 +attribute[2].lowerbound -9223372036854775808 +attribute[2].upperbound 9223372036854775807 +attribute[2].densepostinglistthreshold 0.4 +attribute[2].tensortype "" +attribute[2].imported false
\ No newline at end of file diff --git a/config-model/src/test/derived/map_of_struct_attribute/summary.cfg b/config-model/src/test/derived/map_of_struct_attribute/summary.cfg new file mode 100644 index 00000000000..7af49d95d09 --- /dev/null +++ b/config-model/src/test/derived/map_of_struct_attribute/summary.cfg @@ -0,0 +1,11 @@ +defaultsummaryid 653486243 +classes[0].id 653486243 +classes[0].name "default" +classes[0].fields[0].name "elem_map" +classes[0].fields[0].type "jsonstring" +classes[0].fields[1].name "rankfeatures" +classes[0].fields[1].type "featuredata" +classes[0].fields[2].name "summaryfeatures" +classes[0].fields[2].type "featuredata" +classes[0].fields[3].name "documentid" +classes[0].fields[3].type "longstring"
\ No newline at end of file diff --git a/config-model/src/test/derived/map_of_struct_attribute/summarymap.cfg b/config-model/src/test/derived/map_of_struct_attribute/summarymap.cfg new file mode 100644 index 00000000000..42b6e811ee6 --- /dev/null +++ b/config-model/src/test/derived/map_of_struct_attribute/summarymap.cfg @@ -0,0 +1,7 @@ +defaultoutputclass -1 +override[0].field "rankfeatures" +override[0].command "rankfeatures" +override[0].arguments "" +override[1].field "summaryfeatures" +override[1].command "summaryfeatures" +override[1].arguments ""
\ No newline at end of file diff --git a/config-model/src/test/derived/map_of_struct_attribute/test.sd b/config-model/src/test/derived/map_of_struct_attribute/test.sd new file mode 100644 index 00000000000..cb2eac4ed78 --- /dev/null +++ b/config-model/src/test/derived/map_of_struct_attribute/test.sd @@ -0,0 +1,20 @@ +search test { + document test { + struct elem { + field name type string {} + field weight type int {} + } + field elem_map type map<string,elem> { + indexing: summary + struct-field key { + indexing: attribute + } + struct-field value.name { + indexing: attribute + } + struct-field value.weight { + indexing: attribute + } + } + } +} diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java index 990ebe7f993..c3cfcae66e6 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java @@ -79,6 +79,17 @@ public class AttributeListTestCase extends SearchDefinitionTestCase { assertTrue(!attributes.hasNext()); } + @Test + public void map_of_struct_field_is_derived_into_array_attributes() throws IOException, ParseException { + Search search = SearchBuilder.buildFromFile("src/test/derived/map_of_struct_attribute/test.sd"); + Iterator<Attribute> attributes = new AttributeFields(search).attributeIterator(); + + assertAttribute("elem_map.key", Attribute.Type.STRING, Attribute.CollectionType.ARRAY, attributes.next()); + assertAttribute("elem_map.value.name", Attribute.Type.STRING, Attribute.CollectionType.ARRAY, attributes.next()); + assertAttribute("elem_map.value.weight", Attribute.Type.INTEGER, Attribute.CollectionType.ARRAY, attributes.next()); + assertTrue(!attributes.hasNext()); + } + private static void assertAttribute(String name, Attribute.Type type, Attribute.CollectionType collection, Attribute attr) { assertEquals(name, attr.getName()); assertEquals(type, attr.getType()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributesTestCase.java index 9e73edf9b35..72c7aab4a39 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributesTestCase.java @@ -18,4 +18,14 @@ public class AttributesTestCase extends AbstractExportingTestCase { assertCorrectDeriving("attributes"); } + @Test + public void testArrayOfStructAttribute() throws IOException, ParseException { + assertCorrectDeriving("array_of_struct_attribute"); + } + + @Test + public void testMapOfStructAttribute() throws IOException, ParseException { + assertCorrectDeriving("map_of_struct_attribute"); + } + } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/ExportingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/ExportingTestCase.java index dc2d3b7cea1..4600f6ae4c6 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/ExportingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/ExportingTestCase.java @@ -139,9 +139,4 @@ public class ExportingTestCase extends AbstractExportingTestCase { assertCorrectDeriving("tensor"); } - @Test - public void testArrayOfStructAttribute() throws IOException, ParseException { - assertCorrectDeriving("array_of_struct_attribute"); - } - } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/ContentSearchClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/ContentSearchClusterTest.java index 98177b4ada0..0156128f7ca 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/ContentSearchClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/ContentSearchClusterTest.java @@ -173,17 +173,17 @@ public class ContentSearchClusterTest { } @Test - public void require_that_all_document_types_belong_to_default_bucket_space_by_default() throws Exception { + public void require_that_document_types_belong_to_correct_bucket_spaces() throws Exception { BucketspacesConfig config = getBucketspacesConfig(createClusterWithGlobalType()); assertEquals(2, config.documenttype().size()); - assertDocumentType("global", "default", config.documenttype(0)); + assertDocumentType("global", "global", config.documenttype(0)); assertDocumentType("regular", "default", config.documenttype(1)); // Safeguard against flipping the switch assertFalse(config.enable_multiple_bucket_spaces()); } @Test - public void require_that_multiple_bucket_spaces_can_be_enabled() throws Exception { + public void require_that_multiple_bucket_spaces_can_be_force_enabled() throws Exception { ContentCluster cluster = createClusterWithMultipleBucketSpacesEnabled(); { BucketspacesConfig config = getBucketspacesConfig(cluster); @@ -210,9 +210,9 @@ public class ContentSearchClusterTest { } @Test - public void controller_global_documents_config_forced_to_false_if_multiple_spaces_not_enabled() throws Exception { + public void controller_global_documents_config_always_enabled_even_without_experimental_flag_set() throws Exception { ContentCluster cluster = createClusterWithGlobalDocsButNotMultipleSpacesEnabled(); - assertFalse(getFleetcontrollerConfig(cluster).cluster_has_global_document_types()); + assertTrue(getFleetcontrollerConfig(cluster).cluster_has_global_document_types()); } } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/GlobalDistributionValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/GlobalDistributionValidatorTest.java index b8252f2f081..6506f7a08a8 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/GlobalDistributionValidatorTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/GlobalDistributionValidatorTest.java @@ -26,64 +26,16 @@ public class GlobalDistributionValidatorTest { public final ExpectedException exceptionRule = ExpectedException.none(); @Test - public void throws_exception_if_redudancy_does_not_imply_global_distribution() { - Fixture fixture = new Fixture() - .addGlobalDocument(createDocumentType("foo")) - .addGlobalDocument(createDocumentType("bar")); - Redundancy redundancy = createRedundancyWithoutGlobalDistribution(); - - exceptionRule.expect(IllegalArgumentException.class); - exceptionRule.expectMessage( - "The following document types are marked as global, " + - "but do not have high enough redundancy to make the documents globally distributed: " + - "'bar', 'foo'. Redundancy is 2, expected 3."); - validate(fixture, redundancy); - } - - @Test - public void validation_of_redundancy_is_deactivated_if_multiple_bucket_spaces_is_enabled() { - Fixture fixture = new Fixture() - .addGlobalDocument(createDocumentType("foo")) - .addGlobalDocument(createDocumentType("bar")); - Redundancy redundancy = createRedundancyWithoutGlobalDistributionAndTooFewSearchableCopies(); - - validate(fixture, redundancy, true); - } - - @Test - public void throws_exception_if_searchable_copies_too_low() { - Fixture fixture = new Fixture() - .addGlobalDocument(createDocumentType("foo")) - .addGlobalDocument(createDocumentType("bar")); - Redundancy redundancy = createRedundancyWithTooFewSearchableCopies(); - - exceptionRule.expect(IllegalArgumentException.class); - exceptionRule.expectMessage( - "The following document types have the number of searchable copies less than redundancy: " + - "'bar', 'foo'. Searchable copies is 1, while redundancy is 2."); - validate(fixture, redundancy); - } - - @Test - public void validation_succeeds_when_globally_distributed_and_enough_searchable_copies() { - Fixture fixture = new Fixture() - .addGlobalDocument(createDocumentType("foo")); - Redundancy redundancy = createRedundancyWithGlobalDistribution(); - validate(fixture, redundancy); - } - - @Test public void validation_succeeds_on_no_documents() { new GlobalDistributionValidator() - .validate(emptyMap(), emptySet(), createRedundancyWithoutGlobalDistribution(), false); + .validate(emptyMap(), emptySet()); } @Test public void validation_succeeds_on_no_global_documents() { Fixture fixture = new Fixture() .addNonGlobalDocument(createDocumentType("foo")); - Redundancy redundancy = createRedundancyWithoutGlobalDistribution(); - validate(fixture, redundancy); + validate(fixture); } @Test @@ -92,11 +44,10 @@ public class GlobalDistributionValidatorTest { Fixture fixture = new Fixture() .addNonGlobalDocument(parent) .addNonGlobalDocument(createDocumentType("child", parent)); - Redundancy redundancy = createRedundancyWithoutGlobalDistribution(); exceptionRule.expect(IllegalArgumentException.class); exceptionRule.expectMessage( "The following document types are referenced from other documents, but are not globally distributed: 'parent'"); - validate(fixture, redundancy); + validate(fixture); } @Test @@ -105,8 +56,7 @@ public class GlobalDistributionValidatorTest { Fixture fixture = new Fixture() .addGlobalDocument(parent) .addNonGlobalDocument(createDocumentType("child", parent)); - Redundancy redundancy = createRedundancyWithGlobalDistribution(); - validate(fixture, redundancy); + validate(fixture); } @Test @@ -115,11 +65,10 @@ public class GlobalDistributionValidatorTest { NewDocumentType child = createDocumentType("child", unknown); Fixture fixture = new Fixture() .addNonGlobalDocument(child); - Redundancy redundancy = createRedundancyWithGlobalDistribution(); exceptionRule.expect(IllegalArgumentException.class); exceptionRule.expectMessage( "The following document types are referenced from other documents, but are not listed in services.xml: 'unknown'"); - validate(fixture, redundancy); + validate(fixture); } @Test @@ -130,42 +79,14 @@ public class GlobalDistributionValidatorTest { new VespaModelCreatorWithFilePkg("src/test/cfg/application/validation/global_distribution_validation/").create(); } - private static Redundancy createRedundancyWithGlobalDistribution() { - Redundancy redundancy = new Redundancy(2, 2, 2); - redundancy.setTotalNodes(2); - return redundancy; - } - - private static Redundancy createRedundancyWithoutGlobalDistribution() { - Redundancy redundancy = new Redundancy(2, 2, 2); - redundancy.setTotalNodes(3); - return redundancy; - } - - private static Redundancy createRedundancyWithTooFewSearchableCopies() { - Redundancy redundancy = new Redundancy(2, 2, 1); - redundancy.setTotalNodes(2); - return redundancy; - } - - private static Redundancy createRedundancyWithoutGlobalDistributionAndTooFewSearchableCopies() { - Redundancy redundancy = new Redundancy(2, 2, 1); - redundancy.setTotalNodes(3); - return redundancy; - } - private static NewDocumentType createDocumentType(String name, NewDocumentType... references) { Set<NewDocumentType.Name> documentReferences = Stream.of(references).map(NewDocumentType::getFullName).collect(toSet()); return new NewDocumentType(new NewDocumentType.Name(name), documentReferences); } - private static void validate(Fixture fixture, Redundancy redundancy) { - validate(fixture, redundancy, false); - } - - private static void validate(Fixture fixture, Redundancy redundancy, boolean enableMultipleBucketSpaces) { + private static void validate(Fixture fixture) { new GlobalDistributionValidator() - .validate(fixture.getDocumentTypes(), fixture.getGloballyDistributedDocuments(), redundancy, enableMultipleBucketSpaces); + .validate(fixture.getDocumentTypes(), fixture.getGloballyDistributedDocuments()); } private static class Fixture { diff --git a/config-model/src/test/java/com/yahoo/vespa/model/filedistribution/FileDistributorTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/filedistribution/FileDistributorTestCase.java index eabd0e5a7e0..131a5344116 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/filedistribution/FileDistributorTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/filedistribution/FileDistributorTestCase.java @@ -7,10 +7,10 @@ import com.yahoo.config.model.application.provider.MockFileRegistry; import com.yahoo.config.model.test.MockHosts; import org.junit.Test; +import java.io.File; import java.util.Arrays; import java.util.HashSet; import java.util.Set; -import java.util.stream.Collectors; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -48,5 +48,10 @@ public class FileDistributorTestCase { public void startDownload(String hostName, int port, Set<FileReference> fileReferences) { filesToDownloadCalled++; } + + @Override + public File getFileReferencesDir() { + return null; + } } } |