Include complex settings in settings requests

Today when getting setting via an API like the cluster settings API,
complex settings are excluded (e.g.,
discovery.zen.ping.unicast.hosts). This commit adds these settings to
the output of such APIs.

Relates #20622
This commit is contained in:
Jason Tedor 2016-09-27 20:25:03 -04:00 committed by GitHub
parent 3c8ff45917
commit 6013234560
2 changed files with 21 additions and 8 deletions

View File

@ -375,6 +375,11 @@ public abstract class AbstractScopedSettings extends AbstractComponent {
builder.put(setting.getKey(), setting.getRaw(defaultSettings));
}
}
for (Setting<?> setting : complexMatchers.values()) {
if (setting.exists(source) == false) {
builder.put(setting.getKey(), setting.getRaw(defaultSettings));
}
}
return builder.build();
}

View File

@ -41,6 +41,8 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import static org.hamcrest.CoreMatchers.equalTo;
public class ScopedSettingsTests extends ESTestCase {
public void testAddConsumer() {
@ -156,16 +158,22 @@ public class ScopedSettingsTests extends ESTestCase {
}
public void testDiff() throws IOException {
Setting<Integer> foobarbaz = Setting.intSetting("foo.bar.baz", 1, Property.NodeScope);
Setting<Integer> foobar = Setting.intSetting("foo.bar", 1, Property.Dynamic, Property.NodeScope);
ClusterSettings settings = new ClusterSettings(Settings.EMPTY, new HashSet<>(Arrays.asList(foobar, foobarbaz)));
Setting<Integer> fooBarBaz = Setting.intSetting("foo.bar.baz", 1, Property.NodeScope);
Setting<Integer> fooBar = Setting.intSetting("foo.bar", 1, Property.Dynamic, Property.NodeScope);
Setting<List<String>> foorBarQuux =
Setting.listSetting("foo.bar.quux", Arrays.asList("a", "b", "c"), Function.identity(), Property.NodeScope);
ClusterSettings settings = new ClusterSettings(Settings.EMPTY, new HashSet<>(Arrays.asList(fooBar, fooBarBaz, foorBarQuux)));
Settings diff = settings.diff(Settings.builder().put("foo.bar", 5).build(), Settings.EMPTY);
assertEquals(diff.getAsMap().size(), 1);
assertEquals(diff.getAsInt("foo.bar.baz", null), Integer.valueOf(1));
assertThat(diff.getAsMap().size(), equalTo(2));
assertThat(diff.getAsInt("foo.bar.baz", null), equalTo(1));
assertThat(diff.get("foo.bar.quux", null), equalTo("[\"a\",\"b\",\"c\"]"));
diff = settings.diff(Settings.builder().put("foo.bar", 5).build(), Settings.builder().put("foo.bar.baz", 17).build());
assertEquals(diff.getAsMap().size(), 1);
assertEquals(diff.getAsInt("foo.bar.baz", null), Integer.valueOf(17));
diff = settings.diff(
Settings.builder().put("foo.bar", 5).build(),
Settings.builder().put("foo.bar.baz", 17).put("foo.bar.quux", "d,e,f").build());
assertThat(diff.getAsMap().size(), equalTo(2));
assertThat(diff.getAsInt("foo.bar.baz", null), equalTo(17));
assertThat(diff.get("foo.bar.quux", null), equalTo("[\"d\",\"e\",\"f\"]"));
}
public void testUpdateTracer() {