diff options
author | Geir Storli <geirst@oath.com> | 2018-04-03 17:30:50 +0200 |
---|---|---|
committer | Geir Storli <geirst@oath.com> | 2018-04-03 17:30:50 +0200 |
commit | d22a17ac1adff28d17e4a638cbf83b05f0437ffa (patch) | |
tree | daa68d80ef3529ea0a56bf0b85f91640ca7ccd29 /config-model | |
parent | a732c350605fd22d6d6ae1ae0f4b87e466b2d572 (diff) |
Changing attribute rank filter requires restart of content nodes.
Diffstat (limited to 'config-model')
2 files changed, 39 insertions, 22 deletions
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 26bebad93b4..93cd64b76c9 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 @@ -89,11 +89,34 @@ public class AttributeChangeValidator { validateAttributeSetting(currAttr, nextAttr, Attribute::isFastAccess, "fast-access", result); validateAttributeSetting(currAttr, nextAttr, Attribute::isHuge, "huge", result); validateAttributeSetting(currAttr, nextAttr, Attribute::densePostingListThreshold, "dense-posting-list-threshold", result); + validateAttributeSetting(currAttr, nextAttr, Attribute::isEnabledOnlyBitVector, "rank: filter", result); } } return result; } + private static void validateAttributeSetting(Attribute currentAttr, Attribute nextAttr, + Predicate<Attribute> predicate, String setting, + List<VespaConfigChangeAction> result) { + final boolean nextValue = predicate.test(nextAttr); + if (predicate.test(currentAttr) != nextValue) { + String change = nextValue ? "add" : "remove"; + result.add(new VespaRestartAction(new ChangeMessageBuilder(nextAttr.getName()). + addChange(change + " attribute '" + setting + "'").build())); + } + } + + private static <T> void validateAttributeSetting(Attribute currentAttr, Attribute nextAttr, + Function<Attribute, T> settingValueProvider, String setting, + List<VespaConfigChangeAction> result) { + T currentValue = settingValueProvider.apply(currentAttr); + T nextValue = settingValueProvider.apply(nextAttr); + if ( ! Objects.equals(currentValue, nextValue)) { + String message = String.format("change property '%s' from '%s' to '%s'", setting, currentValue, nextValue); + result.add(new VespaRestartAction(new ChangeMessageBuilder(nextAttr.getName()).addChange(message).build())); + } + } + private List<VespaConfigChangeAction> validateTensorTypes(final ValidationOverrides overrides, Instant now) { final List<VespaConfigChangeAction> result = new ArrayList<>(); @@ -128,26 +151,4 @@ public class AttributeChangeValidator { nextAttr.tensorType().get().toString()).build(), now); } - private static void validateAttributeSetting(Attribute currentAttr, Attribute nextAttr, - Predicate<Attribute> predicate, String setting, - List<VespaConfigChangeAction> result) { - final boolean nextValue = predicate.test(nextAttr); - if (predicate.test(currentAttr) != nextValue) { - String change = nextValue ? "add" : "remove"; - result.add(new VespaRestartAction(new ChangeMessageBuilder(nextAttr.getName()). - addChange(change + " attribute '" + setting + "'").build())); - } - } - - private static <T> void validateAttributeSetting(Attribute currentAttr, Attribute nextAttr, - Function<Attribute, T> settingValueProvider, String setting, - List<VespaConfigChangeAction> result) { - T currentValue = settingValueProvider.apply(currentAttr); - T nextValue = settingValueProvider.apply(nextAttr); - if ( ! Objects.equals(currentValue, nextValue)) { - String message = String.format("change property '%s' from '%s' to '%s'", setting, currentValue, nextValue); - result.add(new VespaRestartAction(new ChangeMessageBuilder(nextAttr.getName()).addChange(message).build())); - } - } - } 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 31102a18811..79bbde01898 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 @@ -141,4 +141,20 @@ public class AttributeChangeValidatorTest { } } + @Test + public void adding_rank_filter_requires_restart() throws Exception { + new Fixture("field f1 type string { indexing: attribute }", + "field f1 type string { indexing: attribute \n rank: filter }"). + assertValidation(newRestartAction( + "Field 'f1' changed: add attribute 'rank: filter'")); + } + + @Test + public void removing_rank_filter_requires_restart() throws Exception { + new Fixture("field f1 type string { indexing: attribute \n rank: filter }", + "field f1 type string { indexing: attribute }"). + assertValidation(newRestartAction( + "Field 'f1' changed: remove attribute 'rank: filter'")); + } + } |