diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-04-21 18:53:40 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-04-21 18:53:40 +0200 |
commit | 1ddfba9719112eb5fb0926cbd6350c567dc6c2d1 (patch) | |
tree | bf6e2029ce2fa82944b91f2bd104bbc7ecd6d8d6 /config-model | |
parent | 48694b599605cabaaee4251ce98d44afc87f7bde (diff) |
Add restart handling for changes to dictionary.
Diffstat (limited to 'config-model')
4 files changed, 39 insertions, 2 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/VespaRestartAction.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/VespaRestartAction.java index ca3a408b2e0..69cd022d939 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/VespaRestartAction.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/VespaRestartAction.java @@ -6,7 +6,6 @@ import com.yahoo.config.model.api.ServiceInfo; import com.yahoo.config.provision.ClusterSpec; import java.util.List; -import java.util.Optional; /** * Represents an action to restart services in order to handle a config change. diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidator.java index 0c3354d2af5..8406e116ad7 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidator.java @@ -6,6 +6,8 @@ import com.yahoo.documentmodel.NewDocumentType; import com.yahoo.searchdefinition.derived.AttributeFields; import com.yahoo.searchdefinition.derived.IndexSchema; import com.yahoo.searchdefinition.document.Attribute; +import com.yahoo.searchdefinition.document.Case; +import com.yahoo.searchdefinition.document.Dictionary; import com.yahoo.searchdefinition.document.HnswIndexParams; import com.yahoo.vespa.model.application.validation.change.VespaConfigChangeAction; import com.yahoo.vespa.model.application.validation.change.VespaRestartAction; @@ -83,6 +85,16 @@ public class AttributeChangeValidator { return attribute.hnswIndexParams().isPresent(); } + private static Dictionary.Type extractDictionaryType(Attribute attr) { + Dictionary dict = attr.getDictionary(); + return dict != null ? dict.getType() : Dictionary.Type.BTREE; + } + + private static Case extractDictionaryCase(Attribute attr) { + Dictionary dict = attr.getDictionary(); + return dict != null ? dict.getMatch() : Case.UNCASED; + } + private List<VespaConfigChangeAction> validateAttributeSettings() { List<VespaConfigChangeAction> result = new ArrayList<>(); for (Attribute nextAttr : nextFields.attributes()) { @@ -91,6 +103,8 @@ public class AttributeChangeValidator { // These validations can be removed as there are they are 1-1 with attributes.def which has restart annotations for them. validateAttributeSetting(id, currAttr, nextAttr, Attribute::isFastSearch, "fast-search", result); validateAttributeSetting(id, currAttr, nextAttr, Attribute::isFastAccess, "fast-access", result); + validateAttributeSetting(id, currAttr, nextAttr, AttributeChangeValidator::extractDictionaryType, "dictionary: btree/hash", result); + validateAttributeSetting(id, currAttr, nextAttr, AttributeChangeValidator::extractDictionaryCase, "dictionary: cased/uncased", result); validateAttributeSetting(id, currAttr, nextAttr, Attribute::isHuge, "huge", result); validateAttributeSetting(id, currAttr, nextAttr, Attribute::densePostingListThreshold, "dense-posting-list-threshold", result); validateAttributeSetting(id, currAttr, nextAttr, Attribute::isEnabledOnlyBitVector, "rank: filter", result); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ConfigChangeTestUtils.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ConfigChangeTestUtils.java index 2157839ef5c..7f92d2f409c 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ConfigChangeTestUtils.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ConfigChangeTestUtils.java @@ -6,7 +6,6 @@ import com.yahoo.config.model.api.ConfigChangeAction; import com.yahoo.config.model.api.ServiceInfo; import com.yahoo.config.provision.ClusterSpec; -import java.time.Instant; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidatorTest.java index e89f0c0a9cd..2a462859806 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidatorTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidatorTest.java @@ -3,6 +3,7 @@ package com.yahoo.vespa.model.application.validation.change.search; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.vespa.model.application.validation.change.VespaConfigChangeAction; +import org.junit.Ignore; import org.junit.Test; import java.util.List; @@ -69,6 +70,22 @@ public class AttributeChangeValidatorTest { } @Test + public void changing_btree2hash_require_restart() throws Exception { + new Fixture("field f1 type long { indexing: attribute\n attribute: fast-search\n dictionary: btree}", + "field f1 type long { indexing: attribute\n attribute: fast-search\n dictionary: hash }"). + assertValidation(newRestartAction(ClusterSpec.Id.from("test"), + "Field 'f1' changed: change property 'dictionary: btree/hash' from 'BTREE' to 'HASH'")); + } + + @Test + public void changing_hash2btree_require_restart() throws Exception { + new Fixture("field f1 type long { indexing: attribute\n attribute: fast-search\n dictionary: hash}", + "field f1 type long { indexing: attribute\n attribute: fast-search\n dictionary: btree }"). + assertValidation(newRestartAction(ClusterSpec.Id.from("test"), + "Field 'f1' changed: change property 'dictionary: btree/hash' from 'HASH' to 'BTREE'")); + } + + @Test public void changing_fast_access_require_restart() throws Exception { new Fixture("field f1 type string { indexing: attribute \n attribute: fast-access }", "field f1 type string { indexing: attribute }"). @@ -76,6 +93,14 @@ public class AttributeChangeValidatorTest { "Field 'f1' changed: remove attribute 'fast-access'")); } + @Ignore // Not testable until one dictionary supports both casings + public void changing_uncased2cased_require_restart() throws Exception { + new Fixture("field f1 type string { indexing: attribute\n attribute: fast-search\n dictionary { hash\ncased}\nmatch:cased}", + "field f1 type string { indexing: attribute\n attribute: fast-search\n dictionary{ btree} }"). + assertValidation(newRestartAction(ClusterSpec.Id.from("test"), + "Field 'f1' changed: change property 'dictionary: btree/hash' from 'HASH' to 'BTREE'")); + } + @Test public void changing_huge_require_restart() throws Exception { new Fixture("field f1 type string { indexing: attribute }", |