add mandatory plugins support in conf

This commit is contained in:
Benjamin Devèze 2012-02-17 14:43:53 +01:00 committed by Benjamin Devèze
parent bf36681e34
commit 017f48a187
2 changed files with 23 additions and 2 deletions

View File

@ -82,11 +82,11 @@
# #
# node.rack: rack314 # node.rack: rack314
# By default, multiple nodes are allowed to start from the same installation location # By default, multiple nodes are allowed to start from the same installation location
# to disable it, set the following: # to disable it, set the following:
# node.max_local_storage_nodes: 1 # node.max_local_storage_nodes: 1
#################################### Index #################################### #################################### Index ####################################
# You can set a number of options (such as shard/replica options, mapping # You can set a number of options (such as shard/replica options, mapping
@ -165,6 +165,13 @@
# path.plugins: /path/to/plugins # 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 #################################### ################################### Memory ####################################
# ElasticSearch performs poorly when JVM starts swapping: you should ensure that # ElasticSearch performs poorly when JVM starts swapping: you should ensure that

View File

@ -74,8 +74,22 @@ public class PluginsService extends AbstractComponent {
// first, find all the ones that are in the classpath // first, find all the ones that are in the classpath
Map<String, Plugin> plugins = Maps.newHashMap(); Map<String, Plugin> plugins = Maps.newHashMap();
plugins.putAll(loadPluginsFromClasspath(settings)); plugins.putAll(loadPluginsFromClasspath(settings));
Set<String> sitePlugins = sitePlugins();
logger.info("loaded {}, sites {}", plugins.keySet(), 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);
this.plugins = ImmutableMap.copyOf(plugins); this.plugins = ImmutableMap.copyOf(plugins);