Convert `config.ignore_system_properties` to new settings infra

This commit is contained in:
Simon Willnauer 2016-01-27 16:10:06 +01:00
parent 1c1898cf42
commit bbba1e5d7f
12 changed files with 17 additions and 14 deletions

View File

@ -171,7 +171,7 @@ final class Bootstrap {
// placeholder
Settings nodeSettings = Settings.settingsBuilder()
.put(settings)
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true)
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING.getKey(), true)
.build();
node = new Node(nodeSettings);

View File

@ -64,6 +64,7 @@ import org.elasticsearch.indices.recovery.RecoverySettings;
import org.elasticsearch.indices.store.IndicesStore;
import org.elasticsearch.indices.ttl.IndicesTTLService;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.internal.InternalSettingsPreparer;
import org.elasticsearch.repositories.fs.FsRepository;
import org.elasticsearch.repositories.uri.URLRepository;
import org.elasticsearch.rest.BaseRestHandler;
@ -269,6 +270,7 @@ public final class ClusterSettings extends AbstractScopedSettings {
AutoCreateIndex.AUTO_CREATE_INDEX_SETTING,
BaseRestHandler.MULTI_ALLOW_EXPLICIT_INDEX,
ClusterName.CLUSTER_NAME_SETTING,
InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING,
ClusterModule.SHARDS_ALLOCATOR_TYPE_SETTING,
EsExecutors.PROCESSORS_SETTING)));
}

View File

