diff --git a/buildSrc/src/main/resources/checkstyle_suppressions.xml b/buildSrc/src/main/resources/checkstyle_suppressions.xml
index d56bdeb537f..0a4dbbf3ff9 100644
--- a/buildSrc/src/main/resources/checkstyle_suppressions.xml
+++ b/buildSrc/src/main/resources/checkstyle_suppressions.xml
@@ -753,7 +753,6 @@
-
diff --git a/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java b/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java
index 76c4eafad78..56f541631ab 100644
--- a/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java
+++ b/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java
@@ -37,19 +37,21 @@ import org.elasticsearch.common.inject.ModulesBuilder;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.network.NetworkService;
+import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.common.util.BigArrays;
-import org.elasticsearch.indices.breaker.CircuitBreakerModule;
+import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.monitor.MonitorService;
+import org.elasticsearch.node.Node;
import org.elasticsearch.node.internal.InternalSettingsPreparer;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.PluginsModule;
import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.search.SearchModule;
+import org.elasticsearch.threadpool.ExecutorBuilder;
import org.elasticsearch.threadpool.ThreadPool;
-import org.elasticsearch.threadpool.ThreadPoolModule;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.transport.netty.NettyTransport;
@@ -134,10 +136,9 @@ public class TransportClient extends AbstractClient {
modules.add(pluginModule);
}
modules.add(new PluginsModule(pluginsService));
- modules.add(new SettingsModule(settings));
modules.add(new NetworkModule(networkService, settings, true, namedWriteableRegistry));
modules.add(new ClusterNameModule(settings));
- modules.add(new ThreadPoolModule(threadPool));
+ modules.add(b -> b.bind(ThreadPool.class).toInstance(threadPool));
modules.add(new SearchModule(settings, namedWriteableRegistry) {
@Override
protected void configure() {
@@ -145,9 +146,20 @@ public class TransportClient extends AbstractClient {
}
});
modules.add(new ActionModule(false, true));
- modules.add(new CircuitBreakerModule(settings));
pluginsService.processModules(modules);
+ final List> additionalSettings = new ArrayList<>();
+ final List additionalSettingsFilter = new ArrayList<>();
+ additionalSettings.addAll(pluginsService.getPluginSettings());
+ additionalSettingsFilter.addAll(pluginsService.getPluginSettingsFilter());
+ for (final ExecutorBuilder> builder : threadPool.builders()) {
+ additionalSettings.addAll(builder.getRegisteredSettings());
+ }
+ SettingsModule settingsModule = new SettingsModule(settings, additionalSettings, additionalSettingsFilter);
+ CircuitBreakerService circuitBreakerService = Node.createCircuitBreakerService(settingsModule.getSettings(),
+ settingsModule.getClusterSettings());
+ modules.add(settingsModule);
+ modules.add((b -> b.bind(CircuitBreakerService.class).toInstance(circuitBreakerService)));
Injector injector = modules.createInjector();
final TransportService transportService = injector.getInstance(TransportService.class);
diff --git a/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java b/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java
index 8c2d4dc01bf..de2d3b75df6 100644
--- a/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java
+++ b/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java
@@ -420,6 +420,7 @@ public final class ClusterSettings extends AbstractScopedSettings {
ResourceWatcherService.RELOAD_INTERVAL_MEDIUM,
ResourceWatcherService.RELOAD_INTERVAL_LOW,
SearchModule.INDICES_MAX_CLAUSE_COUNT_SETTING,
- ThreadPool.ESTIMATED_TIME_INTERVAL_SETTING
+ ThreadPool.ESTIMATED_TIME_INTERVAL_SETTING,
+ Node.BREAKER_TYPE_KEY
)));
}
diff --git a/core/src/main/java/org/elasticsearch/common/settings/Setting.java b/core/src/main/java/org/elasticsearch/common/settings/Setting.java
index da32468acc3..2c3aad38c63 100644
--- a/core/src/main/java/org/elasticsearch/common/settings/Setting.java
+++ b/core/src/main/java/org/elasticsearch/common/settings/Setting.java
@@ -81,6 +81,11 @@ public class Setting extends ToXContentToBytes {
*/
Filtered,
+ /**
+ * iff this setting is shared with more than one module ie. can be defined multiple times.
+ */
+ Shared,
+
/**
* iff this setting can be dynamically updateable
*/
@@ -247,6 +252,13 @@ public class Setting extends ToXContentToBytes {
return properties.contains(Property.Deprecated);
}
+ /**
+ * Returns true
if this setting is shared with more than one other module or plugin, otherwise false
+ */
+ public boolean isShared() {
+ return properties.contains(Property.Shared);
+ }
+
/**
* Returns true
iff this setting is a group setting. Group settings represent a set of settings rather than a single value.
* The key, see {@link #getKey()}, in contrast to non-group settings is a prefix like cluster.store. that matches all settings
diff --git a/core/src/main/java/org/elasticsearch/common/settings/SettingsModule.java b/core/src/main/java/org/elasticsearch/common/settings/SettingsModule.java
index 2ed5ffd86cd..5fd19c4fc1f 100644
--- a/core/src/main/java/org/elasticsearch/common/settings/SettingsModule.java
+++ b/core/src/main/java/org/elasticsearch/common/settings/SettingsModule.java
@@ -19,7 +19,8 @@
package org.elasticsearch.common.settings;
-import org.elasticsearch.common.inject.AbstractModule;
+import org.elasticsearch.common.inject.Binder;
+import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.xcontent.ToXContent;
@@ -28,9 +29,11 @@ import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.tribe.TribeService;
import java.io.IOException;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
@@ -40,7 +43,7 @@ import java.util.stream.IntStream;
/**
* A module that binds the provided settings to the {@link Settings} interface.
*/
-public class SettingsModule extends AbstractModule {
+public class SettingsModule implements Module {
private final Settings settings;
private final Set settingsFilterPattern = new HashSet<>();
@@ -49,8 +52,14 @@ public class SettingsModule extends AbstractModule {
private static final Predicate TRIBE_CLIENT_NODE_SETTINGS_PREDICATE = (s) -> s.startsWith("tribe.")
&& TribeService.TRIBE_SETTING_KEYS.contains(s) == false;
private final ESLogger logger;
+ private final IndexScopedSettings indexScopedSettings;
+ private final ClusterSettings clusterSettings;
- public SettingsModule(Settings settings) {
+ public SettingsModule(Settings settings, Setting>... additionalSettings) {
+ this(settings, Arrays.asList(additionalSettings), Collections.emptyList());
+ }
+
+ public SettingsModule(Settings settings, List> additionalSettings, List settingsFilter) {
logger = Loggers.getLogger(getClass(), settings);
this.settings = settings;
for (Setting> setting : ClusterSettings.BUILT_IN_CLUSTER_SETTINGS) {
@@ -59,12 +68,16 @@ public class SettingsModule extends AbstractModule {
for (Setting> setting : IndexScopedSettings.BUILT_IN_INDEX_SETTINGS) {
registerSetting(setting);
}
- }
- @Override
- protected void configure() {
- final IndexScopedSettings indexScopedSettings = new IndexScopedSettings(settings, new HashSet<>(this.indexSettings.values()));
- final ClusterSettings clusterSettings = new ClusterSettings(settings, new HashSet<>(this.nodeSettings.values()));
+ for (Setting> setting : additionalSettings) {
+ registerSetting(setting);
+ }
+
+ for (String filter : settingsFilter) {
+ registerSettingsFilter(filter);
+ }
+ this.indexScopedSettings = new IndexScopedSettings(settings, new HashSet<>(this.indexSettings.values()));
+ this.clusterSettings = new ClusterSettings(settings, new HashSet<>(this.nodeSettings.values()));
Settings indexSettings = settings.filter((s) -> (s.startsWith("index.") &&
// special case - we want to get Did you mean indices.query.bool.max_clause_count
// which means we need to by-pass this check for this setting
@@ -87,7 +100,7 @@ public class SettingsModule extends AbstractModule {
"In order to upgrade all indices the settings must be updated via the /${index}/_settings API. " +
"Unless all settings are dynamic all indices must be closed in order to apply the upgrade" +
"Indices created in the future should use index templates to set default values."
- ).split(" ")) {
+ ).split(" ")) {
if (count + word.length() > 85) {
builder.append(System.lineSeparator());
count = 0;
@@ -124,19 +137,23 @@ public class SettingsModule extends AbstractModule {
final Predicate acceptOnlyClusterSettings = TRIBE_CLIENT_NODE_SETTINGS_PREDICATE.negate();
clusterSettings.validate(settings.filter(acceptOnlyClusterSettings));
validateTribeSettings(settings, clusterSettings);
- bind(Settings.class).toInstance(settings);
- bind(SettingsFilter.class).toInstance(new SettingsFilter(settings, settingsFilterPattern));
+ }
- bind(ClusterSettings.class).toInstance(clusterSettings);
- bind(IndexScopedSettings.class).toInstance(indexScopedSettings);
+ @Override
+ public void configure(Binder binder) {
+ binder.bind(Settings.class).toInstance(settings);
+ binder.bind(SettingsFilter.class).toInstance(new SettingsFilter(settings, settingsFilterPattern));
+ binder.bind(ClusterSettings.class).toInstance(clusterSettings);
+ binder.bind(IndexScopedSettings.class).toInstance(indexScopedSettings);
}
+
/**
* Registers a new setting. This method should be used by plugins in order to expose any custom settings the plugin defines.
* Unless a setting is registered the setting is unusable. If a setting is never the less specified the node will reject
* the setting during startup.
*/
- public void registerSetting(Setting> setting) {
+ private void registerSetting(Setting> setting) {
if (setting.isFiltered()) {
if (settingsFilterPattern.contains(setting.getKey()) == false) {
registerSettingsFilter(setting.getKey());
@@ -144,13 +161,15 @@ public class SettingsModule extends AbstractModule {
}
if (setting.hasNodeScope() || setting.hasIndexScope()) {
if (setting.hasNodeScope()) {
- if (nodeSettings.containsKey(setting.getKey())) {
+ Setting> existingSetting = nodeSettings.get(setting.getKey());
+ if (existingSetting != null && (setting.isShared() == false || existingSetting.isShared() == false)) {
throw new IllegalArgumentException("Cannot register setting [" + setting.getKey() + "] twice");
}
nodeSettings.put(setting.getKey(), setting);
}
if (setting.hasIndexScope()) {
- if (indexSettings.containsKey(setting.getKey())) {
+ Setting> existingSetting = indexSettings.get(setting.getKey());
+ if (existingSetting != null && (setting.isShared() == false || existingSetting.isShared() == false)) {
throw new IllegalArgumentException("Cannot register setting [" + setting.getKey() + "] twice");
}
indexSettings.put(setting.getKey(), setting);
@@ -164,7 +183,7 @@ public class SettingsModule extends AbstractModule {
* Registers a settings filter pattern that allows to filter out certain settings that for instance contain sensitive information
* or if a setting is for internal purposes only. The given pattern must either be a valid settings key or a simple regexp pattern.
*/
- public void registerSettingsFilter(String filter) {
+ private void registerSettingsFilter(String filter) {
if (SettingsFilter.isValidPattern(filter) == false) {
throw new IllegalArgumentException("filter [" + filter +"] is invalid must be either a key or a regex pattern");
}
@@ -174,19 +193,6 @@ public class SettingsModule extends AbstractModule {
settingsFilterPattern.add(filter);
}
- /**
- * Check if a setting has already been registered
- */
- public boolean exists(Setting> setting) {
- if (setting.hasNodeScope()) {
- return nodeSettings.containsKey(setting.getKey());
- }
- if (setting.hasIndexScope()) {
- return indexSettings.containsKey(setting.getKey());
- }
- throw new IllegalArgumentException("setting scope is unknown. This should never happen!");
- }
-
private void validateTribeSettings(Settings settings, ClusterSettings clusterSettings) {
Map groups = settings.filter(TRIBE_CLIENT_NODE_SETTINGS_PREDICATE).getGroups("tribe.", true);
for (Map.Entry tribeSettings : groups.entrySet()) {
@@ -200,4 +206,16 @@ public class SettingsModule extends AbstractModule {
}
}
}
+
+ public Settings getSettings() {
+ return settings;
+ }
+
+ public IndexScopedSettings getIndexScopedSettings() {
+ return indexScopedSettings;
+ }
+
+ public ClusterSettings getClusterSettings() {
+ return clusterSettings;
+ }
}
diff --git a/core/src/main/java/org/elasticsearch/env/EnvironmentModule.java b/core/src/main/java/org/elasticsearch/env/EnvironmentModule.java
index 8a4aa1fa885..6a893a73437 100644
--- a/core/src/main/java/org/elasticsearch/env/EnvironmentModule.java
+++ b/core/src/main/java/org/elasticsearch/env/EnvironmentModule.java
@@ -20,6 +20,7 @@
package org.elasticsearch.env;
import org.elasticsearch.common.inject.AbstractModule;
+import org.elasticsearch.threadpool.ThreadPool;
/**
*
@@ -27,13 +28,16 @@ import org.elasticsearch.common.inject.AbstractModule;
public class EnvironmentModule extends AbstractModule {
private final Environment environment;
+ private final ThreadPool threadPool;
- public EnvironmentModule(Environment environment) {
+ public EnvironmentModule(Environment environment, ThreadPool threadPool) {
+ this.threadPool = threadPool;
this.environment = environment;
}
@Override
protected void configure() {
+ bind(ThreadPool.class).toInstance(threadPool);
bind(Environment.class).toInstance(environment);
}
}
diff --git a/core/src/main/java/org/elasticsearch/indices/breaker/CircuitBreakerModule.java b/core/src/main/java/org/elasticsearch/indices/breaker/CircuitBreakerModule.java
deleted file mode 100644
index 084d3b7c66a..00000000000
--- a/core/src/main/java/org/elasticsearch/indices/breaker/CircuitBreakerModule.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.elasticsearch.indices.breaker;
-
-import org.elasticsearch.common.inject.AbstractModule;
-import org.elasticsearch.common.settings.Settings;
-
-public class CircuitBreakerModule extends AbstractModule {
-
- public static final String TYPE_KEY = "indices.breaker.type";
-
- private final Settings settings;
-
- public CircuitBreakerModule(Settings settings) {
- this.settings = settings;
- }
-
- @Override
- protected void configure() {
- String type = settings.get(TYPE_KEY);
- Class extends CircuitBreakerService> impl;
- if (type == null || type.equals("hierarchy")) {
- impl = HierarchyCircuitBreakerService.class;
- } else if (type.equals("none")) {
- impl = NoneCircuitBreakerService.class;
- } else {
- throw new IllegalArgumentException("Unknown circuit breaker type [" + type + "]");
- }
- bind(CircuitBreakerService.class).to(impl).asEagerSingleton();
- }
-}
diff --git a/core/src/main/java/org/elasticsearch/indices/breaker/CircuitBreakerService.java b/core/src/main/java/org/elasticsearch/indices/breaker/CircuitBreakerService.java
index d8bf8f10695..05bf8472ac9 100644
--- a/core/src/main/java/org/elasticsearch/indices/breaker/CircuitBreakerService.java
+++ b/core/src/main/java/org/elasticsearch/indices/breaker/CircuitBreakerService.java
@@ -64,4 +64,5 @@ public abstract class CircuitBreakerService extends AbstractLifecycleComponent WRITE_PORTS_FIELD_SETTING =
Setting.boolSetting("node.portsfile", false, Property.NodeScope);
public static final Setting NODE_DATA_SETTING = Setting.boolSetting("node.data", true, Property.NodeScope);
@@ -146,6 +148,16 @@ public class Node implements Closeable {
Setting.boolSetting("node.ingest", true, Property.NodeScope);
public static final Setting NODE_NAME_SETTING = Setting.simpleString("node.name", Property.NodeScope);
public static final Setting NODE_ATTRIBUTES = Setting.groupSetting("node.attr.", Property.NodeScope);
+ public static final Setting BREAKER_TYPE_KEY = new Setting<>("indices.breaker.type", "hierarchy", (s) -> {
+ switch (s) {
+ case "hierarchy":
+ case "none":
+ return s;
+ default:
+ throw new IllegalArgumentException("indices.breaker.type must be one of [hierarchy, none] but was: " + s);
+ }
+ }, Setting.Property.NodeScope);
+
private static final String CLIENT_TYPE = "node";
@@ -168,8 +180,9 @@ public class Node implements Closeable {
protected Node(Environment tmpEnv, Version version, Collection> classpathPlugins) {
Settings tmpSettings = Settings.builder().put(tmpEnv.settings())
.put(Client.CLIENT_TYPE_SETTING_S.getKey(), CLIENT_TYPE).build();
- tmpSettings = TribeService.processSettings(tmpSettings);
+ final List resourcesToClose = new ArrayList<>(); // register everything we need to release in the case of an error
+ tmpSettings = TribeService.processSettings(tmpSettings);
ESLogger logger = Loggers.getLogger(Node.class, NODE_NAME_SETTING.get(tmpSettings));
final String displayVersion = version + (Build.CURRENT.isSnapshot() ? "-SNAPSHOT" : "");
final JvmInfo jvmInfo = JvmInfo.jvmInfo();
@@ -203,40 +216,48 @@ public class Node implements Closeable {
this.pluginsService = new PluginsService(tmpSettings, tmpEnv.modulesFile(), tmpEnv.pluginsFile(), classpathPlugins);
this.settings = pluginsService.updatedSettings();
// create the environment based on the finalized (processed) view of the settings
- this.environment = new Environment(this.settings());
-
- final NodeEnvironment nodeEnvironment;
- try {
- nodeEnvironment = new NodeEnvironment(this.settings, this.environment);
- } catch (IOException ex) {
- throw new IllegalStateException("Failed to created node environment", ex);
- }
- final NetworkService networkService = new NetworkService(settings);
+ this.environment = new Environment(this.settings);
final List> executorBuilders = pluginsService.getExecutorBuilders(settings);
- final ThreadPool threadPool = new ThreadPool(settings, executorBuilders.toArray(new ExecutorBuilder[0]));
- final ScriptModule scriptModule = ScriptModule.create(settings, pluginsService.filterPlugins(ScriptPlugin.class));
- NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry();
+
boolean success = false;
try {
+ final ThreadPool threadPool = new ThreadPool(settings, executorBuilders.toArray(new ExecutorBuilder[0]));
+ resourcesToClose.add(() -> ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS));
+ final List> additionalSettings = new ArrayList<>();
+ final List additionalSettingsFilter = new ArrayList<>();
+ additionalSettings.addAll(pluginsService.getPluginSettings());
+ additionalSettingsFilter.addAll(pluginsService.getPluginSettingsFilter());
+ for (final ExecutorBuilder> builder : threadPool.builders()) {
+ additionalSettings.addAll(builder.getRegisteredSettings());
+ }
+ final ScriptModule scriptModule = ScriptModule.create(settings, pluginsService.filterPlugins(ScriptPlugin.class));
+ additionalSettings.addAll(scriptModule.getSettings());
+ // this is as early as we can validate settings at this point. we already pass them to ScriptModule as well as ThreadPool
+ // so we might be late here already
+ final SettingsModule settingsModule = new SettingsModule(this.settings, additionalSettings, additionalSettingsFilter);
+ final NodeEnvironment nodeEnvironment;
+ try {
+ nodeEnvironment = new NodeEnvironment(this.settings, this.environment);
+ resourcesToClose.add(nodeEnvironment);
+ } catch (IOException ex) {
+ throw new IllegalStateException("Failed to created node environment", ex);
+ }
+ final NetworkService networkService = new NetworkService(settings);
+ NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry();
ModulesBuilder modules = new ModulesBuilder();
modules.add(new Version.Module(version));
- modules.add(new CircuitBreakerModule(settings));
// plugin modules must be added here, before others or we can get crazy injection errors...
for (Module pluginModule : pluginsService.nodeModules()) {
modules.add(pluginModule);
}
final MonitorService monitorService = new MonitorService(settings, nodeEnvironment, threadPool);
modules.add(new PluginsModule(pluginsService));
- SettingsModule settingsModule = new SettingsModule(this.settings);
- modules.add(settingsModule);
- modules.add(new EnvironmentModule(environment));
+ modules.add(new EnvironmentModule(environment, threadPool));
modules.add(new NodeModule(this, monitorService));
modules.add(new NetworkModule(networkService, settings, false, namedWriteableRegistry));
modules.add(scriptModule);
modules.add(new NodeEnvironmentModule(nodeEnvironment));
modules.add(new ClusterNameModule(this.settings));
- final ThreadPoolModule threadPoolModule = new ThreadPoolModule(threadPool);
- modules.add(threadPoolModule);
modules.add(new DiscoveryModule(this.settings));
modules.add(new ClusterModule(this.settings));
modules.add(new IndicesModule());
@@ -248,23 +269,20 @@ public class Node implements Closeable {
modules.add(new RepositoriesModule());
modules.add(new TribeModule());
modules.add(new AnalysisModule(environment));
-
pluginsService.processModules(modules);
-
- scriptModule.prepareSettings(settingsModule);
-
- threadPoolModule.prepareSettings(settingsModule);
-
+ CircuitBreakerService circuitBreakerService = createCircuitBreakerService(settingsModule.getSettings(),
+ settingsModule.getClusterSettings());
+ resourcesToClose.add(circuitBreakerService);
+ modules.add(settingsModule);
+ modules.add(b -> b.bind(CircuitBreakerService.class).toInstance(circuitBreakerService));
injector = modules.createInjector();
-
client = injector.getInstance(Client.class);
success = true;
} catch (IOException ex) {
throw new ElasticsearchException("failed to bind service", ex);
} finally {
if (!success) {
- nodeEnvironment.close();
- ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS);
+ IOUtils.closeWhileHandlingException(resourcesToClose);
}
}
@@ -590,4 +608,19 @@ public class Node implements Closeable {
throw new RuntimeException("Failed to rename ports file", e);
}
}
+
+ /**
+ * Creates a new {@link CircuitBreakerService} based on the settings provided.
+ * @see #BREAKER_TYPE_KEY
+ */
+ public static CircuitBreakerService createCircuitBreakerService(Settings settings, ClusterSettings clusterSettings) {
+ String type = BREAKER_TYPE_KEY.get(settings);
+ if (type.equals("hierarchy")) {
+ return new HierarchyCircuitBreakerService(settings, clusterSettings);
+ } else if (type.equals("none")) {
+ return new NoneCircuitBreakerService();
+ } else {
+ throw new IllegalArgumentException("Unknown circuit breaker type [" + type + "]");
+ }
+ }
}
diff --git a/core/src/main/java/org/elasticsearch/plugins/Plugin.java b/core/src/main/java/org/elasticsearch/plugins/Plugin.java
index c619072a6ba..3907551a3cc 100644
--- a/core/src/main/java/org/elasticsearch/plugins/Plugin.java
+++ b/core/src/main/java/org/elasticsearch/plugins/Plugin.java
@@ -21,7 +21,9 @@ package org.elasticsearch.plugins;
import org.elasticsearch.common.component.LifecycleComponent;
import org.elasticsearch.common.inject.Module;
+import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.index.IndexModule;
import org.elasticsearch.script.ScriptModule;
import org.elasticsearch.threadpool.ExecutorBuilder;
@@ -76,6 +78,16 @@ public abstract class Plugin {
*/
public void onIndexModule(IndexModule indexModule) {}
+ /**
+ * Returns a list of additional {@link Setting} definitions for this plugin.
+ */
+ public List> getSettings() { return Collections.emptyList(); }
+
+ /**
+ * Returns a list of additional settings filter for this plugin
+ */
+ public List getSettingsFilter() { return Collections.emptyList(); }
+
/**
* Old-style guice index level extension point.
*
@@ -84,6 +96,15 @@ public abstract class Plugin {
@Deprecated
public final void onModule(IndexModule indexModule) {}
+
+ /**
+ * Old-style guice settings extension point.
+ *
+ * @deprecated use #getSettings and #getSettingsFilter instead
+ */
+ @Deprecated
+ public final void onModule(SettingsModule settingsModule) {}
+
/**
* Old-style guice scripting extension point.
*
diff --git a/core/src/main/java/org/elasticsearch/plugins/PluginsService.java b/core/src/main/java/org/elasticsearch/plugins/PluginsService.java
index 130870ea661..6d5e0161142 100644
--- a/core/src/main/java/org/elasticsearch/plugins/PluginsService.java
+++ b/core/src/main/java/org/elasticsearch/plugins/PluginsService.java
@@ -39,6 +39,7 @@ import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.index.IndexModule;
import org.elasticsearch.script.NativeScriptFactory;
import org.elasticsearch.script.ScriptContext;
@@ -64,7 +65,6 @@ import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
-import java.util.stream.Stream;
import static org.elasticsearch.common.io.FileSystemUtils.isAccessibleDirectory;
@@ -83,6 +83,14 @@ public class PluginsService extends AbstractComponent {
private final Map> onModuleReferences;
+ public List> getPluginSettings() {
+ return plugins.stream().flatMap(p -> p.v2().getSettings().stream()).collect(Collectors.toList());
+ }
+
+ public List getPluginSettingsFilter() {
+ return plugins.stream().flatMap(p -> p.v2().getSettingsFilter().stream()).collect(Collectors.toList());
+ }
+
static class OnModuleReference {
public final Class extends Module> moduleClass;
public final Method onModuleMethod;
@@ -288,6 +296,7 @@ public class PluginsService extends AbstractComponent {
plugin.v2().onIndexModule(indexModule);
}
}
+
/**
* Get information about plugins and modules
*/
diff --git a/core/src/main/java/org/elasticsearch/script/ScriptModule.java b/core/src/main/java/org/elasticsearch/script/ScriptModule.java
index b3c8e46c753..a66f642fa15 100644
--- a/core/src/main/java/org/elasticsearch/script/ScriptModule.java
+++ b/core/src/main/java/org/elasticsearch/script/ScriptModule.java
@@ -20,10 +20,11 @@
package org.elasticsearch.script;
import org.elasticsearch.common.inject.AbstractModule;
+import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.plugins.ScriptPlugin;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -57,13 +58,16 @@ public class ScriptModule extends AbstractModule {
* This method is called after all modules have been processed but before we actually validate all settings. This allows the
* script extensions to add all their settings.
*/
- public void prepareSettings(SettingsModule settingsModule) {
- scriptSettings.getScriptTypeSettings().forEach(settingsModule::registerSetting);
- scriptSettings.getScriptContextSettings().forEach(settingsModule::registerSetting);
- scriptSettings.getScriptLanguageSettings().forEach(settingsModule::registerSetting);
- settingsModule.registerSetting(scriptSettings.getDefaultScriptLanguageSetting());
+ public List> getSettings() {
+ ArrayList> settings = new ArrayList<>();
+ scriptSettings.getScriptTypeSettings().forEach(settings::add);
+ scriptSettings.getScriptContextSettings().forEach(settings::add);
+ scriptSettings.getScriptLanguageSettings().forEach(settings::add);
+ settings.add(scriptSettings.getDefaultScriptLanguageSetting());
+ return settings;
}
+
@Override
protected void configure() {
ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, scriptContextRegistry);
diff --git a/core/src/main/java/org/elasticsearch/threadpool/ExecutorBuilder.java b/core/src/main/java/org/elasticsearch/threadpool/ExecutorBuilder.java
index 434e6fc509c..5f36d391eba 100644
--- a/core/src/main/java/org/elasticsearch/threadpool/ExecutorBuilder.java
+++ b/core/src/main/java/org/elasticsearch/threadpool/ExecutorBuilder.java
@@ -51,7 +51,7 @@ public abstract class ExecutorBuilder> getRegisteredSettings();
+ public abstract List> getRegisteredSettings();
/**
* Return an executor settings object from the node-level settings.
diff --git a/core/src/main/java/org/elasticsearch/threadpool/FixedExecutorBuilder.java b/core/src/main/java/org/elasticsearch/threadpool/FixedExecutorBuilder.java
index 0735774d972..de7dbbaefc9 100644
--- a/core/src/main/java/org/elasticsearch/threadpool/FixedExecutorBuilder.java
+++ b/core/src/main/java/org/elasticsearch/threadpool/FixedExecutorBuilder.java
@@ -86,7 +86,7 @@ public final class FixedExecutorBuilder extends ExecutorBuilder> getRegisteredSettings() {
+ public List> getRegisteredSettings() {
return Arrays.asList(sizeSetting, queueSizeSetting);
}
diff --git a/core/src/main/java/org/elasticsearch/threadpool/ScalingExecutorBuilder.java b/core/src/main/java/org/elasticsearch/threadpool/ScalingExecutorBuilder.java
index 68c70c83c19..6ab108e94b4 100644
--- a/core/src/main/java/org/elasticsearch/threadpool/ScalingExecutorBuilder.java
+++ b/core/src/main/java/org/elasticsearch/threadpool/ScalingExecutorBuilder.java
@@ -77,7 +77,7 @@ public final class ScalingExecutorBuilder extends ExecutorBuilder> getRegisteredSettings() {
+ public List> getRegisteredSettings() {
return Arrays.asList(coreSetting, maxSetting, keepAliveSetting);
}
diff --git a/core/src/main/java/org/elasticsearch/threadpool/ThreadPoolModule.java b/core/src/main/java/org/elasticsearch/threadpool/ThreadPoolModule.java
deleted file mode 100644
index 843febfef8c..00000000000
--- a/core/src/main/java/org/elasticsearch/threadpool/ThreadPoolModule.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.elasticsearch.threadpool;
-
-import org.elasticsearch.common.inject.AbstractModule;
-import org.elasticsearch.common.settings.SettingsModule;
-
-public class ThreadPoolModule extends AbstractModule {
-
- private final ThreadPool threadPool;
-
- public ThreadPoolModule(final ThreadPool threadPool) {
- this.threadPool = threadPool;
- }
-
- public void prepareSettings(SettingsModule settingsModule) {
- for (final ExecutorBuilder> builder : threadPool.builders()) {
- builder.getRegisteredSettings().forEach(settingsModule::registerSetting);
- }
- }
-
- @Override
- protected void configure() {
- bind(ThreadPool.class).toInstance(threadPool);
- }
-
-}
diff --git a/core/src/test/java/org/elasticsearch/cluster/ClusterModuleTests.java b/core/src/test/java/org/elasticsearch/cluster/ClusterModuleTests.java
index fd924641859..98bb013f308 100644
--- a/core/src/test/java/org/elasticsearch/cluster/ClusterModuleTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/ClusterModuleTests.java
@@ -67,32 +67,32 @@ public class ClusterModuleTests extends ModuleTestCase {
}
public void testRegisterClusterDynamicSettingDuplicate() {
- SettingsModule module = new SettingsModule(Settings.EMPTY);
try {
- module.registerSetting(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING);
+ new SettingsModule(Settings.EMPTY, EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING);
} catch (IllegalArgumentException e) {
- assertEquals(e.getMessage(), "Cannot register setting [" + EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey() + "] twice");
+ assertEquals(e.getMessage(),
+ "Cannot register setting [" + EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey() + "] twice");
}
}
public void testRegisterClusterDynamicSetting() {
- SettingsModule module = new SettingsModule(Settings.EMPTY);
- module.registerSetting(Setting.boolSetting("foo.bar", false, Property.Dynamic, Property.NodeScope));
+ SettingsModule module = new SettingsModule(Settings.EMPTY,
+ Setting.boolSetting("foo.bar", false, Property.Dynamic, Property.NodeScope));
assertInstanceBinding(module, ClusterSettings.class, service -> service.hasDynamicSetting("foo.bar"));
}
public void testRegisterIndexDynamicSettingDuplicate() {
- SettingsModule module = new SettingsModule(Settings.EMPTY);
try {
- module.registerSetting(EnableAllocationDecider.INDEX_ROUTING_ALLOCATION_ENABLE_SETTING);
+ new SettingsModule(Settings.EMPTY, EnableAllocationDecider.INDEX_ROUTING_ALLOCATION_ENABLE_SETTING);
} catch (IllegalArgumentException e) {
- assertEquals(e.getMessage(), "Cannot register setting [" + EnableAllocationDecider.INDEX_ROUTING_ALLOCATION_ENABLE_SETTING.getKey() + "] twice");
+ assertEquals(e.getMessage(),
+ "Cannot register setting [" + EnableAllocationDecider.INDEX_ROUTING_ALLOCATION_ENABLE_SETTING.getKey() + "] twice");
}
}
public void testRegisterIndexDynamicSetting() {
- SettingsModule module = new SettingsModule(Settings.EMPTY);
- module.registerSetting(Setting.boolSetting("index.foo.bar", false, Property.Dynamic, Property.IndexScope));
+ SettingsModule module = new SettingsModule(Settings.EMPTY,
+ Setting.boolSetting("index.foo.bar", false, Property.Dynamic, Property.IndexScope));
assertInstanceBinding(module, IndexScopedSettings.class, service -> service.hasDynamicSetting("index.foo.bar"));
}
@@ -101,7 +101,8 @@ public class ClusterModuleTests extends ModuleTestCase {
try {
module.registerAllocationDecider(EnableAllocationDecider.class);
} catch (IllegalArgumentException e) {
- assertEquals(e.getMessage(), "Can't register the same [allocation_decider] more than once for [" + EnableAllocationDecider.class.getName() + "]");
+ assertEquals(e.getMessage(),
+ "Can't register the same [allocation_decider] more than once for [" + EnableAllocationDecider.class.getName() + "]");
}
}
@@ -146,7 +147,8 @@ public class ClusterModuleTests extends ModuleTestCase {
module.registerIndexTemplateFilter(FakeIndexTemplateFilter.class);
module.registerIndexTemplateFilter(FakeIndexTemplateFilter.class);
} catch (IllegalArgumentException e) {
- assertEquals(e.getMessage(), "Can't register the same [index_template_filter] more than once for [" + FakeIndexTemplateFilter.class.getName() + "]");
+ assertEquals(e.getMessage(),
+ "Can't register the same [index_template_filter] more than once for [" + FakeIndexTemplateFilter.class.getName() + "]");
}
}
diff --git a/core/src/test/java/org/elasticsearch/cluster/settings/SettingsFilteringIT.java b/core/src/test/java/org/elasticsearch/cluster/settings/SettingsFilteringIT.java
index 194b82620de..339ecf2bec6 100644
--- a/core/src/test/java/org/elasticsearch/cluster/settings/SettingsFilteringIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/settings/SettingsFilteringIT.java
@@ -30,7 +30,9 @@ import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import java.util.Arrays;
import java.util.Collection;
+import java.util.List;
import static org.elasticsearch.test.ESIntegTestCase.Scope.SUITE;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
@@ -72,12 +74,16 @@ public class SettingsFilteringIT extends ESIntegTestCase {
return Settings.builder().put("some.node.setting", true).put("some.other.node.setting", true).build();
}
- public void onModule(SettingsModule module) {
- module.registerSetting(SOME_NODE_SETTING);
- module.registerSetting(SOME_OTHER_NODE_SETTING);
- module.registerSetting(Setting.groupSetting("index.filter_test.", Property.IndexScope));
- module.registerSettingsFilter("index.filter_test.foo");
- module.registerSettingsFilter("index.filter_test.bar*");
+ @Override
+ public List> getSettings() {
+ return Arrays.asList(SOME_NODE_SETTING,
+ SOME_OTHER_NODE_SETTING,
+ Setting.groupSetting("index.filter_test.", Property.IndexScope));
+ }
+
+ @Override
+ public List getSettingsFilter() {
+ return Arrays.asList("index.filter_test.foo", "index.filter_test.bar*");
}
}
diff --git a/core/src/test/java/org/elasticsearch/common/settings/SettingsModuleTests.java b/core/src/test/java/org/elasticsearch/common/settings/SettingsModuleTests.java
index 5e992fc947c..353b7b61d6c 100644
--- a/core/src/test/java/org/elasticsearch/common/settings/SettingsModuleTests.java
+++ b/core/src/test/java/org/elasticsearch/common/settings/SettingsModuleTests.java
@@ -21,6 +21,10 @@ package org.elasticsearch.common.settings;
import org.elasticsearch.common.inject.ModuleTestCase;
import org.elasticsearch.common.settings.Setting.Property;
+import org.joda.time.MonthDay;
+
+import java.util.Arrays;
+import java.util.Collections;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
@@ -35,18 +39,16 @@ public class SettingsModuleTests extends ModuleTestCase {
}
{
Settings settings = Settings.builder().put("cluster.routing.allocation.balance.shard", "[2.0]").build();
- SettingsModule module = new SettingsModule(settings);
IllegalArgumentException ex = expectThrows(IllegalArgumentException.class,
- () -> assertInstanceBinding(module, Settings.class, (s) -> s == settings));
+ () -> new SettingsModule(settings));
assertEquals("Failed to parse value [[2.0]] for setting [cluster.routing.allocation.balance.shard]", ex.getMessage());
}
{
Settings settings = Settings.builder().put("cluster.routing.allocation.balance.shard", "[2.0]")
.put("some.foo.bar", 1).build();
- SettingsModule module = new SettingsModule(settings);
IllegalArgumentException ex = expectThrows(IllegalArgumentException.class,
- () -> assertInstanceBinding(module, Settings.class, (s) -> s == settings));
+ () -> new SettingsModule(settings));
assertEquals("Failed to parse value [[2.0]] for setting [cluster.routing.allocation.balance.shard]", ex.getMessage());
assertEquals(1, ex.getSuppressed().length);
assertEquals("unknown setting [some.foo.bar]", ex.getSuppressed()[0].getMessage());
@@ -55,9 +57,8 @@ public class SettingsModuleTests extends ModuleTestCase {
{
Settings settings = Settings.builder().put("index.codec", "default")
.put("index.foo.bar", 1).build();
- SettingsModule module = new SettingsModule(settings);
IllegalArgumentException ex = expectThrows(IllegalArgumentException.class,
- () -> assertInstanceBinding(module, Settings.class, (s) -> s == settings));
+ () -> new SettingsModule(settings));
assertEquals("node settings must not contain any index level settings", ex.getMessage());
}
@@ -71,16 +72,13 @@ public class SettingsModuleTests extends ModuleTestCase {
public void testRegisterSettings() {
{
Settings settings = Settings.builder().put("some.custom.setting", "2.0").build();
- SettingsModule module = new SettingsModule(settings);
- module.registerSetting(Setting.floatSetting("some.custom.setting", 1.0f, Property.NodeScope));
+ SettingsModule module = new SettingsModule(settings, Setting.floatSetting("some.custom.setting", 1.0f, Property.NodeScope));
assertInstanceBinding(module, Settings.class, (s) -> s == settings);
}
{
Settings settings = Settings.builder().put("some.custom.setting", "false").build();
- SettingsModule module = new SettingsModule(settings);
- module.registerSetting(Setting.floatSetting("some.custom.setting", 1.0f, Property.NodeScope));
try {
- assertInstanceBinding(module, Settings.class, (s) -> s == settings);
+ new SettingsModule(settings, Setting.floatSetting("some.custom.setting", 1.0f, Property.NodeScope));
fail();
} catch (IllegalArgumentException ex) {
assertEquals("Failed to parse value [false] for setting [some.custom.setting]", ex.getMessage());
@@ -96,9 +94,8 @@ public class SettingsModuleTests extends ModuleTestCase {
}
{
Settings settings = Settings.builder().put("tribe.t1.cluster.routing.allocation.balance.shard", "[2.0]").build();
- SettingsModule module = new SettingsModule(settings);
try {
- assertInstanceBinding(module, Settings.class, (s) -> s == settings);
+ new SettingsModule(settings);
fail();
} catch (IllegalArgumentException ex) {
assertEquals(
@@ -116,9 +113,8 @@ public class SettingsModuleTests extends ModuleTestCase {
}
{
Settings settings = Settings.builder().put("tribe.blocks.write", "BOOM").build();
- SettingsModule module = new SettingsModule(settings);
try {
- assertInstanceBinding(module, Settings.class, (s) -> s == settings);
+ new SettingsModule(settings);
fail();
} catch (IllegalArgumentException ex) {
assertEquals("Failed to parse value [BOOM] cannot be parsed to boolean [ true/1/on/yes OR false/0/off/no ]",
@@ -127,9 +123,8 @@ public class SettingsModuleTests extends ModuleTestCase {
}
{
Settings settings = Settings.builder().put("tribe.blocks.wtf", "BOOM").build();
- SettingsModule module = new SettingsModule(settings);
try {
- assertInstanceBinding(module, Settings.class, (s) -> s == settings);
+ new SettingsModule(settings);
fail();
} catch (IllegalArgumentException ex) {
assertEquals("tribe.blocks validation failed: unknown setting [wtf]", ex.getMessage());
@@ -147,9 +142,8 @@ public class SettingsModuleTests extends ModuleTestCase {
{
Settings settings = Settings.builder().put("logger._root", "BOOM").put("logger.transport", "WOW").build();
- SettingsModule module = new SettingsModule(settings);
try {
- assertInstanceBinding(module, Settings.class, (s) -> s == settings);
+ new SettingsModule(settings);
fail();
} catch (IllegalArgumentException ex) {
assertEquals("No enum constant org.elasticsearch.common.logging.ESLoggerFactory.LogLevel.BOOM", ex.getMessage());
@@ -160,18 +154,17 @@ public class SettingsModuleTests extends ModuleTestCase {
public void testRegisterSettingsFilter() {
Settings settings = Settings.builder().put("foo.bar", "false").put("bar.foo", false).put("bar.baz", false).build();
- SettingsModule module = new SettingsModule(settings);
- module.registerSetting(Setting.boolSetting("foo.bar", true, Property.NodeScope));
- module.registerSetting(Setting.boolSetting("bar.foo", true, Property.NodeScope, Property.Filtered));
- module.registerSetting(Setting.boolSetting("bar.baz", true, Property.NodeScope));
-
- module.registerSettingsFilter("foo.*");
try {
- module.registerSettingsFilter("bar.foo");
+ new SettingsModule(settings, Arrays.asList(Setting.boolSetting("foo.bar", true, Property.NodeScope),
+ Setting.boolSetting("bar.foo", true, Property.NodeScope, Property.Filtered),
+ Setting.boolSetting("bar.baz", true, Property.NodeScope)), Arrays.asList("foo.*", "bar.foo"));
fail();
} catch (IllegalArgumentException ex) {
assertEquals("filter [bar.foo] has already been registered", ex.getMessage());
}
+ SettingsModule module = new SettingsModule(settings, Arrays.asList(Setting.boolSetting("foo.bar", true, Property.NodeScope),
+ 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).getAsMap().containsKey("bar.baz"));
@@ -180,29 +173,30 @@ public class SettingsModuleTests extends ModuleTestCase {
}
public void testMutuallyExclusiveScopes() {
- new SettingsModule(Settings.EMPTY).registerSetting(Setting.simpleString("foo.bar", Property.NodeScope));
- new SettingsModule(Settings.EMPTY).registerSetting(Setting.simpleString("foo.bar", Property.IndexScope));
+ new SettingsModule(Settings.EMPTY, Setting.simpleString("foo.bar", Property.NodeScope));
+ new SettingsModule(Settings.EMPTY, Setting.simpleString("index.foo.bar", Property.IndexScope));
// Those should fail
try {
- new SettingsModule(Settings.EMPTY).registerSetting(Setting.simpleString("foo.bar"));
+ new SettingsModule(Settings.EMPTY, Setting.simpleString("foo.bar"));
fail("No scope should fail");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), containsString("No scope found for setting"));
}
// Some settings have both scopes - that's fine too if they have per-node defaults
- SettingsModule module = new SettingsModule(Settings.EMPTY);
- module.registerSetting(Setting.simpleString("foo.bar", Property.IndexScope, Property.NodeScope));
-
try {
- module.registerSetting(Setting.simpleString("foo.bar", Property.NodeScope));
+ new SettingsModule(Settings.EMPTY,
+ Setting.simpleString("foo.bar", Property.IndexScope, Property.NodeScope),
+ Setting.simpleString("foo.bar", Property.NodeScope));
fail("already registered");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), containsString("Cannot register setting [foo.bar] twice"));
}
try {
- module.registerSetting(Setting.simpleString("foo.bar", Property.IndexScope));
+ new SettingsModule(Settings.EMPTY,
+ Setting.simpleString("foo.bar", Property.IndexScope, Property.NodeScope),
+ Setting.simpleString("foo.bar", Property.IndexScope));
fail("already registered");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), containsString("Cannot register setting [foo.bar] twice"));
@@ -211,10 +205,28 @@ public class SettingsModuleTests extends ModuleTestCase {
public void testOldMaxClauseCountSetting() {
Settings settings = Settings.builder().put("index.query.bool.max_clause_count", 1024).build();
- SettingsModule module = new SettingsModule(settings);
IllegalArgumentException ex = expectThrows(IllegalArgumentException.class,
- () -> assertInstanceBinding(module, Settings.class, (s) -> s == settings));
+ () -> new SettingsModule(settings));
assertEquals("unknown setting [index.query.bool.max_clause_count] did you mean [indices.query.bool.max_clause_count]?",
ex.getMessage());
}
+
+ public void testRegisterShared() {
+ Property scope = randomFrom(Property.NodeScope, Property.IndexScope);
+ expectThrows(IllegalArgumentException.class, () ->
+ new SettingsModule(Settings.EMPTY,
+ Setting.simpleString("index.foo.bar", scope), Setting.simpleString("index.foo.bar", scope))
+ );
+ expectThrows(IllegalArgumentException.class, () ->
+ new SettingsModule(Settings.EMPTY,
+ Setting.simpleString("index.foo.bar", scope, Property.Shared), Setting.simpleString("index.foo.bar", scope))
+ );
+ expectThrows(IllegalArgumentException.class, () ->
+ new SettingsModule(Settings.EMPTY,
+ Setting.simpleString("index.foo.bar", scope), Setting.simpleString("index.foo.bar", scope, Property.Shared))
+ );
+ new SettingsModule(Settings.EMPTY,
+ Setting.simpleString("index.foo.bar", scope, Property.Shared),
+ Setting.simpleString("index.foo.bar", scope, Property.Shared));
+ }
}
diff --git a/core/src/test/java/org/elasticsearch/index/SettingsListenerIT.java b/core/src/test/java/org/elasticsearch/index/SettingsListenerIT.java
index 07afef1d8ae..17ee96e91a7 100644
--- a/core/src/test/java/org/elasticsearch/index/SettingsListenerIT.java
+++ b/core/src/test/java/org/elasticsearch/index/SettingsListenerIT.java
@@ -23,13 +23,14 @@ import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
import static org.elasticsearch.test.ESIntegTestCase.Scope.SUITE;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
@@ -62,8 +63,9 @@ public class SettingsListenerIT extends ESIntegTestCase {
return "Settings Listenern Plugin";
}
- public void onModule(SettingsModule settingsModule) {
- settingsModule.registerSetting(SettingsTestingService.VALUE);
+ @Override
+ public List> getSettings() {
+ return Arrays.asList(SettingsTestingService.VALUE);
}
@Override
diff --git a/core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java b/core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java
index 0256fab1b7f..6eda8dbb0b1 100644
--- a/core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java
@@ -50,7 +50,9 @@ import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
+import java.util.Arrays;
import java.util.Collection;
+import java.util.List;
import java.util.function.Function;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
@@ -606,10 +608,9 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
new Setting<>("index.e", "", Function.identity(), Property.IndexScope);
- public void onModule(SettingsModule module) {
- module.registerSetting(INDEX_A);
- module.registerSetting(INDEX_C);
- module.registerSetting(INDEX_E);
+ @Override
+ public List> getSettings() {
+ return Arrays.asList(INDEX_A, INDEX_C, INDEX_E);
}
}
diff --git a/core/src/test/java/org/elasticsearch/indices/memory/breaker/RandomExceptionCircuitBreakerIT.java b/core/src/test/java/org/elasticsearch/indices/memory/breaker/RandomExceptionCircuitBreakerIT.java
index 19242b1f90b..41e15a3a351 100644
--- a/core/src/test/java/org/elasticsearch/indices/memory/breaker/RandomExceptionCircuitBreakerIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/memory/breaker/RandomExceptionCircuitBreakerIT.java
@@ -49,6 +49,7 @@ import org.elasticsearch.test.engine.ThrowingLeafReaderWrapper;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
+import java.util.List;
import java.util.Random;
import java.util.concurrent.ExecutionException;
@@ -209,9 +210,9 @@ public class RandomExceptionCircuitBreakerIT extends ESIntegTestCase {
return "a mock reader wrapper that throws random exceptions for testing";
}
- public void onModule(SettingsModule module) {
- module.registerSetting(EXCEPTION_TOP_LEVEL_RATIO_SETTING);
- module.registerSetting(EXCEPTION_LOW_LEVEL_RATIO_SETTING);
+ @Override
+ public List> getSettings() {
+ return Arrays.asList(EXCEPTION_TOP_LEVEL_RATIO_SETTING, EXCEPTION_LOW_LEVEL_RATIO_SETTING);
}
public void onModule(MockEngineFactoryPlugin.MockEngineReaderModule module) {
diff --git a/core/src/test/java/org/elasticsearch/script/NativeScriptTests.java b/core/src/test/java/org/elasticsearch/script/NativeScriptTests.java
index c35fb624e1e..65c0a4fddef 100644
--- a/core/src/test/java/org/elasticsearch/script/NativeScriptTests.java
+++ b/core/src/test/java/org/elasticsearch/script/NativeScriptTests.java
@@ -24,20 +24,22 @@ import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.inject.Injector;
import org.elasticsearch.common.inject.ModulesBuilder;
+import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.EnvironmentModule;
import org.elasticsearch.script.ScriptService.ScriptType;
import org.elasticsearch.test.ESTestCase;
+import org.elasticsearch.test.InternalSettingsPlugin;
import org.elasticsearch.threadpool.ThreadPool;
-import org.elasticsearch.threadpool.ThreadPoolModule;
import org.elasticsearch.watcher.ResourceWatcherService;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -51,14 +53,14 @@ public class NativeScriptTests extends ESTestCase {
.put("node.name", "testNativeScript")
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
.build();
- SettingsModule settingsModule = new SettingsModule(settings);
ScriptModule scriptModule = new ScriptModule(new NativeScriptEngineService(settings,
Collections.singletonMap("my", new MyNativeScriptFactory())));
- scriptModule.prepareSettings(settingsModule);
+ List> scriptSettings = scriptModule.getSettings();
+ scriptSettings.add(InternalSettingsPlugin.VERSION_CREATED);
+ SettingsModule settingsModule = new SettingsModule(settings, scriptSettings, Collections.emptyList());
final ThreadPool threadPool = new ThreadPool(settings);
Injector injector = new ModulesBuilder().add(
- new EnvironmentModule(new Environment(settings)),
- new ThreadPoolModule(threadPool),
+ new EnvironmentModule(new Environment(settings), threadPool),
new SettingsModule(settings),
scriptModule).createInjector();
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/AggregatorParsingTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/AggregatorParsingTests.java
index 3b80cb5679f..f052977873a 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/AggregatorParsingTests.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/AggregatorParsingTests.java
@@ -29,9 +29,9 @@ import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.Injector;
import org.elasticsearch.common.inject.ModulesBuilder;
-import org.elasticsearch.common.inject.multibindings.Multibinder;
import org.elasticsearch.common.inject.util.Providers;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.common.xcontent.XContentFactory;
@@ -46,31 +46,21 @@ import org.elasticsearch.indices.IndicesModule;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
-import org.elasticsearch.script.MockScriptEngine;
-import org.elasticsearch.script.ScriptContext;
-import org.elasticsearch.script.ScriptContextRegistry;
-import org.elasticsearch.script.ScriptEngineRegistry;
-import org.elasticsearch.script.ScriptEngineService;
import org.elasticsearch.script.ScriptModule;
import org.elasticsearch.script.ScriptService;
-import org.elasticsearch.script.ScriptSettings;
import org.elasticsearch.search.SearchModule;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.IndexSettingsModule;
import org.elasticsearch.test.InternalSettingsPlugin;
import org.elasticsearch.test.VersionUtils;
import org.elasticsearch.threadpool.ThreadPool;
-import org.elasticsearch.threadpool.ThreadPoolModule;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
import java.util.Random;
-import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -115,12 +105,12 @@ public class AggregatorParsingTests extends ESTestCase {
final ClusterService clusterService = createClusterService(threadPool);
setState(clusterService, new ClusterState.Builder(clusterService.state()).metaData(new MetaData.Builder()
.put(new IndexMetaData.Builder(index.getName()).settings(indexSettings).numberOfShards(1).numberOfReplicas(0))));
- SettingsModule settingsModule = new SettingsModule(settings);
- settingsModule.registerSetting(InternalSettingsPlugin.VERSION_CREATED);
ScriptModule scriptModule = newTestScriptModule();
- scriptModule.prepareSettings(settingsModule);
- injector = new ModulesBuilder().add(new EnvironmentModule(new Environment(settings)), settingsModule,
- new ThreadPoolModule(threadPool), scriptModule, new IndicesModule() {
+ List> scriptSettings = scriptModule.getSettings();
+ scriptSettings.add(InternalSettingsPlugin.VERSION_CREATED);
+ SettingsModule settingsModule = new SettingsModule(settings, scriptSettings, Collections.emptyList());
+ injector = new ModulesBuilder().add(new EnvironmentModule(new Environment(settings), threadPool), settingsModule
+ , scriptModule, new IndicesModule() {
@Override
protected void configure() {
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/BaseAggregationTestCase.java b/core/src/test/java/org/elasticsearch/search/aggregations/BaseAggregationTestCase.java
index c73df1bbf06..5cb267315a5 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/BaseAggregationTestCase.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/BaseAggregationTestCase.java
@@ -28,12 +28,12 @@ import org.elasticsearch.common.ParseFieldMatcher;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.Injector;
import org.elasticsearch.common.inject.ModulesBuilder;
-import org.elasticsearch.common.inject.multibindings.Multibinder;
import org.elasticsearch.common.inject.util.Providers;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.common.xcontent.ToXContent;
@@ -50,30 +50,20 @@ import org.elasticsearch.indices.IndicesModule;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
-import org.elasticsearch.script.MockScriptEngine;
-import org.elasticsearch.script.ScriptContext;
-import org.elasticsearch.script.ScriptContextRegistry;
-import org.elasticsearch.script.ScriptEngineRegistry;
-import org.elasticsearch.script.ScriptEngineService;
import org.elasticsearch.script.ScriptModule;
import org.elasticsearch.script.ScriptService;
-import org.elasticsearch.script.ScriptSettings;
import org.elasticsearch.search.SearchModule;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.IndexSettingsModule;
import org.elasticsearch.test.InternalSettingsPlugin;
import org.elasticsearch.test.VersionUtils;
import org.elasticsearch.threadpool.ThreadPool;
-import org.elasticsearch.threadpool.ThreadPoolModule;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import static org.elasticsearch.test.ClusterServiceUtils.createClusterService;
import static org.elasticsearch.test.ClusterServiceUtils.setState;
@@ -129,14 +119,13 @@ public abstract class BaseAggregationTestCase> scriptSettings = scriptModule.getSettings();
+ scriptSettings.add(InternalSettingsPlugin.VERSION_CREATED);
+ SettingsModule settingsModule = new SettingsModule(settings, scriptSettings, Collections.emptyList());
injector = new ModulesBuilder().add(
- new EnvironmentModule(new Environment(settings)),
+ new EnvironmentModule(new Environment(settings), threadPool),
settingsModule,
- new ThreadPoolModule(threadPool),
scriptModule,
new IndicesModule() {
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/BasePipelineAggregationTestCase.java b/core/src/test/java/org/elasticsearch/search/aggregations/BasePipelineAggregationTestCase.java
index 2f2354b73a1..2d3a86fb4be 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/BasePipelineAggregationTestCase.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/BasePipelineAggregationTestCase.java
@@ -28,12 +28,12 @@ import org.elasticsearch.common.ParseFieldMatcher;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.Injector;
import org.elasticsearch.common.inject.ModulesBuilder;
-import org.elasticsearch.common.inject.multibindings.Multibinder;
import org.elasticsearch.common.inject.util.Providers;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.common.xcontent.ToXContent;
@@ -44,37 +44,27 @@ import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.EnvironmentModule;
import org.elasticsearch.index.Index;
-import org.elasticsearch.test.AbstractQueryTestCase;
import org.elasticsearch.index.query.QueryParseContext;
import org.elasticsearch.indices.IndicesModule;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
-import org.elasticsearch.script.MockScriptEngine;
-import org.elasticsearch.script.ScriptContext;
-import org.elasticsearch.script.ScriptContextRegistry;
-import org.elasticsearch.script.ScriptEngineRegistry;
-import org.elasticsearch.script.ScriptEngineService;
import org.elasticsearch.script.ScriptModule;
import org.elasticsearch.script.ScriptService;
-import org.elasticsearch.script.ScriptSettings;
import org.elasticsearch.search.SearchModule;
import org.elasticsearch.search.aggregations.pipeline.AbstractPipelineAggregatorBuilder;
+import org.elasticsearch.test.AbstractQueryTestCase;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.IndexSettingsModule;
import org.elasticsearch.test.InternalSettingsPlugin;
import org.elasticsearch.test.VersionUtils;
import org.elasticsearch.threadpool.ThreadPool;
-import org.elasticsearch.threadpool.ThreadPoolModule;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import static org.elasticsearch.test.ClusterServiceUtils.createClusterService;
import static org.elasticsearch.test.ClusterServiceUtils.setState;
@@ -129,14 +119,13 @@ public abstract class BasePipelineAggregationTestCase> scriptSettings = scriptModule.getSettings();
+ scriptSettings.add(InternalSettingsPlugin.VERSION_CREATED);
+ SettingsModule settingsModule = new SettingsModule(settings, scriptSettings, Collections.emptyList());
injector = new ModulesBuilder().add(
- new EnvironmentModule(new Environment(settings)),
+ new EnvironmentModule(new Environment(settings),threadPool),
settingsModule,
- new ThreadPoolModule(threadPool),
scriptModule,
new IndicesModule() {
diff --git a/core/src/test/java/org/elasticsearch/search/basic/SearchWithRandomExceptionsIT.java b/core/src/test/java/org/elasticsearch/search/basic/SearchWithRandomExceptionsIT.java
index 7ddb6413364..0b3ccf165c3 100644
--- a/core/src/test/java/org/elasticsearch/search/basic/SearchWithRandomExceptionsIT.java
+++ b/core/src/test/java/org/elasticsearch/search/basic/SearchWithRandomExceptionsIT.java
@@ -44,7 +44,9 @@ import org.elasticsearch.test.engine.MockEngineSupport;
import org.elasticsearch.test.engine.ThrowingLeafReaderWrapper;
import java.io.IOException;
+import java.util.Arrays;
import java.util.Collection;
+import java.util.List;
import java.util.Random;
import java.util.concurrent.ExecutionException;
@@ -160,9 +162,9 @@ public class SearchWithRandomExceptionsIT extends ESIntegTestCase {
public String name() {
return "random-exception-reader-wrapper";
}
- public void onModule(SettingsModule module) {
- module.registerSetting(EXCEPTION_TOP_LEVEL_RATIO_SETTING);
- module.registerSetting(EXCEPTION_LOW_LEVEL_RATIO_SETTING);
+ @Override
+ public List> getSettings() {
+ return Arrays.asList(EXCEPTION_TOP_LEVEL_RATIO_SETTING, EXCEPTION_LOW_LEVEL_RATIO_SETTING);
}
@Override
public String description() {
diff --git a/core/src/test/java/org/elasticsearch/search/builder/SearchSourceBuilderTests.java b/core/src/test/java/org/elasticsearch/search/builder/SearchSourceBuilderTests.java
index 641cb2c1b85..9bb39d00f4a 100644
--- a/core/src/test/java/org/elasticsearch/search/builder/SearchSourceBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/search/builder/SearchSourceBuilderTests.java
@@ -30,12 +30,12 @@ import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.Injector;
import org.elasticsearch.common.inject.ModulesBuilder;
-import org.elasticsearch.common.inject.multibindings.Multibinder;
import org.elasticsearch.common.inject.util.Providers;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.common.text.Text;
@@ -54,15 +54,9 @@ import org.elasticsearch.indices.IndicesModule;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
-import org.elasticsearch.script.MockScriptEngine;
import org.elasticsearch.script.Script;
-import org.elasticsearch.script.ScriptContext;
-import org.elasticsearch.script.ScriptContextRegistry;
-import org.elasticsearch.script.ScriptEngineRegistry;
-import org.elasticsearch.script.ScriptEngineService;
import org.elasticsearch.script.ScriptModule;
import org.elasticsearch.script.ScriptService;
-import org.elasticsearch.script.ScriptSettings;
import org.elasticsearch.search.SearchModule;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.AggregatorParsers;
@@ -85,16 +79,13 @@ import org.elasticsearch.test.IndexSettingsModule;
import org.elasticsearch.test.InternalSettingsPlugin;
import org.elasticsearch.test.VersionUtils;
import org.elasticsearch.threadpool.ThreadPool;
-import org.elasticsearch.threadpool.ThreadPoolModule;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import java.util.concurrent.TimeUnit;
import static org.elasticsearch.test.ClusterServiceUtils.createClusterService;
@@ -136,13 +127,12 @@ public class SearchSourceBuilderTests extends ESTestCase {
final ClusterService clusterService = createClusterService(threadPool);
setState(clusterService, new ClusterState.Builder(clusterService.state()).metaData(new MetaData.Builder()
.put(new IndexMetaData.Builder(index.getName()).settings(indexSettings).numberOfShards(1).numberOfReplicas(0))));
- SettingsModule settingsModule = new SettingsModule(settings);
- settingsModule.registerSetting(InternalSettingsPlugin.VERSION_CREATED);
ScriptModule scriptModule = newTestScriptModule();
- scriptModule.prepareSettings(settingsModule);
+ List> scriptSettings = scriptModule.getSettings();
+ scriptSettings.add(InternalSettingsPlugin.VERSION_CREATED);
+ SettingsModule settingsModule = new SettingsModule(settings, scriptSettings, Collections.emptyList());
injector = new ModulesBuilder().add(
- new EnvironmentModule(new Environment(settings)), settingsModule,
- new ThreadPoolModule(threadPool),
+ new EnvironmentModule(new Environment(settings), threadPool), settingsModule,
scriptModule, new IndicesModule() {
@Override
protected void configure() {
diff --git a/core/src/test/java/org/elasticsearch/snapshots/mockstore/MockRepository.java b/core/src/test/java/org/elasticsearch/snapshots/mockstore/MockRepository.java
index 8b02f90f51c..ceaaa8aa470 100644
--- a/core/src/test/java/org/elasticsearch/snapshots/mockstore/MockRepository.java
+++ b/core/src/test/java/org/elasticsearch/snapshots/mockstore/MockRepository.java
@@ -48,6 +48,7 @@ import java.io.UnsupportedEncodingException;
import java.nio.file.Path;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -76,9 +77,9 @@ public class MockRepository extends FsRepository {
repositoriesModule.registerRepository("mock", MockRepository.class, BlobStoreIndexShardRepository.class);
}
- public void onModule(SettingsModule module) {
- module.registerSetting(USERNAME_SETTING);
- module.registerSetting(PASSWORD_SETTING);
+ @Override
+ public List> getSettings() {
+ return Arrays.asList(USERNAME_SETTING, PASSWORD_SETTING);
}
}
diff --git a/modules/lang-mustache/src/test/java/org/elasticsearch/messy/tests/TemplateQueryParserTests.java b/modules/lang-mustache/src/test/java/org/elasticsearch/messy/tests/TemplateQueryParserTests.java
index 54068d1921c..a16175689ff 100644
--- a/modules/lang-mustache/src/test/java/org/elasticsearch/messy/tests/TemplateQueryParserTests.java
+++ b/modules/lang-mustache/src/test/java/org/elasticsearch/messy/tests/TemplateQueryParserTests.java
@@ -32,6 +32,7 @@ import org.elasticsearch.common.inject.ModulesBuilder;
import org.elasticsearch.common.inject.multibindings.Multibinder;
import org.elasticsearch.common.inject.util.Providers;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.common.xcontent.XContentFactory;
@@ -67,13 +68,13 @@ import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.IndexSettingsModule;
import org.elasticsearch.test.InternalSettingsPlugin;
import org.elasticsearch.threadpool.ThreadPool;
-import org.elasticsearch.threadpool.ThreadPoolModule;
import org.junit.After;
import org.junit.Before;
import java.io.IOException;
import java.lang.reflect.Proxy;
import java.util.Collections;
+import java.util.List;
import java.util.function.Supplier;
import static org.hamcrest.Matchers.containsString;
@@ -102,16 +103,15 @@ public class TemplateQueryParserTests extends ESTestCase {
});
IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("test", settings);
Index index = idxSettings.getIndex();
- SettingsModule settingsModule = new SettingsModule(settings);
// TODO: make this use a mock engine instead of mustache and it will no longer be messy!
ScriptModule scriptModule = new ScriptModule(new MustacheScriptEngineService(settings));
- scriptModule.prepareSettings(settingsModule);
- settingsModule.registerSetting(InternalSettingsPlugin.VERSION_CREATED);
+ List> scriptSettings = scriptModule.getSettings();
+ scriptSettings.add(InternalSettingsPlugin.VERSION_CREATED);
+ SettingsModule settingsModule = new SettingsModule(settings, scriptSettings, Collections.emptyList());
final ThreadPool threadPool = new ThreadPool(settings);
injector = new ModulesBuilder().add(
- new EnvironmentModule(new Environment(settings)),
+ new EnvironmentModule(new Environment(settings), threadPool),
settingsModule,
- new ThreadPoolModule(threadPool),
new SearchModule(settings, new NamedWriteableRegistry()) {
@Override
protected void configureSearch() {
diff --git a/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorPlugin.java b/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorPlugin.java
index dfc11804dd9..b2064506059 100644
--- a/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorPlugin.java
+++ b/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorPlugin.java
@@ -23,6 +23,7 @@ import org.elasticsearch.action.ActionModule;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.network.NetworkModule;
+import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.indices.IndicesModule;
@@ -31,6 +32,8 @@ import org.elasticsearch.search.SearchModule;
import org.elasticsearch.search.fetch.FetchSubPhase;
import org.elasticsearch.search.highlight.HighlightPhase;
+import java.util.Arrays;
+import java.util.List;
import java.util.Optional;
public class PercolatorPlugin extends Plugin {
@@ -76,8 +79,9 @@ public class PercolatorPlugin extends Plugin {
module.registerFetchSubPhase(new PercolatorHighlightSubFetchPhase(settings, module.getHighlighters()));
}
- public void onModule(SettingsModule module) {
- module.registerSetting(PercolatorFieldMapper.INDEX_MAP_UNMAPPED_FIELDS_AS_STRING_SETTING);
+ @Override
+ public List> getSettings() {
+ return Arrays.asList(PercolatorFieldMapper.INDEX_MAP_UNMAPPED_FIELDS_AS_STRING_SETTING);
}
static boolean transportClientMode(Settings settings) {
diff --git a/plugins/discovery-azure/src/main/java/org/elasticsearch/plugin/discovery/azure/AzureDiscoveryPlugin.java b/plugins/discovery-azure/src/main/java/org/elasticsearch/plugin/discovery/azure/AzureDiscoveryPlugin.java
index 757ff359d42..7ee7d15d7ce 100644
--- a/plugins/discovery-azure/src/main/java/org/elasticsearch/plugin/discovery/azure/AzureDiscoveryPlugin.java
+++ b/plugins/discovery-azure/src/main/java/org/elasticsearch/plugin/discovery/azure/AzureDiscoveryPlugin.java
@@ -24,6 +24,7 @@ import org.elasticsearch.cloud.azure.management.AzureComputeService;
import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
+import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.discovery.DiscoveryModule;
@@ -31,8 +32,10 @@ import org.elasticsearch.discovery.azure.AzureUnicastHostsProvider;
import org.elasticsearch.discovery.zen.ZenDiscovery;
import org.elasticsearch.plugins.Plugin;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
public class AzureDiscoveryPlugin extends Plugin {
@@ -67,16 +70,18 @@ public class AzureDiscoveryPlugin extends Plugin {
}
}
- public void onModule(SettingsModule settingsModule) {
- settingsModule.registerSetting(AzureComputeService.Discovery.REFRESH_SETTING);
- settingsModule.registerSetting(AzureComputeService.Management.KEYSTORE_PASSWORD_SETTING);
- settingsModule.registerSetting(AzureComputeService.Management.KEYSTORE_PATH_SETTING);
- settingsModule.registerSetting(AzureComputeService.Management.KEYSTORE_TYPE_SETTING);
- settingsModule.registerSetting(AzureComputeService.Management.SUBSCRIPTION_ID_SETTING);
- settingsModule.registerSetting(AzureComputeService.Management.SERVICE_NAME_SETTING);
- settingsModule.registerSetting(AzureComputeService.Discovery.HOST_TYPE_SETTING);
- settingsModule.registerSetting(AzureComputeService.Discovery.DEPLOYMENT_NAME_SETTING);
- settingsModule.registerSetting(AzureComputeService.Discovery.DEPLOYMENT_SLOT_SETTING);
- settingsModule.registerSetting(AzureComputeService.Discovery.ENDPOINT_NAME_SETTING);
+ @Override
+ public List> getSettings() {
+ return Arrays.asList(AzureComputeService.Discovery.REFRESH_SETTING,
+ AzureComputeService.Management.KEYSTORE_PASSWORD_SETTING,
+ AzureComputeService.Management.KEYSTORE_PATH_SETTING,
+ AzureComputeService.Management.KEYSTORE_TYPE_SETTING,
+ AzureComputeService.Management.SUBSCRIPTION_ID_SETTING,
+ AzureComputeService.Management.SERVICE_NAME_SETTING,
+ AzureComputeService.Discovery.HOST_TYPE_SETTING,
+ AzureComputeService.Discovery.DEPLOYMENT_NAME_SETTING,
+ AzureComputeService.Discovery.DEPLOYMENT_SLOT_SETTING,
+ AzureComputeService.Discovery.ENDPOINT_NAME_SETTING);
}
+
}
diff --git a/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureDiscoveryClusterFormationTests.java b/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureDiscoveryClusterFormationTests.java
index 489f7043b83..0a1973ddda3 100644
--- a/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureDiscoveryClusterFormationTests.java
+++ b/plugins/discovery-azure/src/test/java/org/elasticsearch/discovery/azure/AzureDiscoveryClusterFormationTests.java
@@ -28,8 +28,8 @@ import org.elasticsearch.cloud.azure.management.AzureComputeService;
import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.io.FileSystemUtils;
import org.elasticsearch.common.logging.Loggers;
+import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.discovery.DiscoveryModule;
import org.elasticsearch.env.Environment;
import org.elasticsearch.node.Node;
@@ -57,6 +57,7 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.KeyStore;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -83,8 +84,9 @@ public class AzureDiscoveryClusterFormationTests extends ESIntegTestCase {
return AzureDiscoveryClusterFormationTests.class.getName();
}
- public void onModule(SettingsModule settingsModule) {
- settingsModule.registerSetting(AzureComputeService.Management.ENDPOINT_SETTING);
+ @Override
+ public List> getSettings() {
+ return Arrays.asList(AzureComputeService.Management.ENDPOINT_SETTING);
}
}
diff --git a/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java b/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java
index 8cfe6c43108..139b78226cf 100644
--- a/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java
+++ b/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java
@@ -42,43 +42,44 @@ public interface AwsEc2Service {
* cloud.aws.access_key: AWS Access key. Shared with repository-s3 plugin
*/
Setting KEY_SETTING =
- Setting.simpleString("cloud.aws.access_key", Property.NodeScope, Property.Filtered);
+ Setting.simpleString("cloud.aws.access_key", Property.NodeScope, Property.Filtered, Property.Shared);
/**
* cloud.aws.secret_key: AWS Secret key. Shared with repository-s3 plugin
*/
Setting SECRET_SETTING =
- Setting.simpleString("cloud.aws.secret_key", Property.NodeScope, Property.Filtered);
+ Setting.simpleString("cloud.aws.secret_key", Property.NodeScope, Property.Filtered, Property.Shared);
/**
* cloud.aws.protocol: Protocol for AWS API: http or https. Defaults to https. Shared with repository-s3 plugin
*/
Setting PROTOCOL_SETTING = new Setting<>("cloud.aws.protocol", "https", s -> Protocol.valueOf(s.toUpperCase(Locale.ROOT)),
- Property.NodeScope);
+ Property.NodeScope, Property.Shared);
/**
* cloud.aws.proxy.host: In case of proxy, define its hostname/IP. Shared with repository-s3 plugin
*/
- Setting PROXY_HOST_SETTING = Setting.simpleString("cloud.aws.proxy.host", Property.NodeScope);
+ Setting PROXY_HOST_SETTING = Setting.simpleString("cloud.aws.proxy.host", Property.NodeScope, Property.Shared);
/**
* cloud.aws.proxy.port: In case of proxy, define its port. Defaults to 80. Shared with repository-s3 plugin
*/
- Setting PROXY_PORT_SETTING = Setting.intSetting("cloud.aws.proxy.port", 80, 0, 1<<16, Property.NodeScope);
+ Setting PROXY_PORT_SETTING = Setting.intSetting("cloud.aws.proxy.port", 80, 0, 1<<16, Property.NodeScope,
+ Property.Shared);
/**
* cloud.aws.proxy.username: In case of proxy with auth, define the username. Shared with repository-s3 plugin
*/
- Setting PROXY_USERNAME_SETTING = Setting.simpleString("cloud.aws.proxy.username", Property.NodeScope);
+ Setting PROXY_USERNAME_SETTING = Setting.simpleString("cloud.aws.proxy.username", Property.NodeScope, Property.Shared);
/**
* cloud.aws.proxy.password: In case of proxy with auth, define the password. Shared with repository-s3 plugin
*/
Setting PROXY_PASSWORD_SETTING =
- Setting.simpleString("cloud.aws.proxy.password", Property.NodeScope, Property.Filtered);
+ Setting.simpleString("cloud.aws.proxy.password", Property.NodeScope, Property.Filtered, Property.Shared);
/**
* cloud.aws.signer: If you are using an old AWS API version, you can define a Signer. Shared with repository-s3 plugin
*/
- Setting SIGNER_SETTING = Setting.simpleString("cloud.aws.signer", Property.NodeScope);
+ Setting SIGNER_SETTING = Setting.simpleString("cloud.aws.signer", Property.NodeScope, Property.Shared);
/**
* cloud.aws.region: Region. Shared with repository-s3 plugin
*/
Setting REGION_SETTING =
- new Setting<>("cloud.aws.region", "", s -> s.toLowerCase(Locale.ROOT), Property.NodeScope);
+ new Setting<>("cloud.aws.region", "", s -> s.toLowerCase(Locale.ROOT), Property.NodeScope, Property.Shared);
/**
* Defines specific ec2 settings starting with cloud.aws.ec2.
diff --git a/plugins/discovery-ec2/src/main/java/org/elasticsearch/plugin/discovery/ec2/Ec2DiscoveryPlugin.java b/plugins/discovery-ec2/src/main/java/org/elasticsearch/plugin/discovery/ec2/Ec2DiscoveryPlugin.java
index 21e31b9f076..6a61b610ba6 100644
--- a/plugins/discovery-ec2/src/main/java/org/elasticsearch/plugin/discovery/ec2/Ec2DiscoveryPlugin.java
+++ b/plugins/discovery-ec2/src/main/java/org/elasticsearch/plugin/discovery/ec2/Ec2DiscoveryPlugin.java
@@ -38,7 +38,9 @@ import org.elasticsearch.plugins.Plugin;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
+import java.util.List;
/**
*
@@ -104,48 +106,38 @@ public class Ec2DiscoveryPlugin extends Plugin {
discoveryModule.addUnicastHostProvider(EC2, AwsEc2UnicastHostsProvider.class);
}
- public void onModule(SettingsModule settingsModule) {
+ @Override
+ public List> getSettings() {
+ return Arrays.asList(
// Register global cloud aws settings: cloud.aws (might have been registered in ec2 plugin)
- registerSettingIfMissing(settingsModule, AwsEc2Service.KEY_SETTING);
- registerSettingIfMissing(settingsModule, AwsEc2Service.SECRET_SETTING);
- registerSettingIfMissing(settingsModule, AwsEc2Service.PROTOCOL_SETTING);
- registerSettingIfMissing(settingsModule, AwsEc2Service.PROXY_HOST_SETTING);
- registerSettingIfMissing(settingsModule, AwsEc2Service.PROXY_PORT_SETTING);
- registerSettingIfMissing(settingsModule, AwsEc2Service.PROXY_USERNAME_SETTING);
- registerSettingIfMissing(settingsModule, AwsEc2Service.PROXY_PASSWORD_SETTING);
- registerSettingIfMissing(settingsModule, AwsEc2Service.SIGNER_SETTING);
- registerSettingIfMissing(settingsModule, AwsEc2Service.REGION_SETTING);
-
+ AwsEc2Service.KEY_SETTING,
+ AwsEc2Service.SECRET_SETTING,
+ AwsEc2Service.PROTOCOL_SETTING,
+ AwsEc2Service.PROXY_HOST_SETTING,
+ AwsEc2Service.PROXY_PORT_SETTING,
+ AwsEc2Service.PROXY_USERNAME_SETTING,
+ AwsEc2Service.PROXY_PASSWORD_SETTING,
+ AwsEc2Service.SIGNER_SETTING,
+ AwsEc2Service.REGION_SETTING,
// Register EC2 specific settings: cloud.aws.ec2
- settingsModule.registerSetting(AwsEc2Service.CLOUD_EC2.KEY_SETTING);
- settingsModule.registerSetting(AwsEc2Service.CLOUD_EC2.SECRET_SETTING);
- settingsModule.registerSetting(AwsEc2Service.CLOUD_EC2.PROTOCOL_SETTING);
- settingsModule.registerSetting(AwsEc2Service.CLOUD_EC2.PROXY_HOST_SETTING);
- settingsModule.registerSetting(AwsEc2Service.CLOUD_EC2.PROXY_PORT_SETTING);
- settingsModule.registerSetting(AwsEc2Service.CLOUD_EC2.PROXY_USERNAME_SETTING);
- settingsModule.registerSetting(AwsEc2Service.CLOUD_EC2.PROXY_PASSWORD_SETTING);
- settingsModule.registerSetting(AwsEc2Service.CLOUD_EC2.SIGNER_SETTING);
- settingsModule.registerSetting(AwsEc2Service.CLOUD_EC2.REGION_SETTING);
- settingsModule.registerSetting(AwsEc2Service.CLOUD_EC2.ENDPOINT_SETTING);
-
+ AwsEc2Service.CLOUD_EC2.KEY_SETTING,
+ AwsEc2Service.CLOUD_EC2.SECRET_SETTING,
+ AwsEc2Service.CLOUD_EC2.PROTOCOL_SETTING,
+ AwsEc2Service.CLOUD_EC2.PROXY_HOST_SETTING,
+ AwsEc2Service.CLOUD_EC2.PROXY_PORT_SETTING,
+ AwsEc2Service.CLOUD_EC2.PROXY_USERNAME_SETTING,
+ AwsEc2Service.CLOUD_EC2.PROXY_PASSWORD_SETTING,
+ AwsEc2Service.CLOUD_EC2.SIGNER_SETTING,
+ AwsEc2Service.CLOUD_EC2.REGION_SETTING,
+ AwsEc2Service.CLOUD_EC2.ENDPOINT_SETTING,
// Register EC2 discovery settings: discovery.ec2
- settingsModule.registerSetting(AwsEc2Service.DISCOVERY_EC2.HOST_TYPE_SETTING);
- settingsModule.registerSetting(AwsEc2Service.DISCOVERY_EC2.ANY_GROUP_SETTING);
- settingsModule.registerSetting(AwsEc2Service.DISCOVERY_EC2.GROUPS_SETTING);
- settingsModule.registerSetting(AwsEc2Service.DISCOVERY_EC2.AVAILABILITY_ZONES_SETTING);
- settingsModule.registerSetting(AwsEc2Service.DISCOVERY_EC2.NODE_CACHE_TIME_SETTING);
- settingsModule.registerSetting(AwsEc2Service.DISCOVERY_EC2.TAG_SETTING);
-
+ AwsEc2Service.DISCOVERY_EC2.HOST_TYPE_SETTING,
+ AwsEc2Service.DISCOVERY_EC2.ANY_GROUP_SETTING,
+ AwsEc2Service.DISCOVERY_EC2.GROUPS_SETTING,
+ AwsEc2Service.DISCOVERY_EC2.AVAILABILITY_ZONES_SETTING,
+ AwsEc2Service.DISCOVERY_EC2.NODE_CACHE_TIME_SETTING,
+ AwsEc2Service.DISCOVERY_EC2.TAG_SETTING,
// Register cloud node settings: cloud.node
- settingsModule.registerSetting(AwsEc2Service.AUTO_ATTRIBUTE_SETTING);
- }
-
- /**
- * We manage potential duplicates between s3 and ec2 plugins (cloud.aws.xxx)
- */
- private void registerSettingIfMissing(SettingsModule settingsModule, Setting> setting) {
- if (settingsModule.exists(setting) == false) {
- settingsModule.registerSetting(setting);
- }
+ AwsEc2Service.AUTO_ATTRIBUTE_SETTING);
}
}
diff --git a/plugins/discovery-gce/src/main/java/org/elasticsearch/plugin/discovery/gce/GceDiscoveryPlugin.java b/plugins/discovery-gce/src/main/java/org/elasticsearch/plugin/discovery/gce/GceDiscoveryPlugin.java
index 2b92c4fd8c1..c48a8b409e5 100644
--- a/plugins/discovery-gce/src/main/java/org/elasticsearch/plugin/discovery/gce/GceDiscoveryPlugin.java
+++ b/plugins/discovery-gce/src/main/java/org/elasticsearch/plugin/discovery/gce/GceDiscoveryPlugin.java
@@ -28,6 +28,7 @@ import org.elasticsearch.common.component.LifecycleComponent;
import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
+import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.discovery.DiscoveryModule;
@@ -37,8 +38,10 @@ import org.elasticsearch.plugins.Plugin;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
public class GceDiscoveryPlugin extends Plugin {
@@ -100,13 +103,15 @@ public class GceDiscoveryPlugin extends Plugin {
discoveryModule.addUnicastHostProvider(GCE, GceUnicastHostsProvider.class);
}
- public void onModule(SettingsModule settingsModule) {
+ @Override
+ public List> getSettings() {
+ return Arrays.asList(
// Register GCE settings
- settingsModule.registerSetting(GceComputeService.PROJECT_SETTING);
- settingsModule.registerSetting(GceComputeService.ZONE_SETTING);
- settingsModule.registerSetting(GceUnicastHostsProvider.TAGS_SETTING);
- settingsModule.registerSetting(GceComputeService.REFRESH_SETTING);
- settingsModule.registerSetting(GceComputeService.RETRY_SETTING);
- settingsModule.registerSetting(GceComputeService.MAX_WAIT_SETTING);
+ GceComputeService.PROJECT_SETTING,
+ GceComputeService.ZONE_SETTING,
+ GceUnicastHostsProvider.TAGS_SETTING,
+ GceComputeService.REFRESH_SETTING,
+ GceComputeService.RETRY_SETTING,
+ GceComputeService.MAX_WAIT_SETTING);
}
}
diff --git a/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java b/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java
index f6a850d1d23..0b977d7896e 100644
--- a/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java
+++ b/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java
@@ -28,6 +28,7 @@ import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.io.FileSystemUtils;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
+import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.plugin.discovery.gce.GceDiscoveryPlugin;
@@ -48,6 +49,7 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.KeyStore;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -74,10 +76,10 @@ public class GceDiscoverTests extends ESIntegTestCase {
return "GceDiscoverTests";
}
- public void onModule(SettingsModule module) {
- module.registerSetting(GceComputeServiceImpl.GCE_HOST);
- module.registerSetting(GceComputeServiceImpl.GCE_ROOT_URL);
- module.registerSetting(GceComputeServiceImpl.GCE_VALIDATE_CERTIFICATES);
+ @Override
+ public List> getSettings() {
+ return Arrays.asList(GceComputeServiceImpl.GCE_HOST, GceComputeServiceImpl.GCE_ROOT_URL,
+ GceComputeServiceImpl.GCE_VALIDATE_CERTIFICATES);
}
}
diff --git a/plugins/mapper-attachments/src/main/java/org/elasticsearch/mapper/attachments/MapperAttachmentsPlugin.java b/plugins/mapper-attachments/src/main/java/org/elasticsearch/mapper/attachments/MapperAttachmentsPlugin.java
index 7a77510447d..13f10fcdbe0 100644
--- a/plugins/mapper-attachments/src/main/java/org/elasticsearch/mapper/attachments/MapperAttachmentsPlugin.java
+++ b/plugins/mapper-attachments/src/main/java/org/elasticsearch/mapper/attachments/MapperAttachmentsPlugin.java
@@ -22,10 +22,14 @@ package org.elasticsearch.mapper.attachments;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.ESLoggerFactory;
+import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.indices.IndicesModule;
import org.elasticsearch.plugins.Plugin;
+import java.util.Arrays;
+import java.util.List;
+
public class MapperAttachmentsPlugin extends Plugin {
@@ -42,11 +46,13 @@ public class MapperAttachmentsPlugin extends Plugin {
return "Adds the attachment type allowing to parse difference attachment formats";
}
- public void onModule(SettingsModule settingsModule) {
+ @Override
+ public List> getSettings() {
deprecationLogger.deprecated("[mapper-attachments] plugin has been deprecated and will be replaced by [ingest-attachment] plugin.");
- settingsModule.registerSetting(AttachmentMapper.INDEX_ATTACHMENT_DETECT_LANGUAGE_SETTING);
- settingsModule.registerSetting(AttachmentMapper.INDEX_ATTACHMENT_IGNORE_ERRORS_SETTING);
- settingsModule.registerSetting(AttachmentMapper.INDEX_ATTACHMENT_INDEXED_CHARS_SETTING);
+
+ return Arrays.asList(AttachmentMapper.INDEX_ATTACHMENT_DETECT_LANGUAGE_SETTING,
+ AttachmentMapper.INDEX_ATTACHMENT_IGNORE_ERRORS_SETTING,
+ AttachmentMapper.INDEX_ATTACHMENT_INDEXED_CHARS_SETTING);
}
public void onModule(IndicesModule indicesModule) {
diff --git a/plugins/repository-azure/src/main/java/org/elasticsearch/plugin/repository/azure/AzureRepositoryPlugin.java b/plugins/repository-azure/src/main/java/org/elasticsearch/plugin/repository/azure/AzureRepositoryPlugin.java
index 3ce043500ae..f3e0c267ada 100644
--- a/plugins/repository-azure/src/main/java/org/elasticsearch/plugin/repository/azure/AzureRepositoryPlugin.java
+++ b/plugins/repository-azure/src/main/java/org/elasticsearch/plugin/repository/azure/AzureRepositoryPlugin.java
@@ -24,6 +24,7 @@ import org.elasticsearch.cloud.azure.storage.AzureStorageService;
import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
+import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardRepository;
@@ -31,8 +32,10 @@ import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.repositories.RepositoriesModule;
import org.elasticsearch.repositories.azure.AzureRepository;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
/**
*
@@ -67,16 +70,20 @@ public class AzureRepositoryPlugin extends Plugin {
module.registerRepository(AzureRepository.TYPE, AzureRepository.class, BlobStoreIndexShardRepository.class);
}
- public void onModule(SettingsModule module) {
- module.registerSetting(AzureStorageService.Storage.ACCOUNT_SETTING);
- module.registerSetting(AzureStorageService.Storage.COMPRESS_SETTING);
- module.registerSetting(AzureStorageService.Storage.CONTAINER_SETTING);
- module.registerSetting(AzureStorageService.Storage.BASE_PATH_SETTING);
- module.registerSetting(AzureStorageService.Storage.CHUNK_SIZE_SETTING);
- module.registerSetting(AzureStorageService.Storage.LOCATION_MODE_SETTING);
+ @Override
+ public List> getSettings() {
+ return Arrays.asList(AzureStorageService.Storage.ACCOUNT_SETTING,
+ AzureStorageService.Storage.COMPRESS_SETTING,
+ AzureStorageService.Storage.CONTAINER_SETTING,
+ AzureStorageService.Storage.BASE_PATH_SETTING,
+ AzureStorageService.Storage.CHUNK_SIZE_SETTING,
+ AzureStorageService.Storage.LOCATION_MODE_SETTING);
+ }
+
+ @Override
+ public List getSettingsFilter() {
// Cloud storage API settings using a pattern needed to be hidden
- module.registerSettingsFilter(AzureStorageService.Storage.PREFIX + "*.account");
- module.registerSettingsFilter(AzureStorageService.Storage.PREFIX + "*.key");
+ return Arrays.asList(AzureStorageService.Storage.PREFIX + "*.account", AzureStorageService.Storage.PREFIX + "*.key");
}
}
diff --git a/plugins/repository-azure/src/test/java/org/elasticsearch/cloud/azure/storage/AzureStorageSettingsFilterTests.java b/plugins/repository-azure/src/test/java/org/elasticsearch/cloud/azure/storage/AzureStorageSettingsFilterTests.java
index 6f215069564..db3bd617da4 100644
--- a/plugins/repository-azure/src/test/java/org/elasticsearch/cloud/azure/storage/AzureStorageSettingsFilterTests.java
+++ b/plugins/repository-azure/src/test/java/org/elasticsearch/cloud/azure/storage/AzureStorageSettingsFilterTests.java
@@ -47,8 +47,7 @@ public class AzureStorageSettingsFilterTests extends ESTestCase {
public void testSettingsFiltering() throws IOException {
AzureRepositoryPlugin p = new AzureRepositoryPlugin(Settings.EMPTY);
- SettingsModule module = new SettingsModule(Settings.EMPTY);
- p.onModule(module);
+ SettingsModule module = new SettingsModule(Settings.EMPTY, p.getSettings(), p.getSettingsFilter());
SettingsFilter settingsFilter = ModuleTestCase.bindAndGetInstance(module, SettingsFilter.class);
// Test using direct filtering
diff --git a/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/AwsS3Service.java b/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/AwsS3Service.java
index 427c454fa28..87c37b52e72 100644
--- a/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/AwsS3Service.java
+++ b/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/AwsS3Service.java
@@ -40,43 +40,44 @@ public interface AwsS3Service extends LifecycleComponent {
* cloud.aws.access_key: AWS Access key. Shared with discovery-ec2 plugin
*/
Setting KEY_SETTING =
- Setting.simpleString("cloud.aws.access_key", Property.NodeScope, Property.Filtered);
+ Setting.simpleString("cloud.aws.access_key", Property.NodeScope, Property.Filtered, Property.Shared);
/**
* cloud.aws.secret_key: AWS Secret key. Shared with discovery-ec2 plugin
*/
Setting SECRET_SETTING =
- Setting.simpleString("cloud.aws.secret_key", Property.NodeScope, Property.Filtered);
+ Setting.simpleString("cloud.aws.secret_key", Property.NodeScope, Property.Filtered, Property.Shared);
/**
* cloud.aws.protocol: Protocol for AWS API: http or https. Defaults to https. Shared with discovery-ec2 plugin
*/
Setting PROTOCOL_SETTING = new Setting<>("cloud.aws.protocol", "https", s -> Protocol.valueOf(s.toUpperCase(Locale.ROOT)),
- Property.NodeScope);
+ Property.NodeScope, Property.Shared);
/**
* cloud.aws.proxy.host: In case of proxy, define its hostname/IP. Shared with discovery-ec2 plugin
*/
- Setting PROXY_HOST_SETTING = Setting.simpleString("cloud.aws.proxy.host", Property.NodeScope);
+ Setting PROXY_HOST_SETTING = Setting.simpleString("cloud.aws.proxy.host", Property.NodeScope, Property.Shared);
/**
* cloud.aws.proxy.port: In case of proxy, define its port. Defaults to 80. Shared with discovery-ec2 plugin
*/
- Setting PROXY_PORT_SETTING = Setting.intSetting("cloud.aws.proxy.port", 80, 0, 1<<16, Property.NodeScope);
+ Setting PROXY_PORT_SETTING = Setting.intSetting("cloud.aws.proxy.port", 80, 0, 1<<16, Property.NodeScope,
+ Property.Shared);
/**
* cloud.aws.proxy.username: In case of proxy with auth, define the username. Shared with discovery-ec2 plugin
*/
- Setting PROXY_USERNAME_SETTING = Setting.simpleString("cloud.aws.proxy.username", Property.NodeScope);
+ Setting PROXY_USERNAME_SETTING = Setting.simpleString("cloud.aws.proxy.username", Property.NodeScope, Property.Shared);
/**
* cloud.aws.proxy.password: In case of proxy with auth, define the password. Shared with discovery-ec2 plugin
*/
Setting PROXY_PASSWORD_SETTING =
- Setting.simpleString("cloud.aws.proxy.password", Property.NodeScope, Property.Filtered);
+ Setting.simpleString("cloud.aws.proxy.password", Property.NodeScope, Property.Filtered, Property.Shared);
/**
* cloud.aws.signer: If you are using an old AWS API version, you can define a Signer. Shared with discovery-ec2 plugin
*/
- Setting SIGNER_SETTING = Setting.simpleString("cloud.aws.signer", Property.NodeScope);
+ Setting SIGNER_SETTING = Setting.simpleString("cloud.aws.signer", Property.NodeScope, Property.Shared);
/**
* cloud.aws.region: Region. Shared with discovery-ec2 plugin
*/
Setting REGION_SETTING =
- new Setting<>("cloud.aws.region", "", s -> s.toLowerCase(Locale.ROOT), Property.NodeScope);
+ new Setting<>("cloud.aws.region", "", s -> s.toLowerCase(Locale.ROOT), Property.NodeScope, Property.Shared);
/**
* Defines specific s3 settings starting with cloud.aws.s3.
diff --git a/plugins/repository-s3/src/main/java/org/elasticsearch/plugin/repository/s3/S3RepositoryPlugin.java b/plugins/repository-s3/src/main/java/org/elasticsearch/plugin/repository/s3/S3RepositoryPlugin.java
index d07d8c174c5..6d02e149530 100644
--- a/plugins/repository-s3/src/main/java/org/elasticsearch/plugin/repository/s3/S3RepositoryPlugin.java
+++ b/plugins/repository-s3/src/main/java/org/elasticsearch/plugin/repository/s3/S3RepositoryPlugin.java
@@ -34,8 +34,10 @@ import org.elasticsearch.repositories.s3.S3Repository;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
/**
*
@@ -89,69 +91,61 @@ public class S3RepositoryPlugin extends Plugin {
repositoriesModule.registerRepository(S3Repository.TYPE, S3Repository.class, BlobStoreIndexShardRepository.class);
}
- public void onModule(SettingsModule settingsModule) {
- // Register global cloud aws settings: cloud.aws (might have been registered in ec2 plugin)
- registerSettingIfMissing(settingsModule, AwsS3Service.KEY_SETTING);
- registerSettingIfMissing(settingsModule, AwsS3Service.SECRET_SETTING);
- registerSettingIfMissing(settingsModule, AwsS3Service.PROTOCOL_SETTING);
- registerSettingIfMissing(settingsModule, AwsS3Service.PROXY_HOST_SETTING);
- registerSettingIfMissing(settingsModule, AwsS3Service.PROXY_PORT_SETTING);
- registerSettingIfMissing(settingsModule, AwsS3Service.PROXY_USERNAME_SETTING);
- registerSettingIfMissing(settingsModule, AwsS3Service.PROXY_PASSWORD_SETTING);
- registerSettingIfMissing(settingsModule, AwsS3Service.SIGNER_SETTING);
- registerSettingIfMissing(settingsModule, AwsS3Service.REGION_SETTING);
+ @Override
+ public List> getSettings() {
+ return Arrays.asList( // Register global cloud aws settings: cloud.aws (might have been registered in ec2 plugin)
+ AwsS3Service.KEY_SETTING,
+ AwsS3Service.SECRET_SETTING,
+ AwsS3Service.PROTOCOL_SETTING,
+ AwsS3Service.PROXY_HOST_SETTING,
+ AwsS3Service.PROXY_PORT_SETTING,
+ AwsS3Service.PROXY_USERNAME_SETTING,
+ AwsS3Service.PROXY_PASSWORD_SETTING,
+ AwsS3Service.SIGNER_SETTING,
+ AwsS3Service.REGION_SETTING,
// Register S3 specific settings: cloud.aws.s3
- settingsModule.registerSetting(AwsS3Service.CLOUD_S3.KEY_SETTING);
- settingsModule.registerSetting(AwsS3Service.CLOUD_S3.SECRET_SETTING);
- settingsModule.registerSetting(AwsS3Service.CLOUD_S3.PROTOCOL_SETTING);
- settingsModule.registerSetting(AwsS3Service.CLOUD_S3.PROXY_HOST_SETTING);
- settingsModule.registerSetting(AwsS3Service.CLOUD_S3.PROXY_PORT_SETTING);
- settingsModule.registerSetting(AwsS3Service.CLOUD_S3.PROXY_USERNAME_SETTING);
- settingsModule.registerSetting(AwsS3Service.CLOUD_S3.PROXY_PASSWORD_SETTING);
- settingsModule.registerSetting(AwsS3Service.CLOUD_S3.SIGNER_SETTING);
- settingsModule.registerSetting(AwsS3Service.CLOUD_S3.REGION_SETTING);
- settingsModule.registerSetting(AwsS3Service.CLOUD_S3.ENDPOINT_SETTING);
+ AwsS3Service.CLOUD_S3.KEY_SETTING,
+ AwsS3Service.CLOUD_S3.SECRET_SETTING,
+ AwsS3Service.CLOUD_S3.PROTOCOL_SETTING,
+ AwsS3Service.CLOUD_S3.PROXY_HOST_SETTING,
+ AwsS3Service.CLOUD_S3.PROXY_PORT_SETTING,
+ AwsS3Service.CLOUD_S3.PROXY_USERNAME_SETTING,
+ AwsS3Service.CLOUD_S3.PROXY_PASSWORD_SETTING,
+ AwsS3Service.CLOUD_S3.SIGNER_SETTING,
+ AwsS3Service.CLOUD_S3.REGION_SETTING,
+ AwsS3Service.CLOUD_S3.ENDPOINT_SETTING,
// Register S3 repositories settings: repositories.s3
- settingsModule.registerSetting(S3Repository.Repositories.KEY_SETTING);
- settingsModule.registerSetting(S3Repository.Repositories.SECRET_SETTING);
- settingsModule.registerSetting(S3Repository.Repositories.BUCKET_SETTING);
- settingsModule.registerSetting(S3Repository.Repositories.REGION_SETTING);
- settingsModule.registerSetting(S3Repository.Repositories.ENDPOINT_SETTING);
- settingsModule.registerSetting(S3Repository.Repositories.PROTOCOL_SETTING);
- settingsModule.registerSetting(S3Repository.Repositories.SERVER_SIDE_ENCRYPTION_SETTING);
- settingsModule.registerSetting(S3Repository.Repositories.BUFFER_SIZE_SETTING);
- settingsModule.registerSetting(S3Repository.Repositories.MAX_RETRIES_SETTING);
- settingsModule.registerSetting(S3Repository.Repositories.CHUNK_SIZE_SETTING);
- settingsModule.registerSetting(S3Repository.Repositories.COMPRESS_SETTING);
- settingsModule.registerSetting(S3Repository.Repositories.STORAGE_CLASS_SETTING);
- settingsModule.registerSetting(S3Repository.Repositories.CANNED_ACL_SETTING);
- settingsModule.registerSetting(S3Repository.Repositories.BASE_PATH_SETTING);
+ S3Repository.Repositories.KEY_SETTING,
+ S3Repository.Repositories.SECRET_SETTING,
+ S3Repository.Repositories.BUCKET_SETTING,
+ S3Repository.Repositories.REGION_SETTING,
+ S3Repository.Repositories.ENDPOINT_SETTING,
+ S3Repository.Repositories.PROTOCOL_SETTING,
+ S3Repository.Repositories.SERVER_SIDE_ENCRYPTION_SETTING,
+ S3Repository.Repositories.BUFFER_SIZE_SETTING,
+ S3Repository.Repositories.MAX_RETRIES_SETTING,
+ S3Repository.Repositories.CHUNK_SIZE_SETTING,
+ S3Repository.Repositories.COMPRESS_SETTING,
+ S3Repository.Repositories.STORAGE_CLASS_SETTING,
+ S3Repository.Repositories.CANNED_ACL_SETTING,
+ S3Repository.Repositories.BASE_PATH_SETTING,
// Register S3 single repository settings
- settingsModule.registerSetting(S3Repository.Repository.KEY_SETTING);
- settingsModule.registerSetting(S3Repository.Repository.SECRET_SETTING);
- settingsModule.registerSetting(S3Repository.Repository.BUCKET_SETTING);
- settingsModule.registerSetting(S3Repository.Repository.ENDPOINT_SETTING);
- settingsModule.registerSetting(S3Repository.Repository.PROTOCOL_SETTING);
- settingsModule.registerSetting(S3Repository.Repository.REGION_SETTING);
- settingsModule.registerSetting(S3Repository.Repository.SERVER_SIDE_ENCRYPTION_SETTING);
- settingsModule.registerSetting(S3Repository.Repository.BUFFER_SIZE_SETTING);
- settingsModule.registerSetting(S3Repository.Repository.MAX_RETRIES_SETTING);
- settingsModule.registerSetting(S3Repository.Repository.CHUNK_SIZE_SETTING);
- settingsModule.registerSetting(S3Repository.Repository.COMPRESS_SETTING);
- settingsModule.registerSetting(S3Repository.Repository.STORAGE_CLASS_SETTING);
- settingsModule.registerSetting(S3Repository.Repository.CANNED_ACL_SETTING);
- settingsModule.registerSetting(S3Repository.Repository.BASE_PATH_SETTING);
- }
-
- /**
- * We manage potential duplicates between s3 and ec2 plugins (cloud.aws.xxx)
- */
- private void registerSettingIfMissing(SettingsModule settingsModule, Setting> setting) {
- if (settingsModule.exists(setting) == false) {
- settingsModule.registerSetting(setting);
- }
+ S3Repository.Repository.KEY_SETTING,
+ S3Repository.Repository.SECRET_SETTING,
+ S3Repository.Repository.BUCKET_SETTING,
+ S3Repository.Repository.ENDPOINT_SETTING,
+ S3Repository.Repository.PROTOCOL_SETTING,
+ S3Repository.Repository.REGION_SETTING,
+ S3Repository.Repository.SERVER_SIDE_ENCRYPTION_SETTING,
+ S3Repository.Repository.BUFFER_SIZE_SETTING,
+ S3Repository.Repository.MAX_RETRIES_SETTING,
+ S3Repository.Repository.CHUNK_SIZE_SETTING,
+ S3Repository.Repository.COMPRESS_SETTING,
+ S3Repository.Repository.STORAGE_CLASS_SETTING,
+ S3Repository.Repository.CANNED_ACL_SETTING,
+ S3Repository.Repository.BASE_PATH_SETTING);
}
}
diff --git a/test/framework/src/main/java/org/elasticsearch/index/MockEngineFactoryPlugin.java b/test/framework/src/main/java/org/elasticsearch/index/MockEngineFactoryPlugin.java
index 3c72701f214..5b6c150b729 100644
--- a/test/framework/src/main/java/org/elasticsearch/index/MockEngineFactoryPlugin.java
+++ b/test/framework/src/main/java/org/elasticsearch/index/MockEngineFactoryPlugin.java
@@ -22,13 +22,16 @@ import org.apache.lucene.index.AssertingDirectoryReader;
import org.apache.lucene.index.FilterDirectoryReader;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.Module;
+import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.engine.MockEngineFactory;
import org.elasticsearch.test.engine.MockEngineSupport;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
// this must exist in the same package as IndexModule to allow access to setting the impl
public class MockEngineFactoryPlugin extends Plugin {
@@ -43,9 +46,9 @@ public class MockEngineFactoryPlugin extends Plugin {
private Class extends FilterDirectoryReader> readerWrapper = AssertingDirectoryReader.class;
- public void onModule(SettingsModule module) {
- module.registerSetting(MockEngineSupport.DISABLE_FLUSH_ON_CLOSE);
- module.registerSetting(MockEngineSupport.WRAP_READER_RATIO);
+ @Override
+ public List> getSettings() {
+ return Arrays.asList(MockEngineSupport.DISABLE_FLUSH_ON_CLOSE, MockEngineSupport.WRAP_READER_RATIO);
}
@Override
diff --git a/test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java
index 34e673ac126..9200662d6e4 100644
--- a/test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java
+++ b/test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java
@@ -60,6 +60,7 @@ import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.settings.IndexScopedSettings;
+import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.common.unit.Fuzziness;
@@ -108,7 +109,6 @@ import org.elasticsearch.script.ScriptSettings;
import org.elasticsearch.search.SearchModule;
import org.elasticsearch.search.internal.SearchContext;
import org.elasticsearch.threadpool.ThreadPool;
-import org.elasticsearch.threadpool.ThreadPoolModule;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.junit.After;
@@ -880,15 +880,16 @@ public abstract class AbstractQueryTestCase>
Environment env = InternalSettingsPreparer.prepareEnvironment(settings, null);
PluginsService pluginsService =new PluginsService(settings, env.modulesFile(), env.pluginsFile(), plugins);
- SettingsModule settingsModule = new SettingsModule(settings);
- settingsModule.registerSetting(InternalSettingsPlugin.VERSION_CREATED);
final Client proxy = (Client) Proxy.newProxyInstance(
Client.class.getClassLoader(),
new Class[]{Client.class},
clientInvocationHandler);
NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry();
ScriptModule scriptModule = newTestScriptModule();
- scriptModule.prepareSettings(settingsModule);
+ List> scriptSettings = scriptModule.getSettings();
+ scriptSettings.addAll(pluginsService.getPluginSettings());
+ scriptSettings.add(InternalSettingsPlugin.VERSION_CREATED);
+ SettingsModule settingsModule = new SettingsModule(settings, scriptSettings, pluginsService.getPluginSettingsFilter());
searchModule = new SearchModule(settings, namedWriteableRegistry) {
@Override
protected void configureSearch() {
@@ -901,9 +902,8 @@ public abstract class AbstractQueryTestCase>
}
modulesBuilder.add(new PluginsModule(pluginsService));
modulesBuilder.add(
- new EnvironmentModule(new Environment(settings)),
+ new EnvironmentModule(new Environment(settings), threadPool),
settingsModule,
- new ThreadPoolModule(threadPool),
new IndicesModule() {
@Override
public void configure() {
diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java
index 4e066bc7635..5480e1549cf 100644
--- a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java
+++ b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java
@@ -1806,8 +1806,9 @@ public abstract class ESIntegTestCase extends ESTestCase {
public String description() {
return "a test plugin that registers index.tests.seed as an index setting";
}
- public void onModule(SettingsModule module) {
- module.registerSetting(INDEX_TEST_SEED_SETTING);
+ @Override
+ public List> getSettings() {
+ return Arrays.asList(INDEX_TEST_SEED_SETTING);
}
}
diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java
index 727ea93a659..e0ae77d3f56 100644
--- a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java
+++ b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java
@@ -773,8 +773,7 @@ public abstract class ESTestCase extends LuceneTestCase {
for (Consumer consumer : moduleConsumers) {
consumer.accept(analysisModule);
}
- SettingsModule settingsModule = new SettingsModule(nodeSettings);
- settingsModule.registerSetting(InternalSettingsPlugin.VERSION_CREATED);
+ SettingsModule settingsModule = new SettingsModule(nodeSettings, InternalSettingsPlugin.VERSION_CREATED);
final AnalysisService analysisService = analysisModule.buildRegistry().build(IndexSettingsModule.newIndexSettings(index, indexSettings));
return analysisService;
}
diff --git a/test/framework/src/main/java/org/elasticsearch/test/InternalSettingsPlugin.java b/test/framework/src/main/java/org/elasticsearch/test/InternalSettingsPlugin.java
index f76ae7b4b56..c7b86a6ac13 100644
--- a/test/framework/src/main/java/org/elasticsearch/test/InternalSettingsPlugin.java
+++ b/test/framework/src/main/java/org/elasticsearch/test/InternalSettingsPlugin.java
@@ -24,6 +24,9 @@ import org.elasticsearch.common.settings.Setting.Property;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.plugins.Plugin;
+import java.util.Arrays;
+import java.util.List;
+
public final class InternalSettingsPlugin extends Plugin {
@Override
public String name() {
@@ -42,9 +45,8 @@ public final class InternalSettingsPlugin extends Plugin {
public static final Setting INDEX_CREATION_DATE_SETTING =
Setting.longSetting(IndexMetaData.SETTING_CREATION_DATE, -1, -1, Property.IndexScope, Property.NodeScope);
- public void onModule(SettingsModule module) {
- module.registerSetting(VERSION_CREATED);
- module.registerSetting(MERGE_ENABLED);
- module.registerSetting(INDEX_CREATION_DATE_SETTING);
+ @Override
+ public List> getSettings() {
+ return Arrays.asList(VERSION_CREATED, MERGE_ENABLED, INDEX_CREATION_DATE_SETTING);
}
}
diff --git a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java
index 0dee5f75948..66f02c8a376 100644
--- a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java
+++ b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java
@@ -1940,7 +1940,7 @@ public final class InternalTestCluster extends TestCluster {
private void assertRequestsFinished() {
if (size() > 0) {
for (NodeAndClient nodeAndClient : nodes.values()) {
- CircuitBreaker inFlightRequestsBreaker = getInstance(HierarchyCircuitBreakerService.class, nodeAndClient.name)
+ CircuitBreaker inFlightRequestsBreaker = getInstance(CircuitBreakerService.class, nodeAndClient.name)
.getBreaker(CircuitBreaker.IN_FLIGHT_REQUESTS);
try {
// see #ensureEstimatedStats()
diff --git a/test/framework/src/main/java/org/elasticsearch/test/MockIndexEventListener.java b/test/framework/src/main/java/org/elasticsearch/test/MockIndexEventListener.java
index f17fe024f14..4cf224c4544 100644
--- a/test/framework/src/main/java/org/elasticsearch/test/MockIndexEventListener.java
+++ b/test/framework/src/main/java/org/elasticsearch/test/MockIndexEventListener.java
@@ -34,8 +34,10 @@ import org.elasticsearch.index.shard.IndexShardState;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.plugins.Plugin;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
/**
* This is a testing plugin that registers a generic {@link org.elasticsearch.test.MockIndexEventListener.TestEventListener} as a node level service as well as a listener
@@ -65,8 +67,9 @@ public final class MockIndexEventListener {
* For tests to pass in to fail on listener invocation
*/
public static final Setting INDEX_FAIL = Setting.boolSetting("index.fail", false, Property.IndexScope);
- public void onModule(SettingsModule module) {
- module.registerSetting(INDEX_FAIL);
+ @Override
+ public List> getSettings() {
+ return Arrays.asList(INDEX_FAIL);
}
@Override
diff --git a/test/framework/src/main/java/org/elasticsearch/test/store/MockFSIndexStore.java b/test/framework/src/main/java/org/elasticsearch/test/store/MockFSIndexStore.java
index d44cf60e9e3..34dd613fb0c 100644
--- a/test/framework/src/main/java/org/elasticsearch/test/store/MockFSIndexStore.java
+++ b/test/framework/src/main/java/org/elasticsearch/test/store/MockFSIndexStore.java
@@ -38,9 +38,11 @@ import org.elasticsearch.index.store.IndexStore;
import org.elasticsearch.index.store.IndexStoreConfig;
import org.elasticsearch.plugins.Plugin;
+import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.IdentityHashMap;
+import java.util.List;
import java.util.Map;
public class MockFSIndexStore extends IndexStore {
@@ -62,14 +64,14 @@ public class MockFSIndexStore extends IndexStore {
return Settings.builder().put(IndexModule.INDEX_STORE_TYPE_SETTING.getKey(), "mock").build();
}
- public void onModule(SettingsModule module) {
-
- module.registerSetting(INDEX_CHECK_INDEX_ON_CLOSE_SETTING);
- module.registerSetting(MockFSDirectoryService.CRASH_INDEX_SETTING);
- module.registerSetting(MockFSDirectoryService.RANDOM_IO_EXCEPTION_RATE_SETTING);
- module.registerSetting(MockFSDirectoryService.RANDOM_PREVENT_DOUBLE_WRITE_SETTING);
- module.registerSetting(MockFSDirectoryService.RANDOM_NO_DELETE_OPEN_FILE_SETTING);
- module.registerSetting(MockFSDirectoryService.RANDOM_IO_EXCEPTION_RATE_ON_OPEN_SETTING);
+ @Override
+ public List> getSettings() {
+ return Arrays.asList(INDEX_CHECK_INDEX_ON_CLOSE_SETTING,
+ MockFSDirectoryService.CRASH_INDEX_SETTING,
+ MockFSDirectoryService.RANDOM_IO_EXCEPTION_RATE_SETTING,
+ MockFSDirectoryService.RANDOM_PREVENT_DOUBLE_WRITE_SETTING,
+ MockFSDirectoryService.RANDOM_NO_DELETE_OPEN_FILE_SETTING,
+ MockFSDirectoryService.RANDOM_IO_EXCEPTION_RATE_ON_OPEN_SETTING);
}
@Override
diff --git a/test/framework/src/main/java/org/elasticsearch/test/transport/AssertingLocalTransport.java b/test/framework/src/main/java/org/elasticsearch/test/transport/AssertingLocalTransport.java
index a9687c27873..3b63eadcc0c 100644
--- a/test/framework/src/main/java/org/elasticsearch/test/transport/AssertingLocalTransport.java
+++ b/test/framework/src/main/java/org/elasticsearch/test/transport/AssertingLocalTransport.java
@@ -42,6 +42,8 @@ import org.elasticsearch.transport.TransportResponseHandler;
import org.elasticsearch.transport.local.LocalTransport;
import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
import java.util.Random;
public class AssertingLocalTransport extends LocalTransport {
@@ -63,9 +65,9 @@ public class AssertingLocalTransport extends LocalTransport {
return Settings.builder().put(NetworkModule.TRANSPORT_TYPE_KEY, "mock").build();
}
- public void onModule(SettingsModule module) {
- module.registerSetting(ASSERTING_TRANSPORT_MIN_VERSION_KEY);
- module.registerSetting(ASSERTING_TRANSPORT_MAX_VERSION_KEY);
+ @Override
+ public List> getSettings() {
+ return Arrays.asList(ASSERTING_TRANSPORT_MIN_VERSION_KEY, ASSERTING_TRANSPORT_MAX_VERSION_KEY);
}
}
diff --git a/test/framework/src/main/java/org/elasticsearch/test/transport/MockTransportService.java b/test/framework/src/main/java/org/elasticsearch/test/transport/MockTransportService.java
index 05b8b23e90c..3df16d3bc0d 100644
--- a/test/framework/src/main/java/org/elasticsearch/test/transport/MockTransportService.java
+++ b/test/framework/src/main/java/org/elasticsearch/test/transport/MockTransportService.java
@@ -21,6 +21,7 @@ package org.elasticsearch.test.transport;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.ClusterName;
+import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.cluster.node.DiscoveryNode;
@@ -91,8 +92,9 @@ public class MockTransportService extends TransportService {
module.registerTransportService("mock", MockTransportService.class);
}
- public void onModule(SettingsModule module) {
- module.registerSetting(MockTaskManager.USE_MOCK_TASK_MANAGER_SETTING);
+ @Override
+ public List> getSettings() {
+ return Arrays.asList(MockTaskManager.USE_MOCK_TASK_MANAGER_SETTING);
}
@Override
public Settings additionalSettings() {