Class Plugin

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public abstract class Plugin
    extends java.lang.Object
    implements java.io.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:

    In addition to extension points this class also declares some @Deprecated public final void onModule methods. These methods should cause any extensions of Plugin that used the pre-5.x style extension syntax to fail to build and point the plugin author at the new extension syntax. We hope that these make the process of upgrading a plugin from 2.x to 5.x only mildly painful.

    • Constructor Detail

      • Plugin

        public Plugin()
    • Method Detail

      • getFeature

        protected java.util.Optional<java.lang.String> getFeature()
        A feature exposed by the plugin. This should be used if a plugin exposes ClusterState.Custom or MetaData.Custom; see also ClusterState.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 java.util.Collection<Module> createGuiceModules()
        Node level guice modules.
      • getGuiceServiceClasses

        public java.util.Collection<java.lang.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 java.util.Collection<java.lang.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 implement LifecycleComponent will 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 system
        clusterService - A service to allow watching and updating cluster state
        threadPool - A service to allow retrieving an executor to run an async action
        resourceWatcherService - A service to watch for changes to node local files
        scriptService - A service to allow running scripts on the local node
        xContentRegistry - the registry for extensible xContent parsing
        environment - the environment for path and setting configurations
        nodeEnvironment - the node environment used coordinate access to the data paths
        namedWriteableRegistry - the registry for NamedWriteable object 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.
      • 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 java.util.List<Setting<?>> getSettings()
        Returns a list of additional Setting definitions for this plugin.
      • getSettingsFilter

        public java.util.List<java.lang.String> getSettingsFilter()
        Returns a list of additional settings filter for this plugin
      • getSettingUpgraders

        public java.util.List<SettingUpgrader<?>> getSettingUpgraders()
        Get the setting upgraders provided by this plugin.
        Returns:
        the settings upgraders
      • getCustomMetaDataUpgrader

        public java.util.function.UnaryOperator<java.util.Map<java.lang.String,​MetaData.Custom>> getCustomMetaDataUpgrader()
        Provides a function to modify global custom meta data on startup.

        Plugins should return the input custom map via UnaryOperator.identity() if no upgrade is required.

        The order of custom meta data upgraders calls is undefined and can change between runs so, it is expected that plugins will modify only data owned by them to avoid conflicts.

        Returns:
        Never null. The same or upgraded MetaData.Custom map.
        Throws:
        java.lang.IllegalStateException - if the node should not start because at least one MetaData.Custom is unsupported
      • getIndexTemplateMetaDataUpgrader

        public java.util.function.UnaryOperator<java.util.Map<java.lang.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 upgraded IndexTemplateMetaData map.
        Throws:
        java.lang.IllegalStateException - if the node should not start because at least one IndexTemplateMetaData cannot be upgraded
      • getIndexMetaDataUpgrader

        public java.util.function.UnaryOperator<IndexMetaData> getIndexMetaDataUpgrader()
        Provides a function to modify index meta data when an index is introduced into the cluster state for the first time.

        Plugins should return the input index metadata via UnaryOperator.identity() if no upgrade is required.

        The order of the index upgrader calls for the same index is undefined and can change between runs so, it is expected that plugins will modify only indices owned by them to avoid conflicts.

        Returns:
        Never null. The same or upgraded IndexMetaData.
        Throws:
        java.lang.IllegalStateException - if the node should not start because the index is unsupported
      • getExecutorBuilders

        public java.util.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 java.util.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.
      • close

        public void close()
                   throws java.io.IOException
        Close the resources opened by this plugin.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException - if the plugin failed to close its resources
      • onModule

        @Deprecated
        public final void onModule​(IndexModule indexModule)
        Deprecated.
        use #onIndexModule instead
        Old-style guice index level extension point. @Deprecated and final to act as a signpost for plugin authors upgrading from 2.x.
      • onModule

        @Deprecated
        public final void onModule​(SettingsModule settingsModule)
        Deprecated.
        use #getSettings and #getSettingsFilter instead
        Old-style guice settings extension point. @Deprecated and final to act as a signpost for plugin authors upgrading from 2.x.
      • onModule

        @Deprecated
        public final void onModule​(ScriptModule module)
        Deprecated.
        implement ScriptPlugin instead
        Old-style guice scripting extension point. @Deprecated and final to act as a signpost for plugin authors upgrading from 2.x.
      • onModule

        @Deprecated
        public final void onModule​(AnalysisModule module)
        Deprecated.
        implement AnalysisPlugin instead
        Old-style analysis extension point. @Deprecated and final to act as a signpost for plugin authors upgrading from 2.x.
      • onModule

        @Deprecated
        public final void onModule​(ActionModule module)
        Deprecated.
        implement ActionPlugin instead
        Old-style action extension point. @Deprecated and final to act as a signpost for plugin authors upgrading from 2.x.
      • onModule

        @Deprecated
        public final void onModule​(SearchModule module)
        Deprecated.
        implement SearchPlugin instead
        Old-style search extension point. @Deprecated and final to act as a signpost for plugin authors upgrading from 2.x.
      • onModule

        @Deprecated
        public final void onModule​(NetworkModule module)
        Deprecated.
        implement NetworkPlugin instead
        Old-style network extension point. @Deprecated and final to act as a signpost for plugin authors upgrading from 2.x.
      • onModule

        @Deprecated
        public final void onModule​(RepositoriesModule module)
        Deprecated.
        implement RepositoryPlugin instead
        Old-style snapshot/restore extension point. @Deprecated and final to act as a signpost for plugin authors upgrading from 2.x.
      • onModule

        @Deprecated
        public final void onModule​(ClusterModule module)
        Deprecated.
        implement ClusterPlugin instead
        Old-style cluster extension point. @Deprecated and final to act as a signpost for plugin authors upgrading from 2.x.
      • onModule

        @Deprecated
        public final void onModule​(DiscoveryModule module)
        Deprecated.
        implement DiscoveryPlugin instead
        Old-style discovery extension point. @Deprecated and final to act as a signpost for plugin authors upgrading from 2.x.