From efece285d3073131aea4b94f03e19051198897c2 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Tue, 19 Jan 2016 17:33:17 +0100 Subject: [PATCH] TransportClient should use updated setting for initialization of modules and service Today the TransportClient uses the given settings rather than the updated setting from the plugin service to pass on to it's modules etc. It should use the updates settings instead. --- .../client/transport/TransportClient.java | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) 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 b870c68c792..3d68e642c46 100644 --- a/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java +++ b/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java @@ -82,7 +82,7 @@ public class TransportClient extends AbstractClient { */ public static class Builder { - private Settings settings = Settings.EMPTY; + private Settings providedSettings = Settings.EMPTY; private List> pluginClasses = new ArrayList<>(); /** @@ -96,7 +96,7 @@ public class TransportClient extends AbstractClient { * The settings to configure the transport client with. */ public Builder settings(Settings settings) { - this.settings = settings; + this.providedSettings = settings; return this; } @@ -108,21 +108,22 @@ public class TransportClient extends AbstractClient { return this; } + private PluginsService newPluginService(final Settings settings) { + final Settings.Builder settingsBuilder = settingsBuilder() + .put(NettyTransport.PING_SCHEDULE, "5s") // enable by default the transport schedule ping interval + .put( InternalSettingsPreparer.prepareSettings(settings)) + .put("network.server", false) + .put("node.client", true) + .put(CLIENT_TYPE_SETTING, CLIENT_TYPE); + return new PluginsService(settingsBuilder.build(), null, null, pluginClasses); + }; + /** * Builds a new instance of the transport client. */ public TransportClient build() { - Settings settings = InternalSettingsPreparer.prepareSettings(this.settings); - settings = settingsBuilder() - .put(NettyTransport.PING_SCHEDULE, "5s") // enable by default the transport schedule ping interval - .put(settings) - .put("network.server", false) - .put("node.client", true) - .put(CLIENT_TYPE_SETTING, CLIENT_TYPE) - .build(); - - PluginsService pluginsService = new PluginsService(settings, null, null, pluginClasses); - this.settings = pluginsService.updatedSettings(); + final PluginsService pluginsService = newPluginService(providedSettings); + final Settings settings = pluginsService.updatedSettings(); Version version = Version.CURRENT; @@ -139,9 +140,9 @@ public class TransportClient extends AbstractClient { modules.add(pluginModule); } modules.add(new PluginsModule(pluginsService)); - modules.add(new SettingsModule(this.settings, settingsFilter )); - modules.add(new NetworkModule(networkService, this.settings, true, namedWriteableRegistry)); - modules.add(new ClusterNameModule(this.settings)); + modules.add(new SettingsModule(settings, settingsFilter )); + modules.add(new NetworkModule(networkService, settings, true, namedWriteableRegistry)); + modules.add(new ClusterNameModule(settings)); modules.add(new ThreadPoolModule(threadPool)); modules.add(new SearchModule(settings, namedWriteableRegistry) { @Override @@ -150,7 +151,7 @@ public class TransportClient extends AbstractClient { } }); modules.add(new ActionModule(true)); - modules.add(new CircuitBreakerModule(this.settings)); + modules.add(new CircuitBreakerModule(settings)); pluginsService.processModules(modules);