Remove NodeClientModule and PluginsModule

This commit is contained in:
Simon Willnauer 2016-06-20 11:53:07 +02:00
parent fb713774a1
commit e50314bb6e
5 changed files with 8 additions and 83 deletions

View File

@ -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();
}
}

View File

@ -19,7 +19,6 @@
package org.elasticsearch.client.transport; package org.elasticsearch.client.transport;
import org.elasticsearch.Version;
import org.elasticsearch.action.Action; import org.elasticsearch.action.Action;
import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionModule; import org.elasticsearch.action.ActionModule;
@ -46,7 +45,6 @@ import org.elasticsearch.monitor.MonitorService;
import org.elasticsearch.node.Node; import org.elasticsearch.node.Node;
import org.elasticsearch.node.internal.InternalSettingsPreparer; import org.elasticsearch.node.internal.InternalSettingsPreparer;
import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.PluginsModule;
import org.elasticsearch.plugins.PluginsService; import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.search.SearchModule; import org.elasticsearch.search.SearchModule;
import org.elasticsearch.threadpool.ExecutorBuilder; import org.elasticsearch.threadpool.ExecutorBuilder;
@ -120,9 +118,6 @@ public class TransportClient extends AbstractClient {
public TransportClient build() { public TransportClient build() {
final PluginsService pluginsService = newPluginService(providedSettings); final PluginsService pluginsService = newPluginService(providedSettings);
final Settings settings = pluginsService.updatedSettings(); final Settings settings = pluginsService.updatedSettings();
Version version = Version.CURRENT;
final ThreadPool threadPool = new ThreadPool(settings); final ThreadPool threadPool = new ThreadPool(settings);
final NetworkService networkService = new NetworkService(settings); final NetworkService networkService = new NetworkService(settings);
NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(); NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry();
@ -133,7 +128,6 @@ public class TransportClient extends AbstractClient {
for (Module pluginModule : pluginsService.nodeModules()) { for (Module pluginModule : pluginsService.nodeModules()) {
modules.add(pluginModule); modules.add(pluginModule);
} }
modules.add(new PluginsModule(pluginsService));
modules.add(new NetworkModule(networkService, settings, true, namedWriteableRegistry)); modules.add(new NetworkModule(networkService, settings, true, namedWriteableRegistry));
modules.add(b -> b.bind(ThreadPool.class).toInstance(threadPool)); modules.add(b -> b.bind(ThreadPool.class).toInstance(threadPool));
modules.add(new SearchModule(settings, namedWriteableRegistry) { modules.add(new SearchModule(settings, namedWriteableRegistry) {
@ -156,7 +150,10 @@ public class TransportClient extends AbstractClient {
CircuitBreakerService circuitBreakerService = Node.createCircuitBreakerService(settingsModule.getSettings(), CircuitBreakerService circuitBreakerService = Node.createCircuitBreakerService(settingsModule.getSettings(),
settingsModule.getClusterSettings()); settingsModule.getClusterSettings());
modules.add(settingsModule); 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(); Injector injector = modules.createInjector();
final TransportService transportService = injector.getInstance(TransportService.class); final TransportService transportService = injector.getInstance(TransportService.class);

View File

@ -27,7 +27,7 @@ import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.action.ActionModule; import org.elasticsearch.action.ActionModule;
import org.elasticsearch.client.Client; 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.ClusterModule;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.ClusterStateObserver; 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.internal.InternalSettingsPreparer;
import org.elasticsearch.node.service.NodeService; import org.elasticsearch.node.service.NodeService;
import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.PluginsModule;
import org.elasticsearch.plugins.PluginsService; import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.plugins.ScriptPlugin; import org.elasticsearch.plugins.ScriptPlugin;
import org.elasticsearch.repositories.RepositoriesModule; import org.elasticsearch.repositories.RepositoriesModule;
@ -252,7 +251,6 @@ public class Node implements Closeable {
modules.add(pluginModule); modules.add(pluginModule);
} }
final MonitorService monitorService = new MonitorService(settings, nodeEnvironment, threadPool); final MonitorService monitorService = new MonitorService(settings, nodeEnvironment, threadPool);
modules.add(new PluginsModule(pluginsService));
modules.add(new NodeModule(this, monitorService)); modules.add(new NodeModule(this, monitorService));
modules.add(new NetworkModule(networkService, settings, false, namedWriteableRegistry)); modules.add(new NetworkModule(networkService, settings, false, namedWriteableRegistry));
modules.add(scriptModule); modules.add(scriptModule);
@ -262,7 +260,6 @@ public class Node implements Closeable {
modules.add(new SearchModule(settings, namedWriteableRegistry)); modules.add(new SearchModule(settings, namedWriteableRegistry));
modules.add(new ActionModule(DiscoveryNode.isIngestNode(settings), false)); modules.add(new ActionModule(DiscoveryNode.isIngestNode(settings), false));
modules.add(new GatewayModule()); modules.add(new GatewayModule());
modules.add(new NodeClientModule());
modules.add(new RepositoriesModule()); modules.add(new RepositoriesModule());
modules.add(new AnalysisModule(environment)); modules.add(new AnalysisModule(environment));
pluginsService.processModules(modules); pluginsService.processModules(modules);
@ -271,6 +268,8 @@ public class Node implements Closeable {
resourcesToClose.add(circuitBreakerService); resourcesToClose.add(circuitBreakerService);
modules.add(settingsModule); modules.add(settingsModule);
modules.add(b -> { 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(Environment.class).toInstance(environment);
b.bind(ThreadPool.class).toInstance(threadPool); b.bind(ThreadPool.class).toInstance(threadPool);
b.bind(NodeEnvironment.class).toInstance(nodeEnvironment); b.bind(NodeEnvironment.class).toInstance(nodeEnvironment);

View File

@ -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);
}
}

View File

@ -93,7 +93,6 @@ import org.elasticsearch.indices.mapper.MapperRegistry;
import org.elasticsearch.indices.query.IndicesQueriesRegistry; import org.elasticsearch.indices.query.IndicesQueriesRegistry;
import org.elasticsearch.node.internal.InternalSettingsPreparer; import org.elasticsearch.node.internal.InternalSettingsPreparer;
import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.PluginsModule;
import org.elasticsearch.plugins.PluginsService; import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.script.Script.ScriptParseException; import org.elasticsearch.script.Script.ScriptParseException;
import org.elasticsearch.script.ScriptModule; import org.elasticsearch.script.ScriptModule;
@ -889,9 +888,9 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
for (Module pluginModule : pluginsService.nodeModules()) { for (Module pluginModule : pluginsService.nodeModules()) {
modulesBuilder.add(pluginModule); modulesBuilder.add(pluginModule);
} }
modulesBuilder.add(new PluginsModule(pluginsService));
modulesBuilder.add( modulesBuilder.add(
(b) -> { (b) -> {
b.bind(PluginsService.class).toInstance(pluginsService);
b.bind(Environment.class).toInstance(new Environment(settings)); b.bind(Environment.class).toInstance(new Environment(settings));
b.bind(ThreadPool.class).toInstance(threadPool); b.bind(ThreadPool.class).toInstance(threadPool);
}, },