Internal: Convert empty and size checks of settings to not use getAsMap() (#22890)
With the new secure settings, methods like getAsMap() no longer work correctly as a means of checking for empty settings, or the total size. This change converts the existing uses of that method to use methods directly on Settings. Note this does not update the implementations to account for SecureSettings, as that will require a followup which changes how secure settings work.
This commit is contained in:
parent
f6d38d480a
commit
29f63c78cc
|
@ -51,7 +51,7 @@ public class ClusterUpdateSettingsRequest extends AcknowledgedRequest<ClusterUpd
|
|||
@Override
|
||||
public ActionRequestValidationException validate() {
|
||||
ActionRequestValidationException validationException = null;
|
||||
if (transientSettings.getAsMap().isEmpty() && persistentSettings.getAsMap().isEmpty()) {
|
||||
if (transientSettings.isEmpty() && persistentSettings.isEmpty()) {
|
||||
validationException = addValidationError("no settings to update", validationException);
|
||||
}
|
||||
return validationException;
|
||||
|
|
|
@ -67,10 +67,10 @@ public class TransportClusterUpdateSettingsAction extends
|
|||
@Override
|
||||
protected ClusterBlockException checkBlock(ClusterUpdateSettingsRequest request, ClusterState state) {
|
||||
// allow for dedicated changes to the metadata blocks, so we don't block those to allow to "re-enable" it
|
||||
if ((request.transientSettings().getAsMap().isEmpty() &&
|
||||
request.persistentSettings().getAsMap().size() == 1 &&
|
||||
if ((request.transientSettings().isEmpty() &&
|
||||
request.persistentSettings().size() == 1 &&
|
||||
MetaData.SETTING_READ_ONLY_SETTING.exists(request.persistentSettings())) ||
|
||||
(request.persistentSettings().getAsMap().isEmpty() && request.transientSettings().getAsMap().size() == 1 &&
|
||||
(request.persistentSettings().isEmpty() && request.transientSettings().size() == 1 &&
|
||||
MetaData.SETTING_READ_ONLY_SETTING.exists(request.transientSettings()))) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class TransportUpdateSettingsAction extends TransportMasterNodeAction<Upd
|
|||
if (globalBlock != null) {
|
||||
return globalBlock;
|
||||
}
|
||||
if (request.settings().getAsMap().size() == 1 && IndexMetaData.INDEX_BLOCKS_METADATA_SETTING.exists(request.settings()) || IndexMetaData.INDEX_READ_ONLY_SETTING.exists(request.settings())) {
|
||||
if (request.settings().size() == 1 && IndexMetaData.INDEX_BLOCKS_METADATA_SETTING.exists(request.settings()) || IndexMetaData.INDEX_READ_ONLY_SETTING.exists(request.settings())) {
|
||||
return null;
|
||||
}
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, indexNameExpressionResolver.concreteIndexNames(state, request));
|
||||
|
|
|
@ -70,7 +70,7 @@ public class UpdateSettingsRequest extends AcknowledgedRequest<UpdateSettingsReq
|
|||
@Override
|
||||
public ActionRequestValidationException validate() {
|
||||
ActionRequestValidationException validationException = null;
|
||||
if (settings.getAsMap().isEmpty()) {
|
||||
if (settings.isEmpty()) {
|
||||
validationException = addValidationError("no settings to update", validationException);
|
||||
}
|
||||
return validationException;
|
||||
|
|
|
@ -973,7 +973,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, To
|
|||
builder.field("version", metaData.version());
|
||||
builder.field("cluster_uuid", metaData.clusterUUID);
|
||||
|
||||
if (!metaData.persistentSettings().getAsMap().isEmpty()) {
|
||||
if (!metaData.persistentSettings().isEmpty()) {
|
||||
builder.startObject("settings");
|
||||
for (Map.Entry<String, String> entry : metaData.persistentSettings().getAsMap().entrySet()) {
|
||||
builder.field(entry.getKey(), entry.getValue());
|
||||
|
@ -981,7 +981,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, To
|
|||
builder.endObject();
|
||||
}
|
||||
|
||||
if (context == XContentContext.API && !metaData.transientSettings().getAsMap().isEmpty()) {
|
||||
if (context == XContentContext.API && !metaData.transientSettings().isEmpty()) {
|
||||
builder.startObject("transient_settings");
|
||||
for (Map.Entry<String, String> entry : metaData.transientSettings().getAsMap().entrySet()) {
|
||||
builder.field(entry.getKey(), entry.getValue());
|
||||
|
|
|
@ -218,7 +218,7 @@ public class MetaDataUpdateSettingsService extends AbstractComponent implements
|
|||
closeIndices
|
||||
));
|
||||
}
|
||||
if (!skippedSettigns.getAsMap().isEmpty() && !openIndices.isEmpty()) {
|
||||
if (!skippedSettigns.isEmpty() && !openIndices.isEmpty()) {
|
||||
throw new IllegalArgumentException(String.format(Locale.ROOT,
|
||||
"Can't update non dynamic settings [%s] for open indices %s",
|
||||
skippedSettigns.getAsMap().keySet(),
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.elasticsearch.common.io.Streams;
|
|||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.logging.DeprecationLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.settings.loader.SettingsLoader;
|
||||
import org.elasticsearch.common.settings.loader.SettingsLoaderFactory;
|
||||
import org.elasticsearch.common.unit.ByteSizeUnit;
|
||||
|
@ -589,7 +588,7 @@ public final class Settings implements ToXContent {
|
|||
}
|
||||
|
||||
public static void writeSettingsToStream(Settings settings, StreamOutput out) throws IOException {
|
||||
out.writeVInt(settings.getAsMap().size());
|
||||
out.writeVInt(settings.size());
|
||||
for (Map.Entry<String, String> entry : settings.getAsMap().entrySet()) {
|
||||
out.writeString(entry.getKey());
|
||||
out.writeOptionalString(entry.getValue());
|
||||
|
@ -626,7 +625,12 @@ public final class Settings implements ToXContent {
|
|||
* @return <tt>true</tt> if this settings object contains no settings
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return this.settings.isEmpty();
|
||||
return this.settings.isEmpty(); // TODO: account for secure settings
|
||||
}
|
||||
|
||||
/** Returns the number of settings in this settings object. */
|
||||
public int size() {
|
||||
return this.settings.size(); // TODO: account for secure settings
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -75,7 +75,7 @@ public class RestGetSettingsAction extends BaseRestHandler {
|
|||
builder.startObject();
|
||||
for (ObjectObjectCursor<String, Settings> cursor : getSettingsResponse.getIndexToSettings()) {
|
||||
// no settings, jump over it to shorten the response data
|
||||
if (cursor.value.getAsMap().isEmpty()) {
|
||||
if (cursor.value.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
builder.startObject(cursor.key);
|
||||
|
|
|
@ -155,7 +155,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase {
|
|||
assertThat(indexMetaData.getNumberOfShards(), equalTo(1));
|
||||
assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2));
|
||||
assertThat(indexMetaData.getCreationDate(), equalTo(-1L));
|
||||
assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(3));
|
||||
assertThat(indexMetaData.getSettings().size(), equalTo(3));
|
||||
assertThat(indexMetaData.getMappings().size(), equalTo(0));
|
||||
|
||||
indexMetaData = parsedMetaData.index("test2");
|
||||
|
@ -164,7 +164,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase {
|
|||
assertThat(indexMetaData.primaryTerm(0), equalTo(2L));
|
||||
assertThat(indexMetaData.primaryTerm(1), equalTo(2L));
|
||||
assertThat(indexMetaData.getCreationDate(), equalTo(-1L));
|
||||
assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(5));
|
||||
assertThat(indexMetaData.getSettings().size(), equalTo(5));
|
||||
assertThat(indexMetaData.getSettings().get("setting1"), equalTo("value1"));
|
||||
assertThat(indexMetaData.getSettings().get("setting2"), equalTo("value2"));
|
||||
assertThat(indexMetaData.getMappings().size(), equalTo(0));
|
||||
|
@ -173,7 +173,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase {
|
|||
assertThat(indexMetaData.getNumberOfShards(), equalTo(1));
|
||||
assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2));
|
||||
assertThat(indexMetaData.getCreationDate(), equalTo(-1L));
|
||||
assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(3));
|
||||
assertThat(indexMetaData.getSettings().size(), equalTo(3));
|
||||
assertThat(indexMetaData.getMappings().size(), equalTo(1));
|
||||
assertThat(indexMetaData.getMappings().get("mapping1").source().string(), equalTo(MAPPING_SOURCE1));
|
||||
|
||||
|
@ -181,14 +181,14 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase {
|
|||
assertThat(indexMetaData.getCreationDate(), equalTo(2L));
|
||||
assertThat(indexMetaData.getNumberOfShards(), equalTo(1));
|
||||
assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2));
|
||||
assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(4));
|
||||
assertThat(indexMetaData.getSettings().size(), equalTo(4));
|
||||
assertThat(indexMetaData.getMappings().size(), equalTo(0));
|
||||
|
||||
indexMetaData = parsedMetaData.index("test5");
|
||||
assertThat(indexMetaData.getNumberOfShards(), equalTo(1));
|
||||
assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2));
|
||||
assertThat(indexMetaData.getCreationDate(), equalTo(-1L));
|
||||
assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(5));
|
||||
assertThat(indexMetaData.getSettings().size(), equalTo(5));
|
||||
assertThat(indexMetaData.getSettings().get("setting1"), equalTo("value1"));
|
||||
assertThat(indexMetaData.getSettings().get("setting2"), equalTo("value2"));
|
||||
assertThat(indexMetaData.getMappings().size(), equalTo(2));
|
||||
|
@ -199,7 +199,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase {
|
|||
assertThat(indexMetaData.getNumberOfShards(), equalTo(1));
|
||||
assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2));
|
||||
assertThat(indexMetaData.getCreationDate(), equalTo(2L));
|
||||
assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(6));
|
||||
assertThat(indexMetaData.getSettings().size(), equalTo(6));
|
||||
assertThat(indexMetaData.getSettings().get("setting1"), equalTo("value1"));
|
||||
assertThat(indexMetaData.getSettings().get("setting2"), equalTo("value2"));
|
||||
assertThat(indexMetaData.getMappings().size(), equalTo(0));
|
||||
|
@ -208,7 +208,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase {
|
|||
assertThat(indexMetaData.getNumberOfShards(), equalTo(1));
|
||||
assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2));
|
||||
assertThat(indexMetaData.getCreationDate(), equalTo(2L));
|
||||
assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(4));
|
||||
assertThat(indexMetaData.getSettings().size(), equalTo(4));
|
||||
assertThat(indexMetaData.getMappings().size(), equalTo(2));
|
||||
assertThat(indexMetaData.getMappings().get("mapping1").source().string(), equalTo(MAPPING_SOURCE1));
|
||||
assertThat(indexMetaData.getMappings().get("mapping2").source().string(), equalTo(MAPPING_SOURCE2));
|
||||
|
@ -217,7 +217,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase {
|
|||
assertThat(indexMetaData.getNumberOfShards(), equalTo(1));
|
||||
assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2));
|
||||
assertThat(indexMetaData.getCreationDate(), equalTo(-1L));
|
||||
assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(5));
|
||||
assertThat(indexMetaData.getSettings().size(), equalTo(5));
|
||||
assertThat(indexMetaData.getSettings().get("setting1"), equalTo("value1"));
|
||||
assertThat(indexMetaData.getSettings().get("setting2"), equalTo("value2"));
|
||||
assertThat(indexMetaData.getMappings().size(), equalTo(2));
|
||||
|
@ -231,7 +231,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase {
|
|||
assertThat(indexMetaData.getNumberOfShards(), equalTo(1));
|
||||
assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2));
|
||||
assertThat(indexMetaData.getCreationDate(), equalTo(2L));
|
||||
assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(6));
|
||||
assertThat(indexMetaData.getSettings().size(), equalTo(6));
|
||||
assertThat(indexMetaData.getSettings().get("setting1"), equalTo("value1"));
|
||||
assertThat(indexMetaData.getSettings().get("setting2"), equalTo("value2"));
|
||||
assertThat(indexMetaData.getMappings().size(), equalTo(2));
|
||||
|
@ -245,7 +245,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase {
|
|||
assertThat(indexMetaData.getNumberOfShards(), equalTo(1));
|
||||
assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2));
|
||||
assertThat(indexMetaData.getCreationDate(), equalTo(-1L));
|
||||
assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(5));
|
||||
assertThat(indexMetaData.getSettings().size(), equalTo(5));
|
||||
assertThat(indexMetaData.getSettings().get("setting1"), equalTo("value1"));
|
||||
assertThat(indexMetaData.getSettings().get("setting2"), equalTo("value2"));
|
||||
assertThat(indexMetaData.getMappings().size(), equalTo(2));
|
||||
|
@ -259,7 +259,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase {
|
|||
assertThat(indexMetaData.getNumberOfShards(), equalTo(1));
|
||||
assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2));
|
||||
assertThat(indexMetaData.getCreationDate(), equalTo(-1L));
|
||||
assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(5));
|
||||
assertThat(indexMetaData.getSettings().size(), equalTo(5));
|
||||
assertThat(indexMetaData.getSettings().get("setting1"), equalTo("value1"));
|
||||
assertThat(indexMetaData.getSettings().get("setting2"), equalTo("value2"));
|
||||
assertThat(indexMetaData.getMappings().size(), equalTo(2));
|
||||
|
@ -277,7 +277,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase {
|
|||
assertThat(indexMetaData.getNumberOfShards(), equalTo(1));
|
||||
assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2));
|
||||
assertThat(indexMetaData.getCreationDate(), equalTo(2L));
|
||||
assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(6));
|
||||
assertThat(indexMetaData.getSettings().size(), equalTo(6));
|
||||
assertThat(indexMetaData.getSettings().get("setting1"), equalTo("value1"));
|
||||
assertThat(indexMetaData.getSettings().get("setting2"), equalTo("value2"));
|
||||
assertThat(indexMetaData.getMappings().size(), equalTo(2));
|
||||
|
|
|
@ -270,21 +270,21 @@ public class ScopedSettingsTests extends ESTestCase {
|
|||
ClusterSettings settings = new ClusterSettings(Settings.EMPTY, new HashSet<>(Arrays.asList(fooBar, fooBarBaz, foorBarQuux,
|
||||
someGroup, someAffix)));
|
||||
Settings diff = settings.diff(Settings.builder().put("foo.bar", 5).build(), Settings.EMPTY);
|
||||
assertEquals(4, diff.getAsMap().size()); // 4 since foo.bar.quux has 3 values essentially
|
||||
assertEquals(4, diff.size()); // 4 since foo.bar.quux has 3 values essentially
|
||||
assertThat(diff.getAsInt("foo.bar.baz", null), equalTo(1));
|
||||
assertArrayEquals(diff.getAsArray("foo.bar.quux", null), new String[] {"a", "b", "c"});
|
||||
|
||||
diff = settings.diff(
|
||||
Settings.builder().put("foo.bar", 5).build(),
|
||||
Settings.builder().put("foo.bar.baz", 17).putArray("foo.bar.quux", "d", "e", "f").build());
|
||||
assertEquals(4, diff.getAsMap().size()); // 4 since foo.bar.quux has 3 values essentially
|
||||
assertEquals(4, diff.size()); // 4 since foo.bar.quux has 3 values essentially
|
||||
assertThat(diff.getAsInt("foo.bar.baz", null), equalTo(17));
|
||||
assertArrayEquals(diff.getAsArray("foo.bar.quux", null), new String[] {"d", "e", "f"});
|
||||
|
||||
diff = settings.diff(
|
||||
Settings.builder().put("some.group.foo", 5).build(),
|
||||
Settings.builder().put("some.group.foobar", 17, "some.group.foo", 25).build());
|
||||
assertEquals(6, diff.getAsMap().size()); // 6 since foo.bar.quux has 3 values essentially
|
||||
assertEquals(6, diff.size()); // 6 since foo.bar.quux has 3 values essentially
|
||||
assertThat(diff.getAsInt("some.group.foobar", null), equalTo(17));
|
||||
assertNull(diff.get("some.group.foo"));
|
||||
assertArrayEquals(diff.getAsArray("foo.bar.quux", null), new String[] {"a", "b", "c"});
|
||||
|
@ -295,7 +295,7 @@ public class ScopedSettingsTests extends ESTestCase {
|
|||
Settings.builder().put("some.prefix.foo.somekey", 5).build(),
|
||||
Settings.builder().put("some.prefix.foobar.somekey", 17,
|
||||
"some.prefix.foo.somekey", 18).build());
|
||||
assertEquals(6, diff.getAsMap().size()); // 6 since foo.bar.quux has 3 values essentially
|
||||
assertEquals(6, diff.size()); // 6 since foo.bar.quux has 3 values essentially
|
||||
assertThat(diff.getAsInt("some.prefix.foobar.somekey", null), equalTo(17));
|
||||
assertNull(diff.get("some.prefix.foo.somekey"));
|
||||
assertArrayEquals(diff.getAsArray("foo.bar.quux", null), new String[] {"a", "b", "c"});
|
||||
|
@ -314,21 +314,21 @@ public class ScopedSettingsTests extends ESTestCase {
|
|||
ClusterSettings settings = new ClusterSettings(Settings.EMPTY, new HashSet<>(Arrays.asList(fooBar, fooBarBaz, foorBarQuux,
|
||||
someGroup, someAffix)));
|
||||
Settings diff = settings.diff(Settings.builder().put("foo.bar", 5).build(), Settings.EMPTY);
|
||||
assertEquals(1, diff.getAsMap().size());
|
||||
assertEquals(1, diff.size());
|
||||
assertThat(diff.getAsInt("foo.bar.baz", null), equalTo(1));
|
||||
assertNull(diff.getAsArray("foo.bar.quux", null)); // affix settings don't know their concrete keys
|
||||
|
||||
diff = settings.diff(
|
||||
Settings.builder().put("foo.bar", 5).build(),
|
||||
Settings.builder().put("foo.bar.baz", 17).putArray("foo.bar.quux", "d", "e", "f").build());
|
||||
assertEquals(4, diff.getAsMap().size());
|
||||
assertEquals(4, diff.size());
|
||||
assertThat(diff.getAsInt("foo.bar.baz", null), equalTo(17));
|
||||
assertArrayEquals(diff.getAsArray("foo.bar.quux", null), new String[] {"d", "e", "f"});
|
||||
|
||||
diff = settings.diff(
|
||||
Settings.builder().put("some.group.foo", 5).build(),
|
||||
Settings.builder().put("some.group.foobar", 17, "some.group.foo", 25).build());
|
||||
assertEquals(3, diff.getAsMap().size());
|
||||
assertEquals(3, diff.size());
|
||||
assertThat(diff.getAsInt("some.group.foobar", null), equalTo(17));
|
||||
assertNull(diff.get("some.group.foo"));
|
||||
assertNull(diff.getAsArray("foo.bar.quux", null)); // affix settings don't know their concrete keys
|
||||
|
@ -339,7 +339,7 @@ public class ScopedSettingsTests extends ESTestCase {
|
|||
Settings.builder().put("some.prefix.foo.somekey", 5).build(),
|
||||
Settings.builder().put("some.prefix.foobar.somekey", 17,
|
||||
"some.prefix.foo.somekey", 18).build());
|
||||
assertEquals(3, diff.getAsMap().size());
|
||||
assertEquals(3, diff.size());
|
||||
assertThat(diff.getAsInt("some.prefix.foobar.somekey", null), equalTo(17));
|
||||
assertNull(diff.get("some.prefix.foo.somekey"));
|
||||
assertNull(diff.getAsArray("foo.bar.quux", null)); // affix settings don't know their concrete keys
|
||||
|
@ -353,7 +353,7 @@ public class ScopedSettingsTests extends ESTestCase {
|
|||
.putArray("foo.bar.quux", "x", "y", "z")
|
||||
.putArray("foo.baz.quux", "d", "e", "f")
|
||||
.build());
|
||||
assertEquals(9, diff.getAsMap().size());
|
||||
assertEquals(9, diff.size());
|
||||
assertThat(diff.getAsInt("some.prefix.foobar.somekey", null), equalTo(17));
|
||||
assertNull(diff.get("some.prefix.foo.somekey"));
|
||||
assertArrayEquals(diff.getAsArray("foo.bar.quux", null), new String[] {"x", "y", "z"});
|
||||
|
|
|
@ -163,7 +163,7 @@ public class SettingsModuleTests extends ModuleTestCase {
|
|||
Setting.boolSetting("bar.foo", true, Property.NodeScope, Property.Filtered),
|
||||
Setting.boolSetting("bar.baz", true, Property.NodeScope)), Arrays.asList("foo.*"));
|
||||
assertInstanceBinding(module, Settings.class, (s) -> s == settings);
|
||||
assertInstanceBinding(module, SettingsFilter.class, (s) -> s.filter(settings).getAsMap().size() == 1);
|
||||
assertInstanceBinding(module, SettingsFilter.class, (s) -> s.filter(settings).size() == 1);
|
||||
assertInstanceBinding(module, SettingsFilter.class, (s) -> s.filter(settings).getAsMap().containsKey("bar.baz"));
|
||||
assertInstanceBinding(module, SettingsFilter.class, (s) -> s.filter(settings).getAsMap().get("bar.baz").equals("false"));
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ public class SettingsTests extends ESTestCase {
|
|||
|
||||
Settings fooSettings = settings.getAsSettings("foo");
|
||||
assertFalse(fooSettings.isEmpty());
|
||||
assertEquals(2, fooSettings.getAsMap().size());
|
||||
assertEquals(2, fooSettings.size());
|
||||
assertThat(fooSettings.get("bar"), equalTo("def"));
|
||||
assertThat(fooSettings.get("baz"), equalTo("ghi"));
|
||||
}
|
||||
|
@ -225,13 +225,13 @@ public class SettingsTests extends ESTestCase {
|
|||
|
||||
Settings firstLevelSettings = settings.getByPrefix("1.");
|
||||
assertFalse(firstLevelSettings.isEmpty());
|
||||
assertEquals(2, firstLevelSettings.getAsMap().size());
|
||||
assertEquals(2, firstLevelSettings.size());
|
||||
assertThat(firstLevelSettings.get("2.3.4"), equalTo("abc"));
|
||||
assertThat(firstLevelSettings.get("2.3"), equalTo("hello world"));
|
||||
|
||||
Settings secondLevelSetting = firstLevelSettings.getByPrefix("2.");
|
||||
assertFalse(secondLevelSetting.isEmpty());
|
||||
assertEquals(2, secondLevelSetting.getAsMap().size());
|
||||
assertEquals(2, secondLevelSetting.size());
|
||||
assertNull(secondLevelSetting.get("2.3.4"));
|
||||
assertNull(secondLevelSetting.get("1.2.3.4"));
|
||||
assertNull(secondLevelSetting.get("1.2.3"));
|
||||
|
@ -240,7 +240,7 @@ public class SettingsTests extends ESTestCase {
|
|||
|
||||
Settings thirdLevelSetting = secondLevelSetting.getByPrefix("3.");
|
||||
assertFalse(thirdLevelSetting.isEmpty());
|
||||
assertEquals(1, thirdLevelSetting.getAsMap().size());
|
||||
assertEquals(1, thirdLevelSetting.size());
|
||||
assertNull(thirdLevelSetting.get("2.3.4"));
|
||||
assertNull(thirdLevelSetting.get("3.4"));
|
||||
assertNull(thirdLevelSetting.get("1.2.3"));
|
||||
|
@ -380,7 +380,7 @@ public class SettingsTests extends ESTestCase {
|
|||
.normalizePrefix("foo.")
|
||||
.build();
|
||||
|
||||
assertThat(settings.getAsMap().size(), equalTo(1));
|
||||
assertThat(settings.size(), equalTo(1));
|
||||
assertThat(settings.get("bar"), nullValue());
|
||||
assertThat(settings.get("foo.bar"), equalTo("baz"));
|
||||
|
||||
|
@ -391,7 +391,7 @@ public class SettingsTests extends ESTestCase {
|
|||
.normalizePrefix("foo.")
|
||||
.build();
|
||||
|
||||
assertThat(settings.getAsMap().size(), equalTo(2));
|
||||
assertThat(settings.size(), equalTo(2));
|
||||
assertThat(settings.get("bar"), nullValue());
|
||||
assertThat(settings.get("foo.bar"), equalTo("baz"));
|
||||
assertThat(settings.get("foo.test"), equalTo("test"));
|
||||
|
@ -402,7 +402,7 @@ public class SettingsTests extends ESTestCase {
|
|||
.build();
|
||||
|
||||
|
||||
assertThat(settings.getAsMap().size(), equalTo(1));
|
||||
assertThat(settings.size(), equalTo(1));
|
||||
assertThat(settings.get("foo.test"), equalTo("test"));
|
||||
}
|
||||
|
||||
|
|
|
@ -1906,7 +1906,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|||
Settings initialSettings = initialSettingsBuilder.build();
|
||||
logger.info("--> using initial block settings {}", initialSettings.getAsMap());
|
||||
|
||||
if (!initialSettings.getAsMap().isEmpty()) {
|
||||
if (!initialSettings.isEmpty()) {
|
||||
logger.info("--> apply initial blocks to index");
|
||||
client().admin().indices().prepareUpdateSettings("test-idx").setSettings(initialSettingsBuilder).get();
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class TribeServiceTests extends ESTestCase {
|
|||
assertEquals("false", clientSettings.get("node.ingest"));
|
||||
assertEquals("false", clientSettings.get("node.local_storage"));
|
||||
assertEquals("3707202549613653169", clientSettings.get("node.id.seed")); // should be fixed by the parent id and tribe name
|
||||
assertEquals(9, clientSettings.getAsMap().size());
|
||||
assertEquals(9, clientSettings.size());
|
||||
}
|
||||
|
||||
public void testEnvironmentSettings() {
|
||||
|
|
|
@ -876,7 +876,7 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
|||
getExcludeSettings(index, n, builder);
|
||||
}
|
||||
Settings build = builder.build();
|
||||
if (!build.getAsMap().isEmpty()) {
|
||||
if (!build.isEmpty()) {
|
||||
logger.debug("allowNodes: updating [{}]'s setting to [{}]", index, build.toDelimitedString(';'));
|
||||
client().admin().indices().prepareUpdateSettings(index).setSettings(build).execute().actionGet();
|
||||
}
|
||||
|
|
|
@ -114,9 +114,9 @@ public abstract class ESSingleNodeTestCase extends ESTestCase {
|
|||
assertAcked(client().admin().indices().prepareDelete("*").get());
|
||||
MetaData metaData = client().admin().cluster().prepareState().get().getState().getMetaData();
|
||||
assertThat("test leaves persistent cluster metadata behind: " + metaData.persistentSettings().getAsMap(),
|
||||
metaData.persistentSettings().getAsMap().size(), equalTo(0));
|
||||
metaData.persistentSettings().size(), equalTo(0));
|
||||
assertThat("test leaves transient cluster metadata behind: " + metaData.transientSettings().getAsMap(),
|
||||
metaData.transientSettings().getAsMap().size(), equalTo(0));
|
||||
metaData.transientSettings().size(), equalTo(0));
|
||||
if (resetNodeAfterTest()) {
|
||||
assert NODE != null;
|
||||
stopNode();
|
||||
|
|
Loading…
Reference in New Issue