Package org.elasticsearch.plugins
Class Plugin
- java.lang.Object
-
- org.elasticsearch.plugins.Plugin
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public abstract class Plugin extends Object implements Closeable
An extension point allowing to plug in custom functionality. This class has a number of extension points that are available to all plugins, in addition you can implement any of the following interfaces to further customize Elasticsearch:
-
-
Constructor Summary
Constructors Constructor Description Plugin()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SettingsadditionalSettings()Additional node settings loaded by the plugin.voidclose()Close the resources opened by this plugin.Collection<Object>createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry)Returns components added by this plugin.Collection<Module>createGuiceModules()Node level guice modules.List<BootstrapCheck>getBootstrapChecks()Returns a list of checks that are enforced when a node starts up once a node has the transport protocol bound to a non-loopback interface.List<ExecutorBuilder<?>>getExecutorBuilders(Settings settings)Provides the list of this plugin's custom thread pools, empty if none.protected Optional<String>getFeature()A feature exposed by the plugin.Collection<Class<? extends LifecycleComponent>>getGuiceServiceClasses()Node level services that will be automatically started/stopped/closed.UnaryOperator<Map<String,IndexTemplateMetaData>>getIndexTemplateMetaDataUpgrader()Provides a function to modify index template meta data on startup.List<NamedWriteableRegistry.Entry>getNamedWriteables()Returns parsers forNamedWriteablethis plugin will use over the transport protocol.List<NamedXContentRegistry.Entry>getNamedXContent()Returns parsers for named objects this plugin will parse fromXContentParser.namedObject(Class, String, Object).Set<DiscoveryNodeRole>getRoles()List<Setting<?>>getSettings()Returns a list of additionalSettingdefinitions for this plugin.List<String>getSettingsFilter()Returns a list of additional settings filter for this pluginList<SettingUpgrader<?>>getSettingUpgraders()Get the setting upgraders provided by this plugin.voidonIndexModule(IndexModule indexModule)Called before a new index is created on a node.
-
-
-
Method Detail
-
getFeature
protected Optional<String> getFeature()
A feature exposed by the plugin. This should be used if a plugin exposesClusterState.CustomorMetaData.Custom; see alsoClusterState.FeatureAware.- Returns:
- a feature set represented by this plugin, or the empty optional if the plugin does not expose cluster state or metadata customs
-
createGuiceModules
public Collection<Module> createGuiceModules()
Node level guice modules.
-
getGuiceServiceClasses
public Collection<Class<? extends LifecycleComponent>> getGuiceServiceClasses()
Node level services that will be automatically started/stopped/closed. This classes must be constructed by injection with guice.
-
createComponents
public Collection<Object> createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry)
Returns components added by this plugin. Any components returned that implementLifecycleComponentwill have their lifecycle managed. Note: To aid in the migration away from guice, all objects returned as components will be bound in guice to themselves.- Parameters:
client- A client to make requests to the systemclusterService- A service to allow watching and updating cluster statethreadPool- A service to allow retrieving an executor to run an async actionresourceWatcherService- A service to watch for changes to node local filesscriptService- A service to allow running scripts on the local nodexContentRegistry- the registry for extensible xContent parsingenvironment- the environment for path and setting configurationsnodeEnvironment- the node environment used coordinate access to the data pathsnamedWriteableRegistry- the registry forNamedWriteableobject parsing
-
additionalSettings
public Settings additionalSettings()
Additional node settings loaded by the plugin. Note that settings that are explicit in the nodes settings can't be overwritten with the additional settings. These settings added if they don't exist.
-
getNamedWriteables
public List<NamedWriteableRegistry.Entry> getNamedWriteables()
Returns parsers forNamedWriteablethis plugin will use over the transport protocol.- See Also:
NamedWriteableRegistry
-
getNamedXContent
public List<NamedXContentRegistry.Entry> getNamedXContent()
Returns parsers for named objects this plugin will parse fromXContentParser.namedObject(Class, String, Object).- See Also:
NamedWriteableRegistry
-
onIndexModule
public void onIndexModule(IndexModule indexModule)
Called before a new index is created on a node. The given module can be used to register index-level extensions.
-
getSettings
public List<Setting<?>> getSettings()
Returns a list of additionalSettingdefinitions for this plugin.
-
getSettingsFilter
public List<String> getSettingsFilter()
Returns a list of additional settings filter for this plugin
-
getSettingUpgraders
public List<SettingUpgrader<?>> getSettingUpgraders()
Get the setting upgraders provided by this plugin.- Returns:
- the settings upgraders
-
getIndexTemplateMetaDataUpgrader
public UnaryOperator<Map<String,IndexTemplateMetaData>> getIndexTemplateMetaDataUpgrader()
Provides a function to modify index template meta data on startup.Plugins should return the input template map via
UnaryOperator.identity()if no upgrade is required.The order of the template upgrader calls is undefined and can change between runs so, it is expected that plugins will modify only templates owned by them to avoid conflicts.
- Returns:
- Never
null. The same or upgradedIndexTemplateMetaDatamap. - Throws:
IllegalStateException- if the node should not start because at least oneIndexTemplateMetaDatacannot be upgraded
-
getExecutorBuilders
public List<ExecutorBuilder<?>> getExecutorBuilders(Settings settings)
Provides the list of this plugin's custom thread pools, empty if none.- Parameters:
settings- the current settings- Returns:
- executors builders for this plugin's custom thread pools
-
getBootstrapChecks
public List<BootstrapCheck> getBootstrapChecks()
Returns a list of checks that are enforced when a node starts up once a node has the transport protocol bound to a non-loopback interface. In this case we assume the node is running in production and all bootstrap checks must pass. This allows plugins to provide a better out of the box experience by pre-configuring otherwise (in production) mandatory settings or to enforce certain configurations like OS settings or 3rd party resources.
-
getRoles
public Set<DiscoveryNodeRole> getRoles()
-
close
public void close() throws IOExceptionClose the resources opened by this plugin.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- if the plugin failed to close its resources
-
-