org.elasticsearch.common.settings.Setting.Property Java Examples
The following examples show how to use
org.elasticsearch.common.settings.Setting.Property.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SettingTests.java From crate with Apache License 2.0 | 6 votes |
/** * Only one single scope can be added to any setting */ @Test public void testMutuallyExclusiveScopes() { // Those should pass Setting<String> setting = Setting.simpleString("foo.bar", Property.NodeScope); assertThat(setting.hasNodeScope(), is(true)); assertThat(setting.hasIndexScope(), is(false)); setting = Setting.simpleString("foo.bar", Property.IndexScope); assertThat(setting.hasIndexScope(), is(true)); assertThat(setting.hasNodeScope(), is(false)); // We accept settings with no scope but they will be rejected when we register with SettingsModule.registerSetting setting = Setting.simpleString("foo.bar"); assertThat(setting.hasIndexScope(), is(false)); assertThat(setting.hasNodeScope(), is(false)); // We accept settings with multiple scopes but they will be rejected when we register with SettingsModule.registerSetting setting = Setting.simpleString("foo.bar", Property.IndexScope, Property.NodeScope); assertThat(setting.hasIndexScope(), is(true)); assertThat(setting.hasNodeScope(), is(true)); }
Example #2
Source File: SettingTests.java From crate with Apache License 2.0 | 6 votes |
@Test public void testGetAllConcreteSettings() { Setting.AffixSetting<List<String>> listAffixSetting = Setting.affixKeySetting("foo.", "bar", (key) -> Setting.listSetting(key, Collections.emptyList(), Function.identity(), Property.NodeScope)); Settings settings = Settings.builder() .putList("foo.1.bar", "1", "2") .putList("foo.2.bar", "3", "4", "5") .putList("foo.bar", "6") .putList("some.other", "6") .putList("foo.3.bar", "6") .build(); Stream<Setting<List<String>>> allConcreteSettings = listAffixSetting.getAllConcreteSettings(settings); Map<String, List<String>> collect = allConcreteSettings.collect(Collectors.toMap(Setting::getKey, (s) -> s.get(settings))); assertEquals(3, collect.size()); assertEquals(Arrays.asList("1", "2"), collect.get("foo.1.bar")); assertEquals(Arrays.asList("3", "4", "5"), collect.get("foo.2.bar")); assertEquals(Arrays.asList("6"), collect.get("foo.3.bar")); }
Example #3
Source File: SettingTests.java From crate with Apache License 2.0 | 6 votes |
@Test public void testAffixAsMap() { Setting.AffixSetting<String> setting = Setting.prefixKeySetting("foo.bar.", key -> Setting.simpleString(key, Property.NodeScope)); Settings build = Settings.builder().put("foo.bar.baz", 2).put("foo.bar.foobar", 3).build(); Map<String, String> asMap = setting.getAsMap(build); assertEquals(2, asMap.size()); assertEquals("2", asMap.get("baz")); assertEquals("3", asMap.get("foobar")); setting = Setting.prefixKeySetting("foo.bar.", key -> Setting.simpleString(key, Property.NodeScope)); build = Settings.builder().put("foo.bar.baz", 2).put("foo.bar.foobar", 3).put("foo.bar.baz.deep", 45).build(); asMap = setting.getAsMap(build); assertEquals(3, asMap.size()); assertEquals("2", asMap.get("baz")); assertEquals("3", asMap.get("foobar")); assertEquals("45", asMap.get("baz.deep")); }
Example #4
Source File: SettingTests.java From crate with Apache License 2.0 | 6 votes |
@Test public void testAffixSettingNamespaces() { Setting.AffixSetting<Boolean> setting = Setting.affixKeySetting("foo.", "enable", (key) -> Setting.boolSetting(key, false, Property.NodeScope)); Settings build = Settings.builder() .put("foo.bar.enable", "true") .put("foo.baz.enable", "true") .put("foo.boom.enable", "true") .put("something.else", "true") .build(); Set<String> namespaces = setting.getNamespaces(build); assertEquals(3, namespaces.size()); assertTrue(namespaces.contains("bar")); assertTrue(namespaces.contains("baz")); assertTrue(namespaces.contains("boom")); }
Example #5
Source File: ScopedSettingsTests.java From crate with Apache License 2.0 | 6 votes |
@Test public void testOverlappingComplexMatchSettings() { Set<Setting<?>> settings = new LinkedHashSet<>(2); final boolean groupFirst = randomBoolean(); final Setting<?> groupSetting = Setting.groupSetting("foo.", Property.NodeScope); final Setting<?> listSetting = Setting.listSetting("foo.bar", Collections.emptyList(), Function.identity(), Property.NodeScope); settings.add(groupFirst ? groupSetting : listSetting); settings.add(groupFirst ? listSetting : groupSetting); try { new ClusterSettings(Settings.EMPTY, settings); fail("an exception should have been thrown because settings overlap"); } catch (IllegalArgumentException e) { if (groupFirst) { assertEquals("complex setting key: [foo.bar] overlaps existing setting key: [foo.]", e.getMessage()); } else { assertEquals("complex setting key: [foo.] overlaps existing setting key: [foo.bar]", e.getMessage()); } } }
Example #6
Source File: ScopedSettingsTests.java From crate with Apache License 2.0 | 6 votes |
@Test public void testIsFinal() { ClusterSettings settings = new ClusterSettings(Settings.EMPTY, new HashSet<>(Arrays.asList(Setting.intSetting("foo.int", 1, Property.Final, Property.NodeScope), Setting.groupSetting("foo.group.", Property.Final, Property.NodeScope), Setting.groupSetting("foo.list.", Property.Final, Property.NodeScope), Setting.intSetting("foo.int.baz", 1, Property.NodeScope)))); assertFalse(settings.isFinalSetting("foo.int.baz")); assertTrue(settings.isFinalSetting("foo.int")); assertFalse(settings.isFinalSetting("foo.list")); assertTrue(settings.isFinalSetting("foo.list.0.key")); assertTrue(settings.isFinalSetting("foo.list.key")); assertFalse(settings.isFinalSetting("foo.group")); assertTrue(settings.isFinalSetting("foo.group.key")); }
Example #7
Source File: SettingTests.java From crate with Apache License 2.0 | 6 votes |
@Test public void testComplexType() { AtomicReference<ComplexType> ref = new AtomicReference<>(null); Setting<ComplexType> setting = new Setting<>("foo.bar", (s) -> "", (s) -> new ComplexType(s), Property.Dynamic, Property.NodeScope); assertFalse(setting.isGroupSetting()); ref.set(setting.get(Settings.EMPTY)); ComplexType type = ref.get(); ClusterSettings.SettingUpdater<ComplexType> settingUpdater = setting.newUpdater(ref::set, logger); assertFalse(settingUpdater.apply(Settings.EMPTY, Settings.EMPTY)); assertSame("no update - type has not changed", type, ref.get()); // change from default assertTrue(settingUpdater.apply(Settings.builder().put("foo.bar", "2").build(), Settings.EMPTY)); assertNotSame("update - type has changed", type, ref.get()); assertEquals("2", ref.get().foo); // change back to default... assertTrue(settingUpdater.apply(Settings.EMPTY, Settings.builder().put("foo.bar", "2").build())); assertNotSame("update - type has changed", type, ref.get()); assertEquals("", ref.get().foo); }
Example #8
Source File: SettingTests.java From crate with Apache License 2.0 | 6 votes |
@Test public void testDynamicKeySetting() { Setting<Boolean> setting = Setting.prefixKeySetting("foo.", (key) -> Setting.boolSetting(key, false, Property.NodeScope)); assertTrue(setting.hasComplexMatcher()); assertTrue(setting.match("foo.bar")); assertFalse(setting.match("foo")); Setting<Boolean> concreteSetting = setting.getConcreteSetting("foo.bar"); assertTrue(concreteSetting.get(Settings.builder().put("foo.bar", "true").build())); assertFalse(concreteSetting.get(Settings.builder().put("foo.baz", "true").build())); try { setting.getConcreteSetting("foo"); fail(); } catch (IllegalArgumentException ex) { assertEquals("key [foo] must match [foo.] but didn't.", ex.getMessage()); } }
Example #9
Source File: SettingTests.java From crate with Apache License 2.0 | 6 votes |
@Test public void testExistsWithFallback() { final int count = randomIntBetween(1, 16); Setting<String> current = Setting.simpleString("fallback0", Property.NodeScope); for (int i = 1; i < count; i++) { final Setting<String> next = new Setting<>(new Setting.SimpleKey("fallback" + i), current, Function.identity(), Property.NodeScope); current = next; } final Setting<String> fooSetting = new Setting<>(new Setting.SimpleKey("foo"), current, Function.identity(), Property.NodeScope); assertFalse(fooSetting.exists(Settings.EMPTY)); if (randomBoolean()) { assertTrue(fooSetting.exists(Settings.builder().put("foo", "bar").build())); } else { final String setting = "fallback" + randomIntBetween(0, count - 1); assertFalse(fooSetting.exists(Settings.builder().put(setting, "bar").build())); assertTrue(fooSetting.existsOrFallbackExists(Settings.builder().put(setting, "bar").build())); } }
Example #10
Source File: ScopedSettingsTests.java From crate with Apache License 2.0 | 6 votes |
@Test public void testDependentSettings() { Setting.AffixSetting<String> stringSetting = Setting.affixKeySetting("foo.", "name", (k) -> Setting.simpleString(k, Property.Dynamic, Property.NodeScope)); Setting.AffixSetting<Integer> intSetting = Setting.affixKeySetting("foo.", "bar", (k) -> Setting.intSetting(k, 1, Property.Dynamic, Property.NodeScope), stringSetting); AbstractScopedSettings service = new ClusterSettings(Settings.EMPTY,new HashSet<>(Arrays.asList(intSetting, stringSetting))); IllegalArgumentException iae = expectThrows(IllegalArgumentException.class, () -> service.validate(Settings.builder().put("foo.test.bar", 7).build(), true)); assertEquals("missing required setting [foo.test.name] for setting [foo.test.bar]", iae.getMessage()); service.validate(Settings.builder() .put("foo.test.name", "test") .put("foo.test.bar", 7) .build(), true); service.validate(Settings.builder().put("foo.test.bar", 7).build(), false); }
Example #11
Source File: SettingTests.java From crate with Apache License 2.0 | 6 votes |
@Test public void testListSettingsDeprecated() { final Setting<List<String>> deprecatedListSetting = Setting.listSetting( "foo.deprecated", Collections.singletonList("foo.deprecated"), Function.identity(), Property.Deprecated, Property.NodeScope); final Setting<List<String>> nonDeprecatedListSetting = Setting.listSetting( "foo.non_deprecated", Collections.singletonList("foo.non_deprecated"), Function.identity(), Property.NodeScope); final Settings settings = Settings.builder() .put("foo.deprecated", "foo.deprecated1,foo.deprecated2") .put("foo.deprecated", "foo.non_deprecated1,foo.non_deprecated2") .build(); deprecatedListSetting.get(settings); nonDeprecatedListSetting.get(settings); assertSettingDeprecationsAndWarnings(new Setting[]{deprecatedListSetting}); }
Example #12
Source File: SettingTests.java From crate with Apache License 2.0 | 5 votes |
@Test public void testRejectNonIndexScopedNotCopyableOnResizeSetting() { final IllegalArgumentException e = expectThrows( IllegalArgumentException.class, () -> Setting.simpleString("foo.bar", Property.NotCopyableOnResize)); assertThat(e, hasToString(containsString("non-index-scoped setting [foo.bar] can not have property [NotCopyableOnResize]"))); }
Example #13
Source File: SettingTests.java From crate with Apache License 2.0 | 5 votes |
@Test public void testSettingsGroupUpdater() { Setting<Integer> intSetting = Setting.intSetting("prefix.foo", 1, Property.NodeScope, Property.Dynamic); Setting<Integer> intSetting2 = Setting.intSetting("prefix.same", 1, Property.NodeScope, Property.Dynamic); AbstractScopedSettings.SettingUpdater<Settings> updater = Setting.groupedSettingsUpdater(s -> {}, Arrays.asList(intSetting, intSetting2)); Settings current = Settings.builder().put("prefix.foo", 123).put("prefix.same", 5555).build(); Settings previous = Settings.builder().put("prefix.foo", 321).put("prefix.same", 5555).build(); assertTrue(updater.apply(current, previous)); }
Example #14
Source File: SettingTests.java From crate with Apache License 2.0 | 5 votes |
@Test public void testRejectNonIndexScopedPrivateIndexSetting() { final IllegalArgumentException e = expectThrows( IllegalArgumentException.class, () -> Setting.simpleString("foo.bar", Property.PrivateIndex)); assertThat(e, hasToString(containsString("non-index-scoped setting [foo.bar] can not have property [PrivateIndex]"))); }
Example #15
Source File: SettingTests.java From crate with Apache License 2.0 | 5 votes |
@Test public void testRejectNonIndexScopedInternalIndexSetting() { final IllegalArgumentException e = expectThrows( IllegalArgumentException.class, () -> Setting.simpleString("foo.bar", Property.InternalIndex)); assertThat(e, hasToString(containsString("non-index-scoped setting [foo.bar] can not have property [InternalIndex]"))); }
Example #16
Source File: SettingTests.java From crate with Apache License 2.0 | 5 votes |
@Test public void testGet() { Setting<Boolean> booleanSetting = Setting.boolSetting("foo.bar", false, Property.Dynamic, Property.NodeScope); assertFalse(booleanSetting.get(Settings.EMPTY)); assertFalse(booleanSetting.get(Settings.builder().put("foo.bar", false).build())); assertTrue(booleanSetting.get(Settings.builder().put("foo.bar", true).build())); }
Example #17
Source File: SettingTests.java From crate with Apache License 2.0 | 5 votes |
/** * We can't have Null properties */ @Test public void testRejectNullProperties() { IllegalArgumentException ex = expectThrows(IllegalArgumentException.class, () -> Setting.simpleString("foo.bar", (Property[]) null)); assertThat(ex.getMessage(), containsString("properties cannot be null for setting")); }
Example #18
Source File: OpenShiftElasticSearchPlugin.java From openshift-elasticsearch-plugin with Apache License 2.0 | 5 votes |
@Override public List<Setting<?>> getSettings() { List<Setting<?>> settings = sgPlugin.getSettings(); settings.add(Setting.intSetting(OPENSHIFT_CONTEXT_CACHE_MAXSIZE, DEFAULT_OPENSHIFT_CONTEXT_CACHE_MAXSIZE, Property.NodeScope)); settings.add(Setting.longSetting(OPENSHIFT_CONTEXT_CACHE_EXPIRE_SECONDS, DEFAULT_OPENSHIFT_CONTEXT_CACHE_EXPIRE_SECONDS, 0, Property.NodeScope)); settings.add(Setting.simpleString(OPENSHIFT_ES_KIBANA_SEED_MAPPINGS_APP, Property.NodeScope)); settings.add(Setting.simpleString(OPENSHIFT_ES_KIBANA_SEED_MAPPINGS_OPERATIONS, Property.NodeScope)); settings.add(Setting.simpleString(OPENSHIFT_ES_KIBANA_SEED_MAPPINGS_EMPTY, Property.NodeScope)); settings.add(Setting.boolSetting(OPENSHIFT_CONFIG_COMMON_DATA_MODEL, true, Property.NodeScope)); settings.add(Setting.simpleString(OPENSHIFT_CONFIG_PROJECT_INDEX_PREFIX, Property.NodeScope)); settings.add(Setting.simpleString(OPENSHIFT_CONFIG_TIME_FIELD_NAME, Property.NodeScope)); settings.add(Setting.simpleString(SG_CLIENT_KS_PATH, Property.NodeScope)); settings.add(Setting.simpleString(SG_CLIENT_TS_PATH, Property.NodeScope)); settings.add(Setting.boolSetting(OPENSHIFT_CONFIG_OPS_ALLOW_CLUSTER_READER, false, Property.NodeScope)); settings.add(Setting.simpleString(OPENSHIFT_KIBANA_INDEX_MODE, Property.NodeScope)); settings.add(Setting.simpleString(OPENSHIFT_ACL_ROLE_STRATEGY, Property.NodeScope)); settings.add(Setting.listSetting(OPENSHIFT_KIBANA_OPS_INDEX_PATTERNS, Arrays.asList(DEFAULT_KIBANA_OPS_INDEX_PATTERNS), Function.identity(), Property.NodeScope, Property.Dynamic)); settings.add(Setting.simpleString(OPENSHIFT_ACL_EXPIRE_IN_MILLIS, Property.NodeScope)); settings.add(Setting.simpleString(KIBANA_CONFIG_INDEX_NAME, Property.NodeScope)); settings.add(Setting.simpleString(KIBANA_CONFIG_VERSION, Property.NodeScope)); settings.add(Setting.simpleString(KIBANA_VERSION_HEADER, Property.NodeScope)); settings.add(Setting.simpleString(OPENSHIFT_ES_USER_PROFILE_PREFIX, Property.NodeScope)); settings.add(Setting.listSetting(OPENSHIFT_CONFIG_OPS_PROJECTS,Arrays.asList(DEFAULT_OPENSHIFT_OPS_PROJECTS), Function.identity(), Property.NodeScope, Property.Dynamic)); return settings; }
Example #19
Source File: SettingTests.java From crate with Apache License 2.0 | 5 votes |
@Test public void testSettingsGroupUpdaterRemoval() { Setting<Integer> intSetting = Setting.intSetting("prefix.foo", 1, Property.NodeScope, Property.Dynamic); Setting<Integer> intSetting2 = Setting.intSetting("prefix.same", 1, Property.NodeScope, Property.Dynamic); AbstractScopedSettings.SettingUpdater<Settings> updater = Setting.groupedSettingsUpdater(s -> {}, Arrays.asList(intSetting, intSetting2)); Settings current = Settings.builder().put("prefix.same", 5555).build(); Settings previous = Settings.builder().put("prefix.foo", 321).put("prefix.same", 5555).build(); assertTrue(updater.apply(current, previous)); }
Example #20
Source File: SettingTests.java From crate with Apache License 2.0 | 5 votes |
@Test public void testAffixNamespacesWithGroupSetting() { final Setting.AffixSetting<Settings> affixSetting = Setting.affixKeySetting("prefix.","suffix", (key) -> Setting.groupSetting(key + ".", Setting.Property.Dynamic, Setting.Property.NodeScope)); assertThat(affixSetting.getNamespaces(Settings.builder().put("prefix.infix.suffix", "anything").build()), hasSize(1)); assertThat(affixSetting.getNamespaces(Settings.builder().put("prefix.infix.suffix.anything", "anything").build()), hasSize(1)); }
Example #21
Source File: MemorySizeSettingsTests.java From crate with Apache License 2.0 | 5 votes |
private void assertMemorySizeSetting(Setting<ByteSizeValue> setting, String settingKey, ByteSizeValue defaultValue) { assertThat(setting, notNullValue()); assertThat(setting.getKey(), equalTo(settingKey)); assertThat(setting.getProperties(), hasItem(Property.NodeScope)); assertThat(setting.getDefault(Settings.EMPTY), equalTo(defaultValue)); Settings settingWithPercentage = Settings.builder().put(settingKey, "25%").build(); assertThat(setting.get(settingWithPercentage), equalTo(new ByteSizeValue((long) (JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.25)))); Settings settingWithBytesValue = Settings.builder().put(settingKey, "1024b").build(); assertThat(setting.get(settingWithBytesValue), equalTo(new ByteSizeValue(1024))); }
Example #22
Source File: ScopedSettingsTests.java From crate with Apache License 2.0 | 5 votes |
@Test public void testDependentSettingsWithFallback() { Setting.AffixSetting<String> nameFallbackSetting = Setting.affixKeySetting("fallback.", "name", k -> Setting.simpleString(k, Property.Dynamic, Property.NodeScope)); Setting.AffixSetting<String> nameSetting = Setting.affixKeySetting( "foo.", "name", k -> Setting.simpleString( k, "_na_".equals(k) ? nameFallbackSetting.getConcreteSettingForNamespace(k) : nameFallbackSetting.getConcreteSetting(k.replaceAll("^foo", "fallback")), Property.Dynamic, Property.NodeScope)); Setting.AffixSetting<Integer> barSetting = Setting.affixKeySetting("foo.", "bar", k -> Setting.intSetting(k, 1, Property.Dynamic, Property.NodeScope), nameSetting); final AbstractScopedSettings service = new ClusterSettings(Settings.EMPTY,new HashSet<>(Arrays.asList(nameFallbackSetting, nameSetting, barSetting))); final IllegalArgumentException e = expectThrows( IllegalArgumentException.class, () -> service.validate(Settings.builder().put("foo.test.bar", 7).build(), true)); assertThat(e, hasToString(containsString("missing required setting [foo.test.name] for setting [foo.test.bar]"))); service.validate(Settings.builder().put("foo.test.name", "test").put("foo.test.bar", 7).build(), true); service.validate(Settings.builder().put("fallback.test.name", "test").put("foo.test.bar", 7).build(), true); }
Example #23
Source File: ScopedSettingsTests.java From crate with Apache License 2.0 | 5 votes |
@Test public void testAffixMapConsumerNotCalledWithNull() { Setting.AffixSetting<Integer> prefixSetting = Setting.prefixKeySetting("eggplant.", (k) -> Setting.intSetting(k, 1, Property.Dynamic, Property.NodeScope)); Setting.AffixSetting<Integer> otherSetting = Setting.prefixKeySetting("other.", (k) -> Setting.intSetting(k, 1, Property.Dynamic, Property.NodeScope)); AbstractScopedSettings service = new ClusterSettings(Settings.EMPTY,new HashSet<>(Arrays.asList(prefixSetting, otherSetting))); Map<String, Integer> affixResults = new HashMap<>(); Consumer<Map<String,Integer>> consumer = (map) -> { logger.info("--> consuming settings {}", map); affixResults.clear(); affixResults.putAll(map); }; service.addAffixMapUpdateConsumer(prefixSetting, consumer, (s, k) -> {}); assertEquals(0, affixResults.size()); service.applySettings(Settings.builder() .put("eggplant._name", 2) .build()); assertThat(affixResults.size(), equalTo(1)); assertThat(affixResults.get("_name"), equalTo(2)); service.applySettings(Settings.builder() .put("eggplant._name", 2) .put("other.thing", 3) .build()); assertThat(affixResults.get("_name"), equalTo(2)); }
Example #24
Source File: ScopedSettingsTests.java From crate with Apache License 2.0 | 5 votes |
@Test public void testIsDynamic(){ ClusterSettings settings = new ClusterSettings(Settings.EMPTY, new HashSet<>(Arrays.asList(Setting.intSetting("foo.bar", 1, Property.Dynamic, Property.NodeScope), Setting.intSetting("foo.bar.baz", 1, Property.NodeScope)))); assertFalse(settings.isDynamicSetting("foo.bar.baz")); assertTrue(settings.isDynamicSetting("foo.bar")); assertNotNull(settings.get("foo.bar.baz")); settings = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); assertTrue(settings.isDynamicSetting("transport.tracer.include." + randomIntBetween(1, 100))); assertFalse(settings.isDynamicSetting("transport.tracer.include.BOOM")); assertTrue(settings.isDynamicSetting("cluster.routing.allocation.require.value")); }
Example #25
Source File: ScopedSettingsTests.java From crate with Apache License 2.0 | 5 votes |
@Test public void testFinalSettingUpdateFail() { Setting<Integer> finalSetting = Setting.intSetting("some.final.setting", 1, Property.Final, Property.NodeScope); Setting<Settings> finalGroupSetting = Setting.groupSetting("some.final.group.", Property.Final, Property.NodeScope); Settings currentSettings = Settings.builder() .put("some.final.setting", 9) .put("some.final.group.foo", 7) .build(); ClusterSettings service = new ClusterSettings(currentSettings , new HashSet<>(Arrays.asList(finalSetting, finalGroupSetting))); IllegalArgumentException exc = expectThrows(IllegalArgumentException.class, () -> service.updateDynamicSettings(Settings.builder().put("some.final.setting", 8).build(), Settings.builder().put(currentSettings), Settings.builder(), "node")); assertThat(exc.getMessage(), containsString("final node setting [some.final.setting]")); exc = expectThrows(IllegalArgumentException.class, () -> service.updateDynamicSettings(Settings.builder().putNull("some.final.setting").build(), Settings.builder().put(currentSettings), Settings.builder(), "node")); assertThat(exc.getMessage(), containsString("final node setting [some.final.setting]")); exc = expectThrows(IllegalArgumentException.class, () -> service.updateSettings(Settings.builder().put("some.final.group.new", 8).build(), Settings.builder().put(currentSettings), Settings.builder(), "node")); assertThat(exc.getMessage(), containsString("final node setting [some.final.group.new]")); exc = expectThrows(IllegalArgumentException.class, () -> service.updateSettings(Settings.builder().put("some.final.group.foo", 5).build(), Settings.builder().put(currentSettings), Settings.builder(), "node")); assertThat(exc.getMessage(), containsString("final node setting [some.final.group.foo]")); }
Example #26
Source File: ScopedSettingsTests.java From crate with Apache License 2.0 | 5 votes |
@Test public void testInternalIndexSettingsFailsValidation() { final Setting<String> indexInternalSetting = Setting.simpleString("index.internal", Property.InternalIndex, Property.IndexScope); final IndexScopedSettings indexScopedSettings = new IndexScopedSettings(Settings.EMPTY, Collections.singleton(indexInternalSetting)); final IllegalArgumentException e = expectThrows( IllegalArgumentException.class, () -> { final Settings settings = Settings.builder().put("index.internal", "internal").build(); indexScopedSettings.validate(settings, false, /* validateInternalOrPrivateIndex */ true); }); final String message = "can not update internal setting [index.internal]; this setting is managed via a dedicated API"; assertThat(e, hasToString(containsString(message))); }
Example #27
Source File: ScopedSettingsTests.java From crate with Apache License 2.0 | 5 votes |
@Test public void testPrivateIndexSettingsFailsValidation() { final Setting<String> indexInternalSetting = Setting.simpleString("index.private", Property.PrivateIndex, Property.IndexScope); final IndexScopedSettings indexScopedSettings = new IndexScopedSettings(Settings.EMPTY, Collections.singleton(indexInternalSetting)); final IllegalArgumentException e = expectThrows( IllegalArgumentException.class, () -> { final Settings settings = Settings.builder().put("index.private", "private").build(); indexScopedSettings.validate(settings, false, /* validateInternalOrPrivateIndex */ true); }); final String message = "can not update private setting [index.private]; this setting is managed by CrateDB"; assertThat(e, hasToString(containsString(message))); }
Example #28
Source File: ScopedSettingsTests.java From crate with Apache License 2.0 | 5 votes |
@Test public void testInternalIndexSettingsSkipValidation() { final Setting<String> internalIndexSetting = Setting.simpleString("index.internal", Property.InternalIndex, Property.IndexScope); final IndexScopedSettings indexScopedSettings = new IndexScopedSettings(Settings.EMPTY, Collections.singleton(internalIndexSetting)); // nothing should happen, validation should not throw an exception final Settings settings = Settings.builder().put("index.internal", "internal").build(); indexScopedSettings.validate(settings, false, /* validateInternalOrPrivateIndex */ false); }
Example #29
Source File: ScopedSettingsTests.java From crate with Apache License 2.0 | 5 votes |
@Test public void testPrivateIndexSettingsSkipValidation() { final Setting<String> internalIndexSetting = Setting.simpleString("index.private", Property.PrivateIndex, Property.IndexScope); final IndexScopedSettings indexScopedSettings = new IndexScopedSettings(Settings.EMPTY, Collections.singleton(internalIndexSetting)); // nothing should happen, validation should not throw an exception final Settings settings = Settings.builder().put("index.private", "private").build(); indexScopedSettings.validate(settings, false, /* validateInternalOrPrivateIndex */ false); }
Example #30
Source File: ScopedSettingsTests.java From crate with Apache License 2.0 | 5 votes |
@Test public void testUpgradeSettingsNoChangesPreservesInstance() { final Setting<String> oldSetting = Setting.simpleString("foo.old", Property.NodeScope); final Setting<String> newSetting = Setting.simpleString("foo.new", Property.NodeScope); final Setting<String> remainingSetting = Setting.simpleString("foo.remaining", Property.NodeScope); final AbstractScopedSettings service = new ClusterSettings( Settings.EMPTY, List.of(), new HashSet<>(Arrays.asList(oldSetting, newSetting, remainingSetting)), Collections.singleton(new SettingUpgrader<String>() { @Override public Setting<String> getSetting() { return oldSetting; } @Override public String getKey(final String key) { return "foo.new"; } })); final Settings settings = Settings.builder().put("foo.remaining", randomAlphaOfLength(8)).build(); final Settings upgradedSettings = service.upgradeSettings(settings); assertThat(upgradedSettings, sameInstance(settings)); }