@ -25,6 +25,7 @@ import org.elasticsearch.common.Randomness;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.cli.Terminal;
import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsException;
import org.elasticsearch.env.Environment;
@ -56,7 +57,7 @@ public class InternalSettingsPreparer {
public static final String SECRET_PROMPT_VALUE = "${prompt.secret}";
public static final String TEXT_PROMPT_VALUE = "${prompt.text}";
public static final String IGNORE_SYSTEM_PROPERTIES_SETTING = "config.ignore_system_properties";
public static final Setting<Boolean> IGNORE_SYSTEM_PROPERTIES_SETTING = Setting.boolSetting("config.ignore_system_properties", false, false, Setting.Scope.CLUSTER);
/**
* Prepares the settings by gathering all elasticsearch system properties and setting defaults.
@ -112,7 +113,7 @@ public class InternalSettingsPreparer {
}
private static boolean useSystemProperties(Settings input) {
return !input.getAsBoolean(IGNORE_SYSTEM_PROPERTIES_SETTING, false);
return !IGNORE_SYSTEM_PROPERTIES_SETTING.get(input);
}
/**

View File

@ -58,7 +58,7 @@ public class TransportClientIT extends ESIntegTestCase {
.put("http.enabled", false)
.put(Node.NODE_DATA_SETTING.getKey(), false)
.put("cluster.name", "foobar")
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true) // make sure we get what we set :)
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING.getKey(), true) // make sure we get what we set :)
.build());
node.start();
try {

View File

@ -56,7 +56,7 @@ public class TransportClientRetryIT extends ESIntegTestCase {
.put("name", "transport_client_retry_test")
.put(Node.NODE_MODE_SETTING.getKey(), internalCluster().getNodeMode())
.put(ClusterName.CLUSTER_NAME_SETTING.getKey(), internalCluster().getClusterName())
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true)
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING.getKey(), true)
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir());
try (TransportClient transportClient = TransportClient.builder().settings(builder.build()).build()) {

View File

@ -93,7 +93,7 @@ public class EvilInternalSettingsPreparerTests extends ESTestCase {
assertThat(env.settings().get("node.zone"), equalTo("foo"));
settings = settingsBuilder()
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true)
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING.getKey(), true)
.put("node.zone", "bar")
.put(baseEnvSettings)
.build();

View File

@ -105,7 +105,7 @@ public class TribeUnitTests extends ESTestCase {
Path pathConf = getDataPath("elasticsearch.yml").getParent();
Settings settings = Settings
.builder()
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true)
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING.getKey(), true)
.put(Environment.PATH_CONF_SETTING.getKey(), pathConf)
.build();
assertTribeNodeSuccessfullyCreated(settings);

View File

@ -78,7 +78,7 @@ public abstract class ESSmokeClientTestCase extends LuceneTestCase {
private static Client startClient(Path tempDir, TransportAddress... transportAddresses) {
Settings clientSettings = Settings.settingsBuilder()
.put("name", "qa_smoke_client_" + counter.getAndIncrement())
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true) // prevents any settings to be replaced by system properties.
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING.getKey(), true) // prevents any settings to be replaced by system properties.
.put("client.transport.ignore_cluster_name", true)
.put(Environment.PATH_HOME_SETTING.getKey(), tempDir)
.put(Node.NODE_MODE_SETTING.getKey(), "network").build(); // we require network here!

View File

@ -172,7 +172,7 @@ public abstract class ESSingleNodeTestCase extends ESTestCase {
.put("http.enabled", false)
.put(Node.NODE_LOCAL_SETTING.getKey(), true)
.put(Node.NODE_DATA_SETTING.getKey(), true)
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true) // make sure we get what we set :)
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING.getKey(), true) // make sure we get what we set :)
.build();
Node build = new MockNode(settings, getVersion(), getPlugins());
build.start();

View File

@ -53,7 +53,7 @@ import static org.elasticsearch.common.settings.Settings.settingsBuilder;
final class ExternalNode implements Closeable {
public static final Settings REQUIRED_SETTINGS = Settings.builder()
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true)
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING.getKey(), true)
.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "zen")
.put(Node.NODE_MODE_SETTING.getKey(), "network").build(); // we need network mode for this
@ -115,7 +115,7 @@ final class ExternalNode implements Closeable {
case NetworkModule.TRANSPORT_TYPE_KEY:
case "discovery.type":
case NetworkModule.TRANSPORT_SERVICE_TYPE_KEY:
case InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING:
case "config.ignore_system_properties":
continue;
default:
externaNodeSettingsBuilder.put(entry.getKey(), entry.getValue());

View File

@ -74,7 +74,7 @@ public final class ExternalTestCluster extends TestCluster {
Settings clientSettings = Settings.settingsBuilder()
.put(additionalSettings)
.put("name", InternalTestCluster.TRANSPORT_CLIENT_PREFIX + EXTERNAL_CLUSTER_PREFIX + counter.getAndIncrement())
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true) // prevents any settings to be replaced by system properties.
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING.getKey(), true) // prevents any settings to be replaced by system properties.
.put("client.transport.ignore_cluster_name", true)
.put(Environment.PATH_HOME_SETTING.getKey(), tempDir)
.put(Node.NODE_MODE_SETTING.getKey(), "network").build(); // we require network here!

View File

@ -289,7 +289,7 @@ public final class InternalTestCluster extends TestCluster {
builder.put(Environment.PATH_REPO_SETTING.getKey(), baseDir.resolve("repos"));
builder.put("transport.tcp.port", TRANSPORT_BASE_PORT + "-" + (TRANSPORT_BASE_PORT + PORTS_PER_CLUSTER));
builder.put("http.port", HTTP_BASE_PORT + "-" + (HTTP_BASE_PORT + PORTS_PER_CLUSTER));
builder.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true);
builder.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING.getKey(), true);
builder.put(Node.NODE_MODE_SETTING.getKey(), nodeMode);
builder.put("http.pipelining", enableHttpPipelining);
if (Strings.hasLength(System.getProperty("es.logger.level"))) {
@ -886,7 +886,7 @@ public final class InternalTestCluster extends TestCluster {
.put(Node.NODE_MODE_SETTING.getKey(), Node.NODE_MODE_SETTING.exists(nodeSettings) ? Node.NODE_MODE_SETTING.get(nodeSettings) : nodeMode)
.put("logger.prefix", nodeSettings.get("logger.prefix", ""))
.put("logger.level", nodeSettings.get("logger.level", "INFO"))
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true)
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING.getKey(), true)
.put(settings);
if (Node.NODE_LOCAL_SETTING.exists(nodeSettings)) {