Skip to content

Commit

Permalink
Internal: Add plugin modules before (almost all) others
Browse files Browse the repository at this point in the history
This change makes modules added by plugins come before others, as it was
before elastic#12783. The order of configuration, and thereby binding, happens
in the order modules are received, and without this change, some plugins
can get *insane* guice errors (500mb stack trace).
  • Loading branch information
rjernst committed Aug 23, 2015
1 parent ef592a8 commit b6d3fa2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
7 changes: 4 additions & 3 deletions core/src/main/java/org/elasticsearch/index/IndexService.java
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ public synchronized IndexShard createShard(int sShardId, ShardRouting routing) {
final boolean canDeleteShardContent = IndexMetaData.isOnSharedFilesystem(indexSettings) == false ||
(primary && IndexMetaData.isOnSharedFilesystem(indexSettings));
ModulesBuilder modules = new ModulesBuilder();
// plugin modules must be added here, before others or we can get crazy injection errors...
for (Module pluginModule : pluginsService.shardModules(indexSettings)) {
modules.add(pluginModule);
}
modules.add(new IndexShardModule(shardId, primary, indexSettings));
modules.add(new StoreModule(injector.getInstance(IndexStore.class).shardDirectory(), lock,
new StoreCloseListener(shardId, canDeleteShardContent, new Closeable() {
Expand All @@ -326,9 +330,6 @@ public void close() throws IOException {
}), path));
modules.add(new DeletionPolicyModule());

for (Module pluginModule : pluginsService.shardModules(indexSettings)) {
modules.add(pluginModule);
}
pluginsService.processModules(modules);

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ public synchronized IndexService createIndex(String sIndexName, @IndexSettings S
modules.add(new IndexNameModule(index));
modules.add(new LocalNodeIdModule(localNodeId));
modules.add(new IndexSettingsModule(index, indexSettings));
// plugin modules must be added here, before others or we can get crazy injection errors...
for (Module pluginModule : pluginsService.indexModules(indexSettings)) {
modules.add(pluginModule);
}
modules.add(new IndexStoreModule(indexSettings));
modules.add(new AnalysisModule(indexSettings, indicesAnalysisService));
modules.add(new SimilarityModule(indexSettings));
Expand All @@ -332,10 +336,7 @@ public synchronized IndexService createIndex(String sIndexName, @IndexSettings S
modules.add(new MapperServiceModule());
modules.add(new IndexAliasesServiceModule());
modules.add(new IndexModule(indexSettings));

for (Module pluginModule : pluginsService.indexModules(indexSettings)) {
modules.add(pluginModule);
}

pluginsService.processModules(modules);

Injector indexInjector;
Expand Down
8 changes: 5 additions & 3 deletions core/src/main/java/org/elasticsearch/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ public Node(Settings preparedSettings, boolean loadConfigSettings) {
ModulesBuilder modules = new ModulesBuilder();
modules.add(new Version.Module(version));
modules.add(new CircuitBreakerModule(settings));
// plugin modules must be added here, before others or we can get crazy injection errors...
for (Module pluginModule : pluginsService.nodeModules()) {
modules.add(pluginModule);
}
modules.add(new PluginsModule(pluginsService));
modules.add(new SettingsModule(settings));
modules.add(new NodeModule(this));
Expand Down Expand Up @@ -188,9 +192,7 @@ public Node(Settings preparedSettings, boolean loadConfigSettings) {
modules.add(new RepositoriesModule());
modules.add(new TribeModule());

for (Module pluginModule : pluginsService.nodeModules()) {
modules.add(pluginModule);
}

pluginsService.processModules(modules);

injector = modules.createInjector();
Expand Down

0 comments on commit b6d3fa2

Please sign in to comment.