Merge pull request #15948 from mikemccand/always_require_units
Remove settings_require_units setting (so we always require units for bytes and time settings)
This commit is contained in:
commit
d5f8d8ea82
|
@ -76,19 +76,6 @@ public final class Settings implements ToXContent {
|
||||||
public static final Settings EMPTY = new Builder().build();
|
public static final Settings EMPTY = new Builder().build();
|
||||||
private static final Pattern ARRAY_PATTERN = Pattern.compile("(.*)\\.\\d+$");
|
private static final Pattern ARRAY_PATTERN = Pattern.compile("(.*)\\.\\d+$");
|
||||||
|
|
||||||
/** Name of the setting to use to disable required units for byte size, time settings. */
|
|
||||||
public static final String SETTINGS_REQUIRE_UNITS = "settings_require_units";
|
|
||||||
|
|
||||||
private static boolean settingsRequireUnits = true;
|
|
||||||
|
|
||||||
public static void setSettingsRequireUnits(boolean v) {
|
|
||||||
settingsRequireUnits = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean getSettingsRequireUnits() {
|
|
||||||
return settingsRequireUnits;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Map<String, String> forcedUnderscoreSettings;
|
private final Map<String, String> forcedUnderscoreSettings;
|
||||||
private SortedMap<String, String> settings;
|
private SortedMap<String, String> settings;
|
||||||
|
|
||||||
|
|
|
@ -213,12 +213,7 @@ public class ByteSizeValue implements Streamable {
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
} else {
|
} else {
|
||||||
// Missing units:
|
// Missing units:
|
||||||
if (Settings.getSettingsRequireUnits()) {
|
throw new ElasticsearchParseException("failed to parse setting [{}] with value [{}] as a size in bytes: unit is missing or unrecognized", settingName, sValue);
|
||||||
throw new ElasticsearchParseException("failed to parse setting [{}] with value [{}] as a size in bytes: unit is missing or unrecognized", settingName, sValue);
|
|
||||||
} else {
|
|
||||||
// Leniency default to bytes:
|
|
||||||
bytes = Long.parseLong(sValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new ElasticsearchParseException("failed to parse [{}]", e, sValue);
|
throw new ElasticsearchParseException("failed to parse [{}]", e, sValue);
|
||||||
|
|
|
@ -280,13 +280,8 @@ public class TimeValue implements Streamable {
|
||||||
// Allow this special value to be unit-less:
|
// Allow this special value to be unit-less:
|
||||||
millis = 0;
|
millis = 0;
|
||||||
} else {
|
} else {
|
||||||
if (Settings.getSettingsRequireUnits()) {
|
// Missing units:
|
||||||
// Missing units:
|
throw new ElasticsearchParseException("Failed to parse setting [{}] with value [{}] as a time value: unit is missing or unrecognized", settingName, sValue);
|
||||||
throw new ElasticsearchParseException("Failed to parse setting [{}] with value [{}] as a time value: unit is missing or unrecognized", settingName, sValue);
|
|
||||||
} else {
|
|
||||||
// Leniency default to msec for bwc:
|
|
||||||
millis = Long.parseLong(sValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return new TimeValue(millis, TimeUnit.MILLISECONDS);
|
return new TimeValue(millis, TimeUnit.MILLISECONDS);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
|
|
@ -168,11 +168,6 @@ public class InternalSettingsPreparer {
|
||||||
output.put(ClusterName.SETTING, ClusterName.DEFAULT.value());
|
output.put(ClusterName.SETTING, ClusterName.DEFAULT.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
String v = output.get(Settings.SETTINGS_REQUIRE_UNITS);
|
|
||||||
if (v != null) {
|
|
||||||
Settings.setSettingsRequireUnits(Booleans.parseBoolean(v, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
replacePromptPlaceholders(output, terminal);
|
replacePromptPlaceholders(output, terminal);
|
||||||
// all settings placeholders have been resolved. resolve the value for the name setting by checking for name,
|
// all settings placeholders have been resolved. resolve the value for the name setting by checking for name,
|
||||||
// then looking for node.name, and finally generate one if needed
|
// then looking for node.name, and finally generate one if needed
|
||||||
|
|
|
@ -329,19 +329,6 @@ public class ClusterSettingsIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMissingUnitsLenient() {
|
|
||||||
try {
|
|
||||||
createNode(Settings.builder().put(Settings.SETTINGS_REQUIRE_UNITS, "false").build());
|
|
||||||
assertAcked(prepareCreate("test"));
|
|
||||||
ensureGreen();
|
|
||||||
client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().put("index.refresh_interval", "10")).execute().actionGet();
|
|
||||||
} finally {
|
|
||||||
// Restore the default so subsequent tests require units:
|
|
||||||
assertFalse(Settings.getSettingsRequireUnits());
|
|
||||||
Settings.setSettingsRequireUnits(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createNode(Settings settings) {
|
private void createNode(Settings settings) {
|
||||||
internalCluster().startNode(Settings.builder()
|
internalCluster().startNode(Settings.builder()
|
||||||
.put(ClusterName.SETTING, "ClusterSettingsIT")
|
.put(ClusterName.SETTING, "ClusterSettingsIT")
|
||||||
|
|
Loading…
Reference in New Issue