diff --git a/config/elasticsearch.yml b/config/elasticsearch.yml index cf967ea55c9..6ef5d5ea7b0 100644 --- a/config/elasticsearch.yml +++ b/config/elasticsearch.yml @@ -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 @@ -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 diff --git a/src/main/java/org/elasticsearch/plugins/PluginsService.java b/src/main/java/org/elasticsearch/plugins/PluginsService.java index 0df969bb3d7..92e4aeff746 100644 --- a/src/main/java/org/elasticsearch/plugins/PluginsService.java +++ b/src/main/java/org/elasticsearch/plugins/PluginsService.java @@ -74,8 +74,22 @@ public class PluginsService extends AbstractComponent { // first, find all the ones that are in the classpath Map plugins = Maps.newHashMap(); plugins.putAll(loadPluginsFromClasspath(settings)); + Set sitePlugins = sitePlugins(); - logger.info("loaded {}, sites {}", plugins.keySet(), sitePlugins()); + String[] mandatoryPlugins = settings.getAsArray("plugin.mandatory", null); + if (mandatoryPlugins != null) { + Set 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);