Skip to content

Commit

Permalink
add mandatory plugins support in conf
Browse files Browse the repository at this point in the history
  • Loading branch information
Paikan committed Feb 17, 2012
1 parent bf36681 commit 017f48a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
9 changes: 8 additions & 1 deletion config/elasticsearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@
#
# node.rack: rack314


# By default, multiple nodes are allowed to start from the same installation location
# to disable it, set the following:
# node.max_local_storage_nodes: 1


#################################### Index ####################################

# You can set a number of options (such as shard/replica options, mapping
Expand Down Expand Up @@ -165,6 +165,13 @@
# path.plugins: /path/to/plugins


#################################### Plugin ###################################

# If a plugin listed here is not installed for current node, the node will not start.
#
# plugin.mandatory: mapper-attachments,lang-groovy


################################### Memory ####################################

# ElasticSearch performs poorly when JVM starts swapping: you should ensure that
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/org/elasticsearch/plugins/PluginsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,22 @@ public PluginsService(Settings settings, Environment environment) {
// first, find all the ones that are in the classpath
Map<String, Plugin> plugins = Maps.newHashMap();
plugins.putAll(loadPluginsFromClasspath(settings));
Set<String> sitePlugins = sitePlugins();

String[] mandatoryPlugins = settings.getAsArray("plugin.mandatory", null);
if (mandatoryPlugins != null) {
Set<String> missingPlugins = Sets.newHashSet();
for (String mandatoryPlugin : mandatoryPlugins) {
if (!plugins.containsKey(mandatoryPlugin) && !sitePlugins.contains(mandatoryPlugin) && !missingPlugins.contains(mandatoryPlugin)) {
missingPlugins.add(mandatoryPlugin);
}
}
if (!missingPlugins.isEmpty()) {
throw new ElasticSearchException("Missing mandatory plugins " + missingPlugins);
}
}

logger.info("loaded {}, sites {}", plugins.keySet(), sitePlugins());
logger.info("loaded {}, sites {}", plugins.keySet(), sitePlugins);

this.plugins = ImmutableMap.copyOf(plugins);

Expand Down

0 comments on commit 017f48a

Please sign in to comment.