参考
1 | https://dzone.com/articles/elasticsearch5-how-to-build-a-plugin-and-add-a-lis |
Es的插件主要有如下几种类型,参考
1 | https://github.com/elastic/elasticsearch/tree/master/server/src/main/java/org/elasticsearch/plugins |
API Extension Plugins API拓展插件:API extension plugins add new functionality to Elasticsearch by adding new APIs or features, usually to do with search or mapping.
Analysis Plugins 解析器插件:Analysis plugins extend Elasticsearch by adding new analyzers, tokenizers, token filters, or character filters to Elasticsearch.
Alerting Plugins 告警插件:Alerting plugins allow Elasticsearch to monitor indices and to trigger alerts when thresholds are breached.
Discovery Plugins 发现插件:Discovery plugins extend Elasticsearch by adding new discovery mechanisms that can be used instead of Zen Discovery.
Ingest Plugins 摄取插件:The ingest plugins extend Elasticsearch by providing additional ingest node capabilities.
Management Plugins 管理插件:Management plugins offer UIs for managing and interacting with Elasticsearch.
Mapper Plugins Mapper插件:Mapper plugins allow new field datatypes to be added to Elasticsearch.
Security Plugins 安全插件:Security plugins add a security layer to Elasticsearch.
Snapshot/Restore Repository Plugins 快照插件:Repository plugins extend the Snapshot/Restore functionality in Elasticsearch by adding repositories backed by the cloud or by distributed file systems:
Store Plugins 存储插件:Store plugins offer alternatives to default Lucene stores.
ActionPlugin:An additional extension point for {@link Plugin}s that extends Elasticsearch’s scripting functionality
1 | https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/plugins/ActionPlugin.java |
CircuitBreakerPlugin 断路器插件:An extension point for {@link Plugin} implementations to add custom circuit breakers
1 | https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/plugins/CircuitBreakerPlugin.java |
ClusterPlugin 集群插件:An extension point for {@link Plugin} implementations to customer behavior of cluster management.
1 | https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/plugins/ClusterPlugin.java |
EnginePlugin 引擎插件:A plugin that provides alternative engine implementations.
1 | https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/plugins/EnginePlugin.java |
ExtensiblePlugin 拓展插件:This class provides a callback for extensible plugins to be informed of other plugins which extend them.
1 | https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/plugins/ExtensiblePlugin.java |
IndexStorePlugin 索引存储插件:A plugin that provides alternative directory implementations.
1 | https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/plugins/IndexStorePlugin.java |
NetworkPlugin 网络插件:Plugin for extending network and transport related classes
1 | https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/plugins/NetworkPlugin.java |
PersistentTaskPlugin 持续任务插件:Plugin for registering persistent tasks executors.
1 | https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/plugins/PersistentTaskPlugin.java |
ReloadablePlugin Reload插件:An extension point for {@link Plugin}s that can be reloaded. There is no clear definition about what reloading a plugin actually means. When a plugin is reloaded it might rebuild any internal members. Plugins usually implement this interface in order to reread the values of {@code SecureSetting}s and then rebuild any dependent internal members.
1 | https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/plugins/ReloadablePlugin.java |
RestCompatibilityPlugin Rest兼容性插件:An extension point for Compatible API plugin implementation.
1 | https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/plugins/RestCompatibilityPlugin.java |
ScriptPlugin 脚本插件:An additional extension point for {@link Plugin}s that extends Elasticsearch’s scripting functionality.
1 | https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/plugins/ScriptPlugin.java |
SearchPlugin 搜索插件:Plugin for extending search time behavior.
1 | https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/plugins/SearchPlugin.java |
SystemIndexPlugin 系统索引插件:Plugin for defining system indices. Extends {@link ActionPlugin} because system indices must be accessed via APIs added by the plugin that owns the system index, rather than standard APIs.
1 | https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/plugins/SystemIndexPlugin.java |
编写es插件的时候需要提供2类文件
1 | lintong@master:~/software/apache/elasticsearch-6.2.4/plugins/analysis-ik$ ls |
一个是plugin-descriptor.properties文件,里面是插件的一些信息,比如
1 | description=自定义插件 |
一个是插件的jar包文件
在es启动的过程中,首先会启动节点node,之后PluginsService会加载这个node目录下的插件,可以看到my plugin这个插件已经成功加载
1 | [2021-04-29T10:14:15,061][INFO ][o.e.n.Node ] [] initializing ... |