From e50314bb6ede2fbde462fdcfab2d189cf6e5de63 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Mon, 20 Jun 2016 11:53:07 +0200 Subject: [PATCH] Remove NodeClientModule and PluginsModule --- .../client/node/NodeClientModule.java | 34 ------------------ .../client/transport/TransportClient.java | 11 +++--- .../java/org/elasticsearch/node/Node.java | 7 ++-- .../elasticsearch/plugins/PluginsModule.java | 36 ------------------- .../test/AbstractQueryTestCase.java | 3 +- 5 files changed, 8 insertions(+), 83 deletions(-) delete mode 100644 core/src/main/java/org/elasticsearch/client/node/NodeClientModule.java delete mode 100644 core/src/main/java/org/elasticsearch/plugins/PluginsModule.java diff --git a/core/src/main/java/org/elasticsearch/client/node/NodeClientModule.java b/core/src/main/java/org/elasticsearch/client/node/NodeClientModule.java deleted file mode 100644 index de134887303..00000000000 --- a/core/src/main/java/org/elasticsearch/client/node/NodeClientModule.java +++ /dev/null @@ -1,34 +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.client.node; - -import org.elasticsearch.client.Client; -import org.elasticsearch.common.inject.AbstractModule; - -/** - * - */ -public class NodeClientModule extends AbstractModule { - - @Override - protected void configure() { - bind(Client.class).to(NodeClient.class).asEagerSingleton(); - } -} 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 2c2a5ad0428..09e967b00c4 100644 --- a/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java +++ b/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java @@ -19,7 +19,6 @@ package org.elasticsearch.client.transport; -import org.elasticsearch.Version; import org.elasticsearch.action.Action; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionModule; @@ -46,7 +45,6 @@ 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; @@ -120,9 +118,6 @@ public class TransportClient extends AbstractClient { public TransportClient build() { final PluginsService pluginsService = newPluginService(providedSettings); final Settings settings = pluginsService.updatedSettings(); - - Version version = Version.CURRENT; - final ThreadPool threadPool = new ThreadPool(settings); final NetworkService networkService = new NetworkService(settings); NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(); @@ -133,7 +128,6 @@ public class TransportClient extends AbstractClient { for (Module pluginModule : pluginsService.nodeModules()) { modules.add(pluginModule); } - modules.add(new PluginsModule(pluginsService)); modules.add(new NetworkModule(networkService, settings, true, namedWriteableRegistry)); modules.add(b -> b.bind(ThreadPool.class).toInstance(threadPool)); modules.add(new SearchModule(settings, namedWriteableRegistry) { @@ -156,7 +150,10 @@ public class TransportClient extends AbstractClient { CircuitBreakerService circuitBreakerService = Node.createCircuitBreakerService(settingsModule.getSettings(), settingsModule.getClusterSettings()); modules.add(settingsModule); - modules.add((b -> b.bind(CircuitBreakerService.class).toInstance(circuitBreakerService))); + modules.add((b -> { + b.bind(PluginsService.class).toInstance(pluginsService); + 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/node/Node.java b/core/src/main/java/org/elasticsearch/node/Node.java index 9c849bbe14b..68073261959 100644 --- a/core/src/main/java/org/elasticsearch/node/Node.java +++ b/core/src/main/java/org/elasticsearch/node/Node.java @@ -27,7 +27,7 @@ import org.elasticsearch.ElasticsearchTimeoutException; import org.elasticsearch.Version; import org.elasticsearch.action.ActionModule; import org.elasticsearch.client.Client; -import org.elasticsearch.client.node.NodeClientModule; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.ClusterModule; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterStateObserver; @@ -87,7 +87,6 @@ import org.elasticsearch.monitor.jvm.JvmInfo; import org.elasticsearch.node.internal.InternalSettingsPreparer; import org.elasticsearch.node.service.NodeService; import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.plugins.PluginsModule; import org.elasticsearch.plugins.PluginsService; import org.elasticsearch.plugins.ScriptPlugin; import org.elasticsearch.repositories.RepositoriesModule; @@ -252,7 +251,6 @@ public class Node implements Closeable { modules.add(pluginModule); } final MonitorService monitorService = new MonitorService(settings, nodeEnvironment, threadPool); - modules.add(new PluginsModule(pluginsService)); modules.add(new NodeModule(this, monitorService)); modules.add(new NetworkModule(networkService, settings, false, namedWriteableRegistry)); modules.add(scriptModule); @@ -262,7 +260,6 @@ public class Node implements Closeable { modules.add(new SearchModule(settings, namedWriteableRegistry)); modules.add(new ActionModule(DiscoveryNode.isIngestNode(settings), false)); modules.add(new GatewayModule()); - modules.add(new NodeClientModule()); modules.add(new RepositoriesModule()); modules.add(new AnalysisModule(environment)); pluginsService.processModules(modules); @@ -271,6 +268,8 @@ public class Node implements Closeable { resourcesToClose.add(circuitBreakerService); modules.add(settingsModule); modules.add(b -> { + b.bind(PluginsService.class).toInstance(pluginsService); + b.bind(Client.class).to(NodeClient.class).asEagerSingleton(); b.bind(Environment.class).toInstance(environment); b.bind(ThreadPool.class).toInstance(threadPool); b.bind(NodeEnvironment.class).toInstance(nodeEnvironment); diff --git a/core/src/main/java/org/elasticsearch/plugins/PluginsModule.java b/core/src/main/java/org/elasticsearch/plugins/PluginsModule.java deleted file mode 100644 index 04e468cdd6c..00000000000 --- a/core/src/main/java/org/elasticsearch/plugins/PluginsModule.java +++ /dev/null @@ -1,36 +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.plugins; - -import org.elasticsearch.common.inject.AbstractModule; - -public class PluginsModule extends AbstractModule { - - private final PluginsService pluginsService; - - public PluginsModule(PluginsService pluginsService) { - this.pluginsService = pluginsService; - } - - @Override - protected void configure() { - bind(PluginsService.class).toInstance(pluginsService); - } -} 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 65c43fd38c6..ea2154b355e 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java @@ -93,7 +93,6 @@ import org.elasticsearch.indices.mapper.MapperRegistry; import org.elasticsearch.indices.query.IndicesQueriesRegistry; import org.elasticsearch.node.internal.InternalSettingsPreparer; import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.plugins.PluginsModule; import org.elasticsearch.plugins.PluginsService; import org.elasticsearch.script.Script.ScriptParseException; import org.elasticsearch.script.ScriptModule; @@ -889,9 +888,9 @@ public abstract class AbstractQueryTestCase> for (Module pluginModule : pluginsService.nodeModules()) { modulesBuilder.add(pluginModule); } - modulesBuilder.add(new PluginsModule(pluginsService)); modulesBuilder.add( (b) -> { + b.bind(PluginsService.class).toInstance(pluginsService); b.bind(Environment.class).toInstance(new Environment(settings)); b.bind(ThreadPool.class).toInstance(threadPool); },