TransportClient does not load plugins, closes #1982.

This commit is contained in:
Shay Banon 2012-05-26 00:22:00 +02:00
parent e50fffdaeb
commit 4504fc2937
1 changed files with 14 additions and 1 deletions

View File

@ -49,6 +49,7 @@ import org.elasticsearch.cluster.ClusterNameModule;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.CacheRecycler;
import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.component.LifecycleComponent;
import org.elasticsearch.common.inject.Injector;
import org.elasticsearch.common.inject.ModulesBuilder;
import org.elasticsearch.common.io.CachedStreams;
@ -62,6 +63,8 @@ import org.elasticsearch.env.Environment;
import org.elasticsearch.env.EnvironmentModule;
import org.elasticsearch.monitor.MonitorService;
import org.elasticsearch.node.internal.InternalSettingsPerparer;
import org.elasticsearch.plugins.PluginsModule;
import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.search.TransportSearchModule;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.threadpool.ThreadPoolModule;
@ -88,6 +91,8 @@ public class TransportClient extends AbstractClient {
private final Environment environment;
private final PluginsService pluginsService;
private final TransportClientNodesService nodesService;
private final InternalTransportClient internalClient;
@ -141,13 +146,17 @@ public class TransportClient extends AbstractClient {
*/
public TransportClient(Settings pSettings, boolean loadConfigSettings) throws ElasticSearchException {
Tuple<Settings, Environment> tuple = InternalSettingsPerparer.prepareSettings(pSettings, loadConfigSettings);
this.settings = settingsBuilder().put(tuple.v1())
Settings settings = settings = settingsBuilder().put(tuple.v1())
.put("network.server", false)
.put("node.client", true)
.build();
this.environment = tuple.v2();
this.pluginsService = new PluginsService(tuple.v1(), tuple.v2());
this.settings = pluginsService.updatedSettings();
ModulesBuilder modules = new ModulesBuilder();
modules.add(new PluginsModule(settings, pluginsService));
modules.add(new EnvironmentModule(environment));
modules.add(new SettingsModule(settings));
modules.add(new NetworkModule());
@ -238,6 +247,10 @@ public class TransportClient extends AbstractClient {
// ignore, might not be bounded
}
for (Class<? extends LifecycleComponent> plugin : pluginsService.services()) {
injector.getInstance(plugin).close();
}
injector.getInstance(ThreadPool.class).shutdown();
try {
injector.getInstance(ThreadPool.class).awaitTermination(10, TimeUnit.SECONDS);