From 36ad326483bed89178a30e80909a4d844066ed1a Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Thu, 16 Jun 2016 09:35:16 +0200 Subject: [PATCH 1/2] Simplify ScriptModule and script registration elastic/elasticsearchelastic/elasticsearch#18903 (elastic/elasticsearch#2535) follow up PR for elastic/elasticsearchelastic/elasticsearch#18903 Original commit: elastic/x-pack-elasticsearch@d6ab3ab1413d30a48167cc60a940b818160b33c2 --- .../messy/tests/MessyTestUtils.java | 14 +++----------- .../smoketest/WatcherTemplateTests.java | 8 ++------ .../xpack/graph/test/GraphTests.java | 15 ++++++++++++--- .../org/elasticsearch/xpack/XPackPlugin.java | 10 +++++++--- .../org/elasticsearch/xpack/watcher/Watcher.java | 3 --- .../script/MockMustacheScriptEngine.java | 14 +++++++++----- .../elasticsearch/script/SleepScriptEngine.java | 16 ++++++++++------ .../xpack/watcher/test/WatcherTestUtils.java | 2 +- 8 files changed, 44 insertions(+), 38 deletions(-) diff --git a/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/MessyTestUtils.java b/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/MessyTestUtils.java index c4bbc2186b9..dee4d8ae66b 100644 --- a/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/MessyTestUtils.java +++ b/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/MessyTestUtils.java @@ -14,7 +14,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.script.ScriptContextRegistry; import org.elasticsearch.script.ScriptEngineRegistry; -import org.elasticsearch.script.ScriptEngineService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.script.ScriptSettings; import org.elasticsearch.script.groovy.GroovyScriptEngineService; @@ -25,8 +24,7 @@ import org.junit.Ignore; import org.mockito.Mockito; import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; +import java.util.Collections; @Ignore // not a test. @SuppressForbidden(reason = "gradle is broken and tries to run me as a test") @@ -38,19 +36,13 @@ public final class MessyTestUtils { .put("path.home", LuceneTestCase.createTempDir()) .build(); GroovyScriptEngineService groovyScriptEngineService = new GroovyScriptEngineService(settings); - Set engineServiceSet = new HashSet<>(); - engineServiceSet.add(groovyScriptEngineService); - ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry( - Arrays.asList( - new ScriptEngineRegistry.ScriptEngineRegistration(GroovyScriptEngineService.class, GroovyScriptEngineService.NAME) - ) - ); + ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry(Collections.singleton(groovyScriptEngineService)); ScriptContextRegistry scriptContextRegistry = new ScriptContextRegistry(Arrays.asList(ScriptServiceProxy.INSTANCE)); ClusterService clusterService = Mockito.mock(ClusterService.class); Mockito.when(clusterService.state()).thenReturn(ClusterState.builder(new ClusterName("_name")).build()); ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, scriptContextRegistry); - return ScriptServiceProxy.of(new ScriptService(settings, new Environment(settings), engineServiceSet, + return ScriptServiceProxy.of(new ScriptService(settings, new Environment(settings), new ResourceWatcherService(settings, tp), scriptEngineRegistry, scriptContextRegistry, scriptSettings), clusterService); } diff --git a/elasticsearch/qa/smoke-test-watcher-with-mustache/src/test/java/org/elasticsearch/smoketest/WatcherTemplateTests.java b/elasticsearch/qa/smoke-test-watcher-with-mustache/src/test/java/org/elasticsearch/smoketest/WatcherTemplateTests.java index efe00900d07..5475529e2d8 100644 --- a/elasticsearch/qa/smoke-test-watcher-with-mustache/src/test/java/org/elasticsearch/smoketest/WatcherTemplateTests.java +++ b/elasticsearch/qa/smoke-test-watcher-with-mustache/src/test/java/org/elasticsearch/smoketest/WatcherTemplateTests.java @@ -49,18 +49,14 @@ public class WatcherTemplateTests extends ESTestCase { public void init() throws Exception { Settings setting = Settings.builder().put(ScriptService.SCRIPT_AUTO_RELOAD_ENABLED_SETTING, true).build(); Environment environment = Mockito.mock(Environment.class); - Set engines = Collections.singleton(new MustacheScriptEngineService(setting)); ResourceWatcherService resourceWatcherService = Mockito.mock(ResourceWatcherService.class); ScriptContextRegistry registry = new ScriptContextRegistry(Collections.singletonList(ScriptServiceProxy.INSTANCE)); ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry( - Arrays.asList( - new ScriptEngineRegistry.ScriptEngineRegistration(MustacheScriptEngineService.class, - MustacheScriptEngineService.NAME) - ) + Collections.singleton(new MustacheScriptEngineService(setting)) ); ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, registry); - ScriptService scriptService = new ScriptService(setting, environment, engines, resourceWatcherService, scriptEngineRegistry, + ScriptService scriptService = new ScriptService(setting, environment, resourceWatcherService, scriptEngineRegistry, registry, scriptSettings); ClusterService clusterService = Mockito.mock(ClusterService.class); Mockito.when(clusterService.state()).thenReturn(ClusterState.builder(new ClusterName("_name")).build()); diff --git a/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/xpack/graph/test/GraphTests.java b/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/xpack/graph/test/GraphTests.java index 9fe576c8dc5..9131921669f 100644 --- a/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/xpack/graph/test/GraphTests.java +++ b/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/xpack/graph/test/GraphTests.java @@ -15,6 +15,7 @@ import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.ScriptQueryBuilder; import org.elasticsearch.marvel.Monitoring; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.plugins.ScriptPlugin; import org.elasticsearch.script.AbstractSearchScript; import org.elasticsearch.script.ExecutableScript; import org.elasticsearch.script.NativeScriptFactory; @@ -34,6 +35,8 @@ import org.elasticsearch.xpack.graph.action.Vertex; import org.elasticsearch.xpack.graph.action.VertexRequest; import java.util.Collection; +import java.util.Collections; +import java.util.List; import java.util.Map; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; @@ -346,7 +349,7 @@ public class GraphTests extends ESSingleNodeTestCase { assertThat(why, strongVertex.getWeight(), greaterThan(weakVertex.getWeight())); } - public static class ScriptedTimeoutPlugin extends Plugin { + public static class ScriptedTimeoutPlugin extends Plugin implements ScriptPlugin { @Override public String name() { return "test-scripted-graph-timeout"; @@ -357,8 +360,9 @@ public class GraphTests extends ESSingleNodeTestCase { return "Test for scripted timeouts on graph searches"; } - public void onModule(ScriptModule module) { - module.registerScript(NativeTestScriptedTimeout.TEST_NATIVE_SCRIPT_TIMEOUT, NativeTestScriptedTimeout.Factory.class); + @Override + public List getNativeScripts() { + return Collections.singletonList(new NativeTestScriptedTimeout.Factory()); } } @@ -377,6 +381,11 @@ public class GraphTests extends ESSingleNodeTestCase { public boolean needsScores() { return false; } + + @Override + public String getName() { + return TEST_NATIVE_SCRIPT_TIMEOUT; + } } @Override diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackPlugin.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackPlugin.java index 456f8db3598..17aefe14881 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackPlugin.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackPlugin.java @@ -22,6 +22,8 @@ import org.elasticsearch.index.IndexModule; import org.elasticsearch.license.plugin.Licensing; import org.elasticsearch.marvel.Monitoring; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.plugins.ScriptPlugin; +import org.elasticsearch.script.ScriptContext; import org.elasticsearch.script.ScriptModule; import org.elasticsearch.shield.Security; import org.elasticsearch.shield.authc.AuthenticationModule; @@ -31,6 +33,7 @@ import org.elasticsearch.xpack.action.TransportXPackInfoAction; import org.elasticsearch.xpack.action.TransportXPackUsageAction; import org.elasticsearch.xpack.action.XPackInfoAction; import org.elasticsearch.xpack.action.XPackUsageAction; +import org.elasticsearch.xpack.common.ScriptServiceProxy; import org.elasticsearch.xpack.common.http.HttpClientModule; import org.elasticsearch.xpack.common.init.LazyInitializationModule; import org.elasticsearch.xpack.common.init.LazyInitializationService; @@ -55,7 +58,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -public class XPackPlugin extends Plugin { +public class XPackPlugin extends Plugin implements ScriptPlugin { public static final String NAME = "x-pack"; @@ -182,8 +185,9 @@ public class XPackPlugin extends Plugin { return builder.build(); } - public void onModule(ScriptModule module) { - watcher.onModule(module); + @Override + public ScriptContext.Plugin getCustomScriptContexts() { + return ScriptServiceProxy.INSTANCE; } public void onModule(SettingsModule module) { diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java index 2f8b1e1ce2f..50d34f72318 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java @@ -140,9 +140,6 @@ public class Watcher { return Settings.EMPTY; } - public void onModule(ScriptModule module) { - module.registerScriptContext(ScriptServiceProxy.INSTANCE); - } public void onModule(SettingsModule module) { for (TemplateConfig templateConfig : WatcherIndexTemplateRegistry.TEMPLATE_CONFIGS) { diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java index 6430fde4a16..31b4f8fb44f 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java @@ -5,10 +5,9 @@ */ package org.elasticsearch.script; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.xpack.common.text.DefaultTextTemplateEngine; -import java.util.Collections; -import java.util.List; import java.util.Map; /** @@ -27,10 +26,10 @@ public class MockMustacheScriptEngine extends MockScriptEngine { return NAME; } - public void onModule(ScriptModule module) { - module.addScriptEngine(new ScriptEngineRegistry.ScriptEngineRegistration(MockMustacheScriptEngine.class, NAME, true)); + @Override + public ScriptEngineService getScriptEngineService(Settings settings) { + return new MockMustacheScriptEngine(); } - } @Override @@ -51,4 +50,9 @@ public class MockMustacheScriptEngine extends MockScriptEngine { return super.compile(name, script, params); } + + @Override + public boolean isInlineScriptEnabled() { + return true; + } } diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java index c0cf787d7e8..ad593bfe8ac 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java @@ -6,12 +6,13 @@ package org.elasticsearch.script; import org.elasticsearch.common.Nullable; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.plugins.ScriptPlugin; import org.elasticsearch.search.lookup.SearchLookup; import java.io.IOException; import java.util.Collections; -import java.util.List; import java.util.Map; /** @@ -21,7 +22,7 @@ public class SleepScriptEngine implements ScriptEngineService { public static final String NAME = "sleep"; - public static class TestPlugin extends Plugin { + public static class TestPlugin extends Plugin implements ScriptPlugin { public TestPlugin() { } @@ -36,11 +37,10 @@ public class SleepScriptEngine implements ScriptEngineService { return "Mock script engine for integration tests"; } - public void onModule(ScriptModule module) { - module.addScriptEngine(new ScriptEngineRegistry.ScriptEngineRegistration(SleepScriptEngine.class, - SleepScriptEngine.NAME, true)); + @Override + public ScriptEngineService getScriptEngineService(Settings settings) { + return new SleepScriptEngine(); } - } @Override @@ -92,4 +92,8 @@ public class SleepScriptEngine implements ScriptEngineService { .params(Collections.singletonMap("millis", millis)).build(); } + @Override + public boolean isInlineScriptEnabled() { + return true; + } } diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/WatcherTestUtils.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/WatcherTestUtils.java index e576cfd50ab..f11d07a3f4a 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/WatcherTestUtils.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/WatcherTestUtils.java @@ -254,7 +254,7 @@ public final class WatcherTestUtils { ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, scriptContextRegistry); ClusterService clusterService = Mockito.mock(ClusterService.class); Mockito.when(clusterService.state()).thenReturn(ClusterState.builder(new ClusterName("_name")).build()); - return ScriptServiceProxy.of(new ScriptService(settings, new Environment(settings), Collections.emptySet(), + return ScriptServiceProxy.of(new ScriptService(settings, new Environment(settings), new ResourceWatcherService(settings, tp), scriptEngineRegistry, scriptContextRegistry, scriptSettings), clusterService); } From b2c944a480d6195c395a4731f0015b3f62693959 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Thu, 16 Jun 2016 15:53:01 +0200 Subject: [PATCH 2/2] Cut over settings registration to a pull model elastic/elasticsearchelastic/elasticsearch#18890 (elastic/elasticsearch#2538) Followup for elastic/elasticsearchelastic/elasticsearch#18890 Original commit: elastic/x-pack-elasticsearch@a65ee6913f49dfe452c0a57c2e4af389a6a9ede4 --- .../org/elasticsearch/xpack/graph/Graph.java | 13 ++-- .../license/plugin/Licensing.java | 5 +- .../consumer/TestConsumerPluginBase.java | 14 ++--- .../org/elasticsearch/marvel/Monitoring.java | 2 +- .../marvel/MonitoringSettings.java | 32 +++++----- .../org/elasticsearch/shield/Security.java | 63 ++++++++++--------- .../shield/audit/AuditTrailModule.java | 10 +-- .../shield/audit/index/IndexAuditTrail.java | 18 +++--- .../audit/logfile/LoggingAuditTrail.java | 9 +-- .../authc/InternalAuthenticationService.java | 7 ++- .../elasticsearch/shield/authc/Realms.java | 4 +- .../authc/esnative/NativeUsersStore.java | 8 +-- .../authz/InternalAuthorizationService.java | 4 +- .../shield/authz/store/FileRolesStore.java | 4 +- .../shield/authz/store/NativeRolesStore.java | 9 ++- .../shield/crypto/InternalCryptoService.java | 10 +-- .../shield/ssl/SSLConfiguration.java | 38 +++++------ .../shield/transport/filter/IPFilter.java | 16 ++--- .../netty/ShieldNettyHttpServerTransport.java | 9 +-- .../transport/netty/ShieldNettyTransport.java | 21 ++++--- .../shield/user/AnonymousUser.java | 11 +++- .../shield/audit/AuditTrailModuleTests.java | 22 +++---- .../test/SettingsFilterTests.java | 15 +++-- .../org/elasticsearch/xpack/XPackPlugin.java | 44 ++++++++----- .../xpack/notification/Notification.java | 26 ++++---- .../elasticsearch/xpack/watcher/Watcher.java | 45 ++++++------- .../WatcherIndexTemplateRegistryTests.java | 7 ++- 27 files changed, 254 insertions(+), 212 deletions(-) diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/Graph.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/Graph.java index 9c435dba74f..b21f1884bc5 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/Graph.java +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/Graph.java @@ -20,6 +20,7 @@ import org.elasticsearch.xpack.graph.rest.action.RestGraphAction; import java.util.Collection; import java.util.Collections; +import java.util.List; public class Graph extends Plugin { @@ -69,10 +70,12 @@ public class Graph extends Plugin { if (enabled && transportClientMode == false) { module.registerRestHandler(RestGraphAction.class); } - } - - public void onModule(SettingsModule module) { - module.registerSetting(Setting.boolSetting(XPackPlugin.featureEnabledSetting(NAME), true, Setting.Property.NodeScope)); - } + } + + + @Override + public List> getSettings() { + return Collections.singletonList(Setting.boolSetting(XPackPlugin.featureEnabledSetting(NAME), true, Setting.Property.NodeScope)); + } } diff --git a/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/Licensing.java b/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/Licensing.java index 22c95840dd9..0f52530f74f 100644 --- a/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/Licensing.java +++ b/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/Licensing.java @@ -28,6 +28,7 @@ import org.elasticsearch.license.plugin.rest.RestPutLicenseAction; import java.util.Collection; import java.util.Collections; +import java.util.List; import static org.elasticsearch.xpack.XPackPlugin.isTribeClientNode; import static org.elasticsearch.xpack.XPackPlugin.isTribeNode; @@ -80,8 +81,8 @@ public class Licensing { return Collections.emptyList(); } - public void onModule(SettingsModule module) { + public List> getSettings() { // TODO convert this wildcard to a real setting - module.registerSetting(Setting.groupSetting("license.", Setting.Property.NodeScope)); + return Collections.singletonList(Setting.groupSetting("license.", Setting.Property.NodeScope)); } } diff --git a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/consumer/TestConsumerPluginBase.java b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/consumer/TestConsumerPluginBase.java index 46c50b0375c..4261e375d49 100644 --- a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/consumer/TestConsumerPluginBase.java +++ b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/consumer/TestConsumerPluginBase.java @@ -14,7 +14,9 @@ import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.plugins.Plugin; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; +import java.util.List; public abstract class TestConsumerPluginBase extends Plugin { @@ -44,13 +46,11 @@ public abstract class TestConsumerPluginBase extends Plugin { return services; } - public void onModule(SettingsModule module) { - try { - module.registerSetting(Setting.simpleString("_trial_license_duration_in_seconds", Setting.Property.NodeScope)); - module.registerSetting(Setting.simpleString("_grace_duration_in_seconds", Setting.Property.NodeScope)); - } catch (IllegalArgumentException ex) { - // already loaded - } + @Override + public List> getSettings() { + return Arrays.asList(Setting.simpleString("_trial_license_duration_in_seconds", Setting.Property.NodeScope, + Setting.Property.Shared), Setting.simpleString("_grace_duration_in_seconds", Setting.Property.NodeScope, + Setting.Property.Shared)); } public abstract Class service(); diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/Monitoring.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/Monitoring.java index 8b29f92ffa5..4ec351b8ee6 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/Monitoring.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/Monitoring.java @@ -9,6 +9,7 @@ import org.elasticsearch.action.ActionModule; import org.elasticsearch.common.component.LifecycleComponent; import org.elasticsearch.common.inject.Module; 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.marvel.action.MonitoringBulkAction; @@ -80,7 +81,6 @@ public class Monitoring { } public void onModule(SettingsModule module) { - MonitoringSettings.register(module); } public void onModule(ActionModule module) { diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MonitoringSettings.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MonitoringSettings.java index 3ee8afcce21..714f4c9c9ae 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MonitoringSettings.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MonitoringSettings.java @@ -15,6 +15,7 @@ import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.xpack.XPackPlugin; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.function.Function; @@ -125,22 +126,23 @@ public class MonitoringSettings extends AbstractComponent { public static final Setting EXPORTERS_SETTINGS = groupSetting(key("agent.exporters."), Property.Dynamic, Property.NodeScope); - static void register(SettingsModule module) { - module.registerSetting(INDICES); - module.registerSetting(INTERVAL); - module.registerSetting(INDEX_RECOVERY_TIMEOUT); - module.registerSetting(INDEX_STATS_TIMEOUT); - module.registerSetting(INDICES_STATS_TIMEOUT); - module.registerSetting(INDEX_RECOVERY_ACTIVE_ONLY); - module.registerSetting(COLLECTORS); - module.registerSetting(CLUSTER_STATE_TIMEOUT); - module.registerSetting(CLUSTER_STATS_TIMEOUT); - module.registerSetting(HISTORY_DURATION); - module.registerSetting(EXPORTERS_SETTINGS); - module.registerSetting(ENABLED); + public static List> getSettings() { + return Arrays.asList(INDICES, + INTERVAL, + INDEX_RECOVERY_TIMEOUT, + INDEX_STATS_TIMEOUT, + INDICES_STATS_TIMEOUT, + INDEX_RECOVERY_ACTIVE_ONLY, + COLLECTORS, + CLUSTER_STATE_TIMEOUT, + CLUSTER_STATS_TIMEOUT, + HISTORY_DURATION, + EXPORTERS_SETTINGS, + ENABLED); + } - module.registerSettingsFilter("xpack.monitoring.agent.exporters.*.auth.*"); - module.registerSettingsFilter("xpack.monitoring.agent.exporters.*.ssl.*"); + public static List getSettingsFilter() { + return Arrays.asList("xpack.monitoring.agent.exporters.*.auth.*", "xpack.monitoring.agent.exporters.*.ssl.*"); } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/Security.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/Security.java index 6d63c016a03..aaa68307b1b 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/Security.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/Security.java @@ -18,7 +18,6 @@ import org.elasticsearch.common.regex.Regex; 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.common.util.concurrent.ThreadContext; import org.elasticsearch.index.IndexModule; import org.elasticsearch.shield.action.ShieldActionModule; @@ -188,62 +187,70 @@ public class Security { return settingsBuilder.build(); } - public void onModule(SettingsModule settingsModule) { + public List> getSettings() { + List> settingsList = new ArrayList<>(); // always register for both client and node modes - XPackPlugin.registerFeatureEnabledSettings(settingsModule, NAME, true); - settingsModule.registerSetting(USER_SETTING); + XPackPlugin.addFeatureEnabledSettings(settingsList, NAME, true); + settingsList.add(USER_SETTING); // SSL settings - SSLConfiguration.Global.registerSettings(settingsModule); + SSLConfiguration.Global.addSettings(settingsList); // transport settings - ShieldNettyTransport.registerSettings(settingsModule); + ShieldNettyTransport.addSettings(settingsList); if (transportClientMode) { - return; + return settingsList; } // The following just apply in node mode - XPackPlugin.registerFeatureEnabledSettings(settingsModule, DLS_FLS_FEATURE, true); + XPackPlugin.addFeatureEnabledSettings(settingsList, DLS_FLS_FEATURE, true); // IP Filter settings - IPFilter.registerSettings(settingsModule); + IPFilter.addSettings(settingsList); // audit settings - AuditTrailModule.registerSettings(settingsModule); + AuditTrailModule.addSettings(settingsList); // authentication settings - FileRolesStore.registerSettings(settingsModule); - AnonymousUser.registerSettings(settingsModule); - Realms.registerSettings(settingsModule); - NativeUsersStore.registerSettings(settingsModule); - NativeRolesStore.registerSettings(settingsModule); - InternalAuthenticationService.registerSettings(settingsModule); - InternalAuthorizationService.registerSettings(settingsModule); + FileRolesStore.addSettings(settingsList); + AnonymousUser.addSettings(settingsList); + Realms.addSettings(settingsList); + NativeUsersStore.addSettings(settingsList); + NativeRolesStore.addSettings(settingsList); + InternalAuthenticationService.addSettings(settingsList); + InternalAuthorizationService.addSettings(settingsList); // HTTP settings - ShieldNettyHttpServerTransport.registerSettings(settingsModule); + ShieldNettyHttpServerTransport.addSettings(settingsList); // encryption settings - InternalCryptoService.registerSettings(settingsModule); + InternalCryptoService.addSettings(settingsList); // hide settings - settingsModule.registerSetting(Setting.listSetting(setting("hide_settings"), Collections.emptyList(), Function.identity(), + settingsList.add(Setting.listSetting(setting("hide_settings"), Collections.emptyList(), Function.identity(), Property.NodeScope, Property.Filtered)); + return settingsList; + } + + + public List getSettingsFilter() { + ArrayList settingsFilter = new ArrayList<>(); String[] asArray = settings.getAsArray(setting("hide_settings")); for (String pattern : asArray) { - settingsModule.registerSettingsFilter(pattern); + settingsFilter.add(pattern); } - settingsModule.registerSettingsFilter(setting("authc.realms.*.bind_dn")); - settingsModule.registerSettingsFilter(setting("authc.realms.*.bind_password")); - settingsModule.registerSettingsFilter(setting("authc.realms.*." + SessionFactory.HOSTNAME_VERIFICATION_SETTING)); - settingsModule.registerSettingsFilter(setting("authc.realms.*.truststore.password")); - settingsModule.registerSettingsFilter(setting("authc.realms.*.truststore.path")); - settingsModule.registerSettingsFilter(setting("authc.realms.*.truststore.algorithm")); + settingsFilter.add(setting("authc.realms.*.bind_dn")); + settingsFilter.add(setting("authc.realms.*.bind_password")); + settingsFilter.add(setting("authc.realms.*." + SessionFactory.HOSTNAME_VERIFICATION_SETTING)); + settingsFilter.add(setting("authc.realms.*.truststore.password")); + settingsFilter.add(setting("authc.realms.*.truststore.path")); + settingsFilter.add(setting("authc.realms.*.truststore.algorithm")); // hide settings where we don't define them - they are part of a group... - settingsModule.registerSettingsFilter("transport.profiles.*." + setting("*")); + settingsFilter.add("transport.profiles.*." + setting("*")); + return settingsFilter; } public void onIndexModule(IndexModule module) { diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/audit/AuditTrailModule.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/audit/AuditTrailModule.java index f58e0f01b81..1b1a18c0e21 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/audit/AuditTrailModule.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/audit/AuditTrailModule.java @@ -102,10 +102,10 @@ public class AuditTrailModule extends AbstractShieldModule.Node { return false; } - public static void registerSettings(SettingsModule settingsModule) { - settingsModule.registerSetting(ENABLED_SETTING); - settingsModule.registerSetting(OUTPUTS_SETTING); - LoggingAuditTrail.registerSettings(settingsModule); - IndexAuditTrail.registerSettings(settingsModule); + public static void addSettings(List> settings) { + settings.add(ENABLED_SETTING); + settings.add(OUTPUTS_SETTING); + LoggingAuditTrail.registerSettings(settings); + IndexAuditTrail.registerSettings(settings); } } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/audit/index/IndexAuditTrail.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/audit/index/IndexAuditTrail.java index 1e2b4665d66..da8163139b1 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/audit/index/IndexAuditTrail.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/audit/index/IndexAuditTrail.java @@ -877,15 +877,15 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail, Cl } } - public static void registerSettings(SettingsModule settingsModule) { - settingsModule.registerSetting(INDEX_SETTINGS); - settingsModule.registerSetting(EXCLUDE_EVENT_SETTINGS); - settingsModule.registerSetting(INCLUDE_EVENT_SETTINGS); - settingsModule.registerSetting(ROLLOVER_SETTING); - settingsModule.registerSetting(BULK_SIZE_SETTING); - settingsModule.registerSetting(FLUSH_TIMEOUT_SETTING); - settingsModule.registerSetting(QUEUE_SIZE_SETTING); - settingsModule.registerSetting(REMOTE_CLIENT_SETTINGS); + public static void registerSettings(List> settings) { + settings.add(INDEX_SETTINGS); + settings.add(EXCLUDE_EVENT_SETTINGS); + settings.add(INCLUDE_EVENT_SETTINGS); + settings.add(ROLLOVER_SETTING); + settings.add(BULK_SIZE_SETTING); + settings.add(FLUSH_TIMEOUT_SETTING); + settings.add(QUEUE_SIZE_SETTING); + settings.add(REMOTE_CLIENT_SETTINGS); } private class QueueConsumer extends Thread { diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/audit/logfile/LoggingAuditTrail.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/audit/logfile/LoggingAuditTrail.java index 92396f02c94..4f4f6942883 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/audit/logfile/LoggingAuditTrail.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/audit/logfile/LoggingAuditTrail.java @@ -35,6 +35,7 @@ import org.elasticsearch.transport.TransportMessage; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.SocketAddress; +import java.util.List; import static org.elasticsearch.common.Strings.arrayToCommaDelimitedString; import static org.elasticsearch.shield.audit.AuditUtil.indices; @@ -463,9 +464,9 @@ public class LoggingAuditTrail extends AbstractLifecycleComponent> settings) { + settings.add(HOST_ADDRESS_SETTING); + settings.add(HOST_NAME_SETTING); + settings.add(NODE_NAME_SETTING); } } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/InternalAuthenticationService.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/InternalAuthenticationService.java index 343b08d50c4..4805354c83e 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/InternalAuthenticationService.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/InternalAuthenticationService.java @@ -29,6 +29,7 @@ import org.elasticsearch.transport.TransportMessage; import java.io.IOException; import java.util.Base64; +import java.util.List; import static org.elasticsearch.shield.Security.setting; import static org.elasticsearch.shield.support.Exceptions.authenticationError; @@ -316,9 +317,9 @@ public class InternalAuthenticationService extends AbstractComponent implements return null; } - public static void registerSettings(SettingsModule settingsModule) { - settingsModule.registerSetting(SIGN_USER_HEADER); - settingsModule.registerSetting(RUN_AS_ENABLED); + public static void addSettings(List> settings) { + settings.add(SIGN_USER_HEADER); + settings.add(RUN_AS_ENABLED); } // these methods are package private for testing. They are also needed so that a AuditableRequest can be created in tests diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/Realms.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/Realms.java index 604110c6ddc..b2981ec9d1f 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/Realms.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/Realms.java @@ -212,7 +212,7 @@ public class Realms extends AbstractLifecycleComponent implements Iterab } } - public static void registerSettings(SettingsModule settingsModule) { - settingsModule.registerSetting(REALMS_GROUPS_SETTINGS); + public static void addSettings(List> settingsModule) { + settingsModule.add(REALMS_GROUPS_SETTINGS); } } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/esnative/NativeUsersStore.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/esnative/NativeUsersStore.java index ce56350aed9..052813d801f 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/esnative/NativeUsersStore.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/esnative/NativeUsersStore.java @@ -867,9 +867,9 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL void onUsersChanged(List username); } - public static void registerSettings(SettingsModule settingsModule) { - settingsModule.registerSetting(SCROLL_SIZE_SETTING); - settingsModule.registerSetting(SCROLL_KEEP_ALIVE_SETTING); - settingsModule.registerSetting(POLL_INTERVAL_SETTING); + public static void addSettings(List> settings) { + settings.add(SCROLL_SIZE_SETTING); + settings.add(SCROLL_KEEP_ALIVE_SETTING); + settings.add(POLL_INTERVAL_SETTING); } } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authz/InternalAuthorizationService.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authz/InternalAuthorizationService.java index a640b080cf6..ed8e4835333 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authz/InternalAuthorizationService.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authz/InternalAuthorizationService.java @@ -357,7 +357,7 @@ public class InternalAuthorizationService extends AbstractComponent implements A return authorizationError("action [{}] is unauthorized for user [{}]", action, user.principal()); } - public static void registerSettings(SettingsModule settingsModule) { - settingsModule.registerSetting(ANONYMOUS_AUTHORIZATION_EXCEPTION_SETTING); + public static void addSettings(List> settings) { + settings.add(ANONYMOUS_AUTHORIZATION_EXCEPTION_SETTING); } } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authz/store/FileRolesStore.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authz/store/FileRolesStore.java index 389c70254e0..19edfa313cb 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authz/store/FileRolesStore.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authz/store/FileRolesStore.java @@ -260,7 +260,7 @@ public class FileRolesStore extends AbstractLifecycleComponent imple } } - public static void registerSettings(SettingsModule settingsModule) { - settingsModule.registerSetting(ROLES_FILE_SETTING); + public static void addSettings(List> settings) { + settings.add(ROLES_FILE_SETTING); } } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authz/store/NativeRolesStore.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authz/store/NativeRolesStore.java index 46bfb0c3c71..e977dc77b45 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authz/store/NativeRolesStore.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authz/store/NativeRolesStore.java @@ -31,7 +31,6 @@ import org.elasticsearch.common.inject.Provider; 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.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.AbstractRunnable; import org.elasticsearch.common.xcontent.ToXContent; @@ -604,9 +603,9 @@ public class NativeRolesStore extends AbstractComponent implements RolesStore, C } } - public static void registerSettings(SettingsModule settingsModule) { - settingsModule.registerSetting(SCROLL_SIZE_SETTING); - settingsModule.registerSetting(SCROLL_KEEP_ALIVE_SETTING); - settingsModule.registerSetting(POLL_INTERVAL_SETTING); + public static void addSettings(List> settings) { + settings.add(SCROLL_SIZE_SETTING); + settings.add(SCROLL_KEEP_ALIVE_SETTING); + settings.add(POLL_INTERVAL_SETTING); } } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/crypto/InternalCryptoService.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/crypto/InternalCryptoService.java index 30994e722f2..ef96be6b210 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/crypto/InternalCryptoService.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/crypto/InternalCryptoService.java @@ -676,10 +676,10 @@ public class InternalCryptoService extends AbstractLifecycleComponent> settings) { + settings.add(FILE_SETTING); + settings.add(ENCRYPTION_KEY_LENGTH_SETTING); + settings.add(ENCRYPTION_KEY_ALGO_SETTING); + settings.add(ENCRYPTION_ALGO_SETTING); } } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ssl/SSLConfiguration.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ssl/SSLConfiguration.java index 2286bff2cbb..cabac13e0f7 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ssl/SSLConfiguration.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ssl/SSLConfiguration.java @@ -147,25 +147,25 @@ public abstract class SSLConfiguration { static final Setting INCLUDE_JDK_CERTS_SETTING = Setting.boolSetting(globalKey(Custom.INCLUDE_JDK_CERTS_SETTING), true, Property.NodeScope, Property.Filtered); - public static void registerSettings(SettingsModule settingsModule) { - settingsModule.registerSetting(Global.CIPHERS_SETTING); - settingsModule.registerSetting(Global.SUPPORTED_PROTOCOLS_SETTING); - settingsModule.registerSetting(Global.KEYSTORE_PATH_SETTING); - settingsModule.registerSetting(Global.KEYSTORE_PASSWORD_SETTING); - settingsModule.registerSetting(Global.KEYSTORE_ALGORITHM_SETTING); - settingsModule.registerSetting(Global.KEYSTORE_KEY_PASSWORD_SETTING); - settingsModule.registerSetting(Global.KEY_PATH_SETTING); - settingsModule.registerSetting(Global.KEY_PASSWORD_SETTING); - settingsModule.registerSetting(Global.CERT_SETTING); - settingsModule.registerSetting(Global.TRUSTSTORE_PATH_SETTING); - settingsModule.registerSetting(Global.TRUSTSTORE_PASSWORD_SETTING); - settingsModule.registerSetting(Global.TRUSTSTORE_ALGORITHM_SETTING); - settingsModule.registerSetting(Global.PROTOCOL_SETTING); - settingsModule.registerSetting(Global.SESSION_CACHE_SIZE_SETTING); - settingsModule.registerSetting(Global.SESSION_CACHE_TIMEOUT_SETTING); - settingsModule.registerSetting(Global.CA_PATHS_SETTING); - settingsModule.registerSetting(Global.INCLUDE_JDK_CERTS_SETTING); - settingsModule.registerSetting(Global.RELOAD_ENABLED_SETTING); + public static void addSettings(List> settings) { + settings.add(Global.CIPHERS_SETTING); + settings.add(Global.SUPPORTED_PROTOCOLS_SETTING); + settings.add(Global.KEYSTORE_PATH_SETTING); + settings.add(Global.KEYSTORE_PASSWORD_SETTING); + settings.add(Global.KEYSTORE_ALGORITHM_SETTING); + settings.add(Global.KEYSTORE_KEY_PASSWORD_SETTING); + settings.add(Global.KEY_PATH_SETTING); + settings.add(Global.KEY_PASSWORD_SETTING); + settings.add(Global.CERT_SETTING); + settings.add(Global.TRUSTSTORE_PATH_SETTING); + settings.add(Global.TRUSTSTORE_PASSWORD_SETTING); + settings.add(Global.TRUSTSTORE_ALGORITHM_SETTING); + settings.add(Global.PROTOCOL_SETTING); + settings.add(Global.SESSION_CACHE_SIZE_SETTING); + settings.add(Global.SESSION_CACHE_TIMEOUT_SETTING); + settings.add(Global.CA_PATHS_SETTING); + settings.add(Global.INCLUDE_JDK_CERTS_SETTING); + settings.add(Global.RELOAD_ENABLED_SETTING); } private final KeyConfig keyConfig; diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/filter/IPFilter.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/filter/IPFilter.java index b7df9e2234c..ee1724b0f63 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/filter/IPFilter.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/filter/IPFilter.java @@ -260,13 +260,13 @@ public class IPFilter { updateRules(); } - public static void registerSettings(SettingsModule settingsModule) { - settingsModule.registerSetting(ALLOW_BOUND_ADDRESSES_SETTING); - settingsModule.registerSetting(IP_FILTER_ENABLED_SETTING); - settingsModule.registerSetting(IP_FILTER_ENABLED_HTTP_SETTING); - settingsModule.registerSetting(HTTP_FILTER_ALLOW_SETTING); - settingsModule.registerSetting(HTTP_FILTER_DENY_SETTING); - settingsModule.registerSetting(TRANSPORT_FILTER_ALLOW_SETTING); - settingsModule.registerSetting(TRANSPORT_FILTER_DENY_SETTING); + public static void addSettings(List> settings) { + settings.add(ALLOW_BOUND_ADDRESSES_SETTING); + settings.add(IP_FILTER_ENABLED_SETTING); + settings.add(IP_FILTER_ENABLED_HTTP_SETTING); + settings.add(HTTP_FILTER_ALLOW_SETTING); + settings.add(HTTP_FILTER_DENY_SETTING); + settings.add(TRANSPORT_FILTER_ALLOW_SETTING); + settings.add(TRANSPORT_FILTER_DENY_SETTING); } } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/netty/ShieldNettyHttpServerTransport.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/netty/ShieldNettyHttpServerTransport.java index c477f94312c..51545e62a75 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/netty/ShieldNettyHttpServerTransport.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/netty/ShieldNettyHttpServerTransport.java @@ -27,6 +27,7 @@ import org.jboss.netty.handler.ssl.SslHandler; import javax.net.ssl.SSLEngine; import java.util.Collections; +import java.util.List; import static org.elasticsearch.http.HttpTransportSettings.SETTING_HTTP_COMPRESSION; import static org.elasticsearch.shield.Security.setting; @@ -128,10 +129,10 @@ public class ShieldNettyHttpServerTransport extends NettyHttpServerTransport { } } - public static void registerSettings(SettingsModule settingsModule) { - settingsModule.registerSetting(SSL_SETTING); - settingsModule.registerSetting(CLIENT_AUTH_SETTING); - settingsModule.registerSetting(DEPRECATED_SSL_SETTING); + public static void addSettings(List> settings) { + settings.add(SSL_SETTING); + settings.add(CLIENT_AUTH_SETTING); + settings.add(DEPRECATED_SSL_SETTING); } public static void overrideSettings(Settings.Builder settingsBuilder, Settings settings) { diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/netty/ShieldNettyTransport.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/netty/ShieldNettyTransport.java index d226a5ba4b9..89cf5b1287b 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/netty/ShieldNettyTransport.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/netty/ShieldNettyTransport.java @@ -34,6 +34,7 @@ import org.jboss.netty.handler.ssl.SslHandler; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLParameters; import java.net.InetSocketAddress; +import java.util.List; import static org.elasticsearch.shield.Security.featureEnabledSetting; import static org.elasticsearch.shield.Security.setting; @@ -249,17 +250,17 @@ public class ShieldNettyTransport extends NettyTransport { } } - public static void registerSettings(SettingsModule settingsModule) { - settingsModule.registerSetting(SSL_SETTING); - settingsModule.registerSetting(HOSTNAME_VERIFICATION_SETTING); - settingsModule.registerSetting(HOSTNAME_VERIFICATION_RESOLVE_NAME_SETTING); - settingsModule.registerSetting(CLIENT_AUTH_SETTING); - settingsModule.registerSetting(PROFILE_SSL_SETTING); - settingsModule.registerSetting(PROFILE_CLIENT_AUTH_SETTING); + public static void addSettings(List> settingsModule) { + settingsModule.add(SSL_SETTING); + settingsModule.add(HOSTNAME_VERIFICATION_SETTING); + settingsModule.add(HOSTNAME_VERIFICATION_RESOLVE_NAME_SETTING); + settingsModule.add(CLIENT_AUTH_SETTING); + settingsModule.add(PROFILE_SSL_SETTING); + settingsModule.add(PROFILE_CLIENT_AUTH_SETTING); // deprecated transport settings - settingsModule.registerSetting(DEPRECATED_SSL_SETTING); - settingsModule.registerSetting(DEPRECATED_PROFILE_SSL_SETTING); - settingsModule.registerSetting(DEPRECATED_HOSTNAME_VERIFICATION_SETTING); + settingsModule.add(DEPRECATED_SSL_SETTING); + settingsModule.add(DEPRECATED_PROFILE_SSL_SETTING); + settingsModule.add(DEPRECATED_HOSTNAME_VERIFICATION_SETTING); } } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/user/AnonymousUser.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/user/AnonymousUser.java index 818be16d489..55742e31f2b 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/user/AnonymousUser.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/user/AnonymousUser.java @@ -12,6 +12,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.shield.user.User.ReservedUser; +import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -80,8 +81,12 @@ public class AnonymousUser extends ReservedUser { return roles; } - public static void registerSettings(SettingsModule settingsModule) { - settingsModule.registerSetting(USERNAME_SETTING); - settingsModule.registerSetting(ROLES_SETTING); + public static List> getSettings() { + return Arrays.asList(); + } + + public static void addSettings(List> settingsList) { + settingsList.add(USERNAME_SETTING); + settingsList.add(ROLES_SETTING); } } diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/AuditTrailModuleTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/AuditTrailModuleTests.java index 46bb410fca3..b7ae372caf7 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/AuditTrailModuleTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/AuditTrailModuleTests.java @@ -11,15 +11,14 @@ import org.elasticsearch.common.inject.Injector; 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.indices.breaker.CircuitBreakerModule; +import org.elasticsearch.indices.breaker.CircuitBreakerService; +import org.elasticsearch.node.Node; import org.elasticsearch.shield.audit.logfile.LoggingAuditTrail; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.threadpool.ThreadPoolModule; import org.elasticsearch.transport.Transport; import org.elasticsearch.transport.local.LocalTransport; @@ -36,8 +35,7 @@ public class AuditTrailModuleTests extends ESTestCase { .put("client.type", "node") .put(AuditTrailModule.ENABLED_SETTING.getKey(), false) .build(); - SettingsModule settingsModule = new SettingsModule(settings); - settingsModule.registerSetting(AuditTrailModule.ENABLED_SETTING); + SettingsModule settingsModule = new SettingsModule(settings, AuditTrailModule.ENABLED_SETTING); Injector injector = Guice.createInjector(settingsModule, new AuditTrailModule(settings)); AuditTrail auditTrail = injector.getInstance(AuditTrail.class); assertThat(auditTrail, is(AuditTrail.NOOP)); @@ -58,8 +56,7 @@ public class AuditTrailModuleTests extends ESTestCase { .build(); ThreadPool pool = new TestThreadPool("testLogFile"); try { - SettingsModule settingsModule = new SettingsModule(settings); - settingsModule.registerSetting(AuditTrailModule.ENABLED_SETTING); + SettingsModule settingsModule = new SettingsModule(settings, AuditTrailModule.ENABLED_SETTING); Injector injector = Guice.createInjector( settingsModule, new NetworkModule(new NetworkService(settings), settings, false, new NamedWriteableRegistry()) { @@ -69,8 +66,11 @@ public class AuditTrailModuleTests extends ESTestCase { } }, new AuditTrailModule(settings), - new CircuitBreakerModule(settings), - new ThreadPoolModule(pool), + b -> { + b.bind(CircuitBreakerService.class).toInstance(Node.createCircuitBreakerService(settingsModule.getSettings(), + settingsModule.getClusterSettings())); + b.bind(ThreadPool.class).toInstance(pool); + }, new Version.Module(Version.CURRENT) ); AuditTrail auditTrail = injector.getInstance(AuditTrail.class); @@ -90,9 +90,7 @@ public class AuditTrailModuleTests extends ESTestCase { .put(AuditTrailModule.OUTPUTS_SETTING.getKey() , "foo") .put("client.type", "node") .build(); - SettingsModule settingsModule = new SettingsModule(settings); - settingsModule.registerSetting(AuditTrailModule.ENABLED_SETTING); - settingsModule.registerSetting(AuditTrailModule.OUTPUTS_SETTING); + SettingsModule settingsModule = new SettingsModule(settings, AuditTrailModule.ENABLED_SETTING, AuditTrailModule.OUTPUTS_SETTING); try { Guice.createInjector(settingsModule, new AuditTrailModule(settings)); fail("Expect initialization to fail when an unknown audit trail output is configured"); diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/SettingsFilterTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/SettingsFilterTests.java index 945472b94c3..767b656b666 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/SettingsFilterTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/SettingsFilterTests.java @@ -15,7 +15,9 @@ import org.elasticsearch.shield.ssl.SSLConfiguration; import org.elasticsearch.xpack.XPackPlugin; import org.hamcrest.Matcher; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import static org.hamcrest.CoreMatchers.nullValue; @@ -85,13 +87,14 @@ public class SettingsFilterTests extends ESTestCase { .build(); XPackPlugin xPackPlugin = new XPackPlugin(settings); - SettingsModule settingsModule = new SettingsModule(settings); + List> settingList = new ArrayList<>(); + settingList.add(Setting.simpleString("foo.bar", Setting.Property.NodeScope)); + settingList.add(Setting.simpleString("foo.baz", Setting.Property.NodeScope)); + settingList.add(Setting.simpleString("bar.baz", Setting.Property.NodeScope)); + settingList.add(Setting.simpleString("baz.foo", Setting.Property.NodeScope)); + settingList.addAll(xPackPlugin.getSettings()); // custom settings, potentially added by a plugin - settingsModule.registerSetting(Setting.simpleString("foo.bar", Setting.Property.NodeScope)); - settingsModule.registerSetting(Setting.simpleString("foo.baz", Setting.Property.NodeScope)); - settingsModule.registerSetting(Setting.simpleString("bar.baz", Setting.Property.NodeScope)); - settingsModule.registerSetting(Setting.simpleString("baz.foo", Setting.Property.NodeScope)); - xPackPlugin.onModule(settingsModule); + SettingsModule settingsModule = new SettingsModule(settings, settingList, xPackPlugin.getSettingsFilter()); Injector injector = Guice.createInjector(settingsModule); SettingsFilter settingsFilter = injector.getInstance(SettingsFilter.class); diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackPlugin.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackPlugin.java index 17aefe14881..66d5a20b1f4 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackPlugin.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackPlugin.java @@ -21,6 +21,7 @@ import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexModule; import org.elasticsearch.license.plugin.Licensing; import org.elasticsearch.marvel.Monitoring; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.ScriptPlugin; import org.elasticsearch.script.ScriptContext; @@ -28,7 +29,6 @@ import org.elasticsearch.script.ScriptModule; import org.elasticsearch.shield.Security; import org.elasticsearch.shield.authc.AuthenticationModule; import org.elasticsearch.threadpool.ExecutorBuilder; -import org.elasticsearch.threadpool.ThreadPoolModule; import org.elasticsearch.xpack.action.TransportXPackInfoAction; import org.elasticsearch.xpack.action.TransportXPackUsageAction; import org.elasticsearch.xpack.action.XPackInfoAction; @@ -190,22 +190,34 @@ public class XPackPlugin extends Plugin implements ScriptPlugin { return ScriptServiceProxy.INSTANCE; } - public void onModule(SettingsModule module) { + @Override + public List> getSettings() { + ArrayList> settings = new ArrayList<>(); + settings.addAll(notification.getSettings()); + settings.addAll(security.getSettings()); + settings.addAll(MonitoringSettings.getSettings()); + settings.addAll(watcher.getSettings()); + settings.addAll(graph.getSettings()); + settings.addAll(licensing.getSettings()); // we add the `xpack.version` setting to all internal indices - module.registerSetting(Setting.simpleString("index.xpack.version", Setting.Property.IndexScope)); + settings.add(Setting.simpleString("index.xpack.version", Setting.Property.IndexScope)); // http settings - module.registerSetting(Setting.simpleString("xpack.http.default_read_timeout", Setting.Property.NodeScope)); - module.registerSetting(Setting.simpleString("xpack.http.default_connection_timeout", Setting.Property.NodeScope)); - module.registerSetting(Setting.groupSetting("xpack.http.ssl.", Setting.Property.NodeScope)); - module.registerSetting(Setting.groupSetting("xpack.http.proxy.", Setting.Property.NodeScope)); + settings.add(Setting.simpleString("xpack.http.default_read_timeout", Setting.Property.NodeScope)); + settings.add(Setting.simpleString("xpack.http.default_connection_timeout", Setting.Property.NodeScope)); + settings.add(Setting.groupSetting("xpack.http.ssl.", Setting.Property.NodeScope)); + settings.add(Setting.groupSetting("xpack.http.proxy.", Setting.Property.NodeScope)); + return settings; + } - notification.onModule(module); - security.onModule(module); - monitoring.onModule(module); - watcher.onModule(module); - graph.onModule(module); - licensing.onModule(module); + @Override + public List getSettingsFilter() { + List filters = new ArrayList<>(); + filters.addAll(notification.getSettingsFilter()); + filters.addAll(security.getSettingsFilter()); + filters.addAll(MonitoringSettings.getSettingsFilter()); + filters.addAll(graph.getSettingsFilter()); + return filters; } @Override @@ -309,9 +321,9 @@ public class XPackPlugin extends Plugin implements ScriptPlugin { * * {@code ".enabled": true | false} */ - public static void registerFeatureEnabledSettings(SettingsModule settingsModule, String featureName, boolean defaultValue) { - settingsModule.registerSetting(Setting.boolSetting(featureEnabledSetting(featureName), defaultValue, Setting.Property.NodeScope)); - settingsModule.registerSetting(Setting.boolSetting(legacyFeatureEnabledSetting(featureName), + public static void addFeatureEnabledSettings(List> settingsList, String featureName, boolean defaultValue) { + settingsList.add(Setting.boolSetting(featureEnabledSetting(featureName), defaultValue, Setting.Property.NodeScope)); + settingsList.add(Setting.boolSetting(legacyFeatureEnabledSetting(featureName), defaultValue, Setting.Property.NodeScope)); } diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/Notification.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/Notification.java index a1d2e67b6fc..755b18098ae 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/Notification.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/Notification.java @@ -36,18 +36,22 @@ public class Notification { this.transportClient = "transport".equals(settings.get(Client.CLIENT_TYPE_SETTING_S.getKey())); } - public void onModule(SettingsModule module) { - module.registerSetting(InternalSlackService.SLACK_ACCOUNT_SETTING); - module.registerSetting(InternalEmailService.EMAIL_ACCOUNT_SETTING); - module.registerSetting(InternalHipChatService.HIPCHAT_ACCOUNT_SETTING); - module.registerSetting(InternalPagerDutyService.PAGERDUTY_ACCOUNT_SETTING); + public List> getSettings() { + return Arrays.asList(InternalSlackService.SLACK_ACCOUNT_SETTING, + InternalEmailService.EMAIL_ACCOUNT_SETTING, + InternalHipChatService.HIPCHAT_ACCOUNT_SETTING, + InternalPagerDutyService.PAGERDUTY_ACCOUNT_SETTING); + } - module.registerSettingsFilter("xpack.notification.email.account.*.smtp.password"); - module.registerSettingsFilter("xpack.notification.slack.account.*.url"); - module.registerSettingsFilter("xpack.notification.pagerduty.account.*.url"); - module.registerSettingsFilter("xpack.notification.pagerduty." + PagerDutyAccount.SERVICE_KEY_SETTING); - module.registerSettingsFilter("xpack.notification.pagerduty.account.*." + PagerDutyAccount.SERVICE_KEY_SETTING); - module.registerSettingsFilter("xpack.notification.hipchat.account.*.auth_token"); + public List getSettingsFilter() { + ArrayList settingsFilter = new ArrayList<>(); + settingsFilter.add("xpack.notification.email.account.*.smtp.password"); + settingsFilter.add("xpack.notification.slack.account.*.url"); + settingsFilter.add("xpack.notification.pagerduty.account.*.url"); + settingsFilter.add("xpack.notification.pagerduty." + PagerDutyAccount.SERVICE_KEY_SETTING); + settingsFilter.add("xpack.notification.pagerduty.account.*." + PagerDutyAccount.SERVICE_KEY_SETTING); + settingsFilter.add("xpack.notification.hipchat.account.*.auth_token"); + return settingsFilter; } public Collection> nodeServices() { diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java index 50d34f72318..aaaa604764f 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java @@ -19,12 +19,10 @@ import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.script.ScriptModule; import org.elasticsearch.threadpool.ExecutorBuilder; import org.elasticsearch.threadpool.FixedExecutorBuilder; -import org.elasticsearch.threadpool.ThreadPoolModule; import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.common.init.LazyInitializationModule; import org.elasticsearch.xpack.watcher.actions.WatcherActionModule; @@ -141,29 +139,31 @@ public class Watcher { } - public void onModule(SettingsModule module) { + public List> getSettings() { + List> settings = new ArrayList<>(); for (TemplateConfig templateConfig : WatcherIndexTemplateRegistry.TEMPLATE_CONFIGS) { - module.registerSetting(templateConfig.getSetting()); + settings.add(templateConfig.getSetting()); } - module.registerSetting(INDEX_WATCHER_VERSION_SETTING); - module.registerSetting(INDEX_WATCHER_TEMPLATE_VERSION_SETTING); - module.registerSetting(Setting.intSetting("xpack.watcher.execution.scroll.size", 0, Setting.Property.NodeScope)); - module.registerSetting(Setting.intSetting("xpack.watcher.watch.scroll.size", 0, Setting.Property.NodeScope)); - module.registerSetting(Setting.boolSetting(XPackPlugin.featureEnabledSetting(Watcher.NAME), true, Setting.Property.NodeScope)); - module.registerSetting(ENCRYPT_SENSITIVE_DATA_SETTING); + settings.add(INDEX_WATCHER_VERSION_SETTING); + settings.add(INDEX_WATCHER_TEMPLATE_VERSION_SETTING); + settings.add(Setting.intSetting("xpack.watcher.execution.scroll.size", 0, Setting.Property.NodeScope)); + settings.add(Setting.intSetting("xpack.watcher.watch.scroll.size", 0, Setting.Property.NodeScope)); + settings.add(Setting.boolSetting(XPackPlugin.featureEnabledSetting(Watcher.NAME), true, Setting.Property.NodeScope)); + settings.add(ENCRYPT_SENSITIVE_DATA_SETTING); - module.registerSetting(Setting.simpleString("xpack.watcher.internal.ops.search.default_timeout", Setting.Property.NodeScope)); - module.registerSetting(Setting.simpleString("xpack.watcher.internal.ops.bulk.default_timeout", Setting.Property.NodeScope)); - module.registerSetting(Setting.simpleString("xpack.watcher.internal.ops.index.default_timeout", Setting.Property.NodeScope)); - module.registerSetting(Setting.simpleString("xpack.watcher.execution.default_throttle_period", Setting.Property.NodeScope)); - module.registerSetting(Setting.simpleString("xpack.watcher.actions.index.default_timeout", Setting.Property.NodeScope)); - module.registerSetting(Setting.simpleString("xpack.watcher.index.rest.direct_access", Setting.Property.NodeScope)); - module.registerSetting(Setting.simpleString("xpack.watcher.trigger.schedule.engine", Setting.Property.NodeScope)); - module.registerSetting(Setting.simpleString("xpack.watcher.input.search.default_timeout", Setting.Property.NodeScope)); - module.registerSetting(Setting.simpleString("xpack.watcher.transform.search.default_timeout", Setting.Property.NodeScope)); - module.registerSetting(Setting.simpleString("xpack.watcher.trigger.schedule.ticker.tick_interval", Setting.Property.NodeScope)); - module.registerSetting(Setting.simpleString("xpack.watcher.execution.scroll.timeout", Setting.Property.NodeScope)); - module.registerSetting(Setting.simpleString("xpack.watcher.start_immediately", Setting.Property.NodeScope)); + settings.add(Setting.simpleString("xpack.watcher.internal.ops.search.default_timeout", Setting.Property.NodeScope)); + settings.add(Setting.simpleString("xpack.watcher.internal.ops.bulk.default_timeout", Setting.Property.NodeScope)); + settings.add(Setting.simpleString("xpack.watcher.internal.ops.index.default_timeout", Setting.Property.NodeScope)); + settings.add(Setting.simpleString("xpack.watcher.execution.default_throttle_period", Setting.Property.NodeScope)); + settings.add(Setting.simpleString("xpack.watcher.actions.index.default_timeout", Setting.Property.NodeScope)); + settings.add(Setting.simpleString("xpack.watcher.index.rest.direct_access", Setting.Property.NodeScope)); + settings.add(Setting.simpleString("xpack.watcher.trigger.schedule.engine", Setting.Property.NodeScope)); + settings.add(Setting.simpleString("xpack.watcher.input.search.default_timeout", Setting.Property.NodeScope)); + settings.add(Setting.simpleString("xpack.watcher.transform.search.default_timeout", Setting.Property.NodeScope)); + settings.add(Setting.simpleString("xpack.watcher.trigger.schedule.ticker.tick_interval", Setting.Property.NodeScope)); + settings.add(Setting.simpleString("xpack.watcher.execution.scroll.timeout", Setting.Property.NodeScope)); + settings.add(Setting.simpleString("xpack.watcher.start_immediately", Setting.Property.NodeScope)); + return settings; } public List> getExecutorBuilders(final Settings settings) { @@ -279,4 +279,5 @@ public class Watcher { "[.watcher-history-YYYY.MM.dd] are allowed to be created", value); } + } diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java index 41d7cbc29ff..1db1130953f 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java @@ -15,6 +15,8 @@ import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; +import java.util.List; import java.util.function.Function; import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST; @@ -85,8 +87,9 @@ public class WatcherIndexTemplateRegistryTests extends AbstractWatcherIntegratio public static final Setting KEY_1 = new Setting<>("index.key1", "", Function.identity(), Setting.Property.IndexScope); - public void onModule(SettingsModule module) { - module.registerSetting(KEY_1); + @Override + public List> getSettings() { + return Collections.singletonList(KEY_1); } } }