Skip to content

Commit

Permalink
TransportClient does not load plugins, closes elastic#1982.
Browse files Browse the repository at this point in the history
  • Loading branch information
kimchy committed May 25, 2012
1 parent 8a0f599 commit 2b533db
Showing 1 changed file with 14 additions and 1 deletion.
Expand Up @@ -49,6 +49,7 @@
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;
Expand All @@ -62,6 +63,8 @@
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;
Expand All @@ -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;
Expand Down Expand Up @@ -141,13 +146,17 @@ public TransportClient(Settings.Builder settings, boolean loadConfigSettings) th
*/
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());
Expand Down Expand Up @@ -238,6 +247,10 @@ public void close() {
// 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);
Expand Down

0 comments on commit 2b533db

Please sign in to comment.