elasticsearch启动过程(4) 各个模块介绍

elasticsearch启动过程(4) 各个模块介绍

在es程序运行到 InternalNode 中时,在此类的构造方法中完成了各个模块添加,依赖注入等服务。这些服务为es运行时的各种功能服务。

1.modules.add(new Version.Module(version))
Version 中维护了各个版本的version对象,CURRENT为最新对象,包含了版本id,luceneVersion,snapshot,build等信息。

2.modules.add(new CacheRecyclerModule(settings))
初始化了多个Recycler,Recycler中封装了hppc(高性能的原始集合) 库中map。并且使用了重用机制,通过队列使的这些map对象可以回收并新利用,每个map使用Recycler进行调用, 并且加入了threadLocal,cocurrent,softreference,根据配置,Recycler可以有不同的策略。避免多个地方使用集合需要进行多次初始化来申请内存。并且减少垃圾回收。

3. modules.add(new PageCacheRecyclerModule(settings))
初始化了多个Recycler,Recycler中封装了各中数据,byte[],int[],long[],double[],Object[],同样使用重用机制,并且加入了threadLocal,cocurrent,softreference,根据配置,Recycler可以有不同的策略。避免多个地方使用集合需要进行多次初始化来申请内存。并且减少垃圾回收。

4.modules.add(new PluginsModule(settings, pluginsService))
plugin模块,根据各种配置如:es-plugin.properties配置,setting中plugin.types 配置,es的plugin路径等来生成PluginInfo对象,Plugin对象,这里大量使用反射。

5.modules.add(new SettingsModule(settings))
配置模块,维护了es的各种配置信息。

6.modules.add(new NodeModule(this))
节点模块,初始化node,nodesettting,NodeService,重点是NodeService,将node所需要使用的各个service进行对象属性初始化,如,threadPool,Discovery,TransportService,IndicesService等。可以从NodeService哪里获取到节点信息(NodeInfo),节点统计(NodeStats)对象。NodeSettingsService用来是已注册节点拥有最新的配置。

7.modules.add(new NetworkModule())
网络服务,NetworkService,用于解析settings中的网络配置,获取InetAddress对象

8.modules.add(new NodeCacheModule(settings))
节点缓存,初始化ByteBufferCache,用于获取ByteBuffer。

9.modules.add(new ScriptModule(settings))
主要是两者的初始化(1)MvelScriptEngineService(mvel是基于java的表达式语言)的初始化,(2)根据settings中script.native.?.type 中的配置来初始化NativeScriptEngineService

10,modules.add(new EnvironmentModule(environment))
es的环境变量信息模块,根据配置初始化 homefile,workfile,logsfile,datafiles 等路径。

11.modules.add(new EnvironmentModule(environment))
节点环境模块,根据environment来初始化节点环境,初始化了节点存储data的路径数组,节点索引位置数组,和目录锁数组。

12.modules.add(new ClusterNameModule(settings))
集群名称,根据配置文件初始化集群名称,默认集群名称为elasticsearch

13.modules.add(new ThreadPoolModule(settings))
线程池模块,为不同服务初始化不同的线程池。根据以下这个常量,初始化对应的线程池

public static final String SAME = "same";
    public static final String GENERIC = "generic";
    public static final String GET = "get";
    public static final String INDEX = "index";
    public static final String BULK = "bulk";
    public static final String SEARCH = "search";
    public static final String SUGGEST = "suggest";
    public static final String PERCOLATE = "percolate";
    public static final String MANAGEMENT = "management";
    public static final String FLUSH = "flush";
    public static final String MERGE = "merge";
    public static final String REFRESH = "refresh";
    public static final String WARMER = "warmer";
    public static final String SNAPSHOT = "snapshot";
    public static final String OPTIMIZE = "optimize";

14.modules.add(new DiscoveryModule(settings))
节点发现模块

15.modules.add(new ClusterModule(settings))
集群模块,初始化集群相关的service,主要是索引相关的服务,比如MetaDataService,MetaDataCreateIndexService,MetaDataDeleteIndexService,MetaDataMappingService,RoutingService等,主要包含以下功能:索引的创建、删除,mapping创建,索引别名,索引更新,索引模板,路由,分片状态,mapping刷新,集群信息。

16.modules.add(new RestModule(settings))
rest模块

17.modules.add(new TransportModule(settings))
节点通信模块,每个节点四种类型连接,low/med/high/ping,low用来处理高负载的api,比如批处理,med用来处理查询或者索引单个文档,high用来集群状态,ping用来节点跟其他几点间发送ping请求。

18.modules.add(new HttpServerModule(settings))
跟transport类似,使用http进行通信。

19.modules.add(new RiversModule(settings))
es的river服务,用于同步其他数据源的数据到es,用户可以自定义river,通过RiversModule进行注册。我们看一下river接口。

package org.elasticsearch.river;

/**
 * Allows to import data into elasticsearch via plugin
 * Gets allocated on a node and eventually automatically re-allocated if needed
 */
public interface River extends RiverComponent {

/**
 * Called whenever the river is registered on a node, which can happen when:
 * 1) the river _meta document gets indexed
 * 2) an already registered river gets started on a node
 */
void start();

/**
 * Called when the river is closed on a node, which can happen when:
 * 1) the river is deleted by deleting its type through the delete mapping api
 * 2) the node where the river is allocated is shut down or the river gets rerouted to another node
 */
void close();
}

20.modules.add(new IndicesModule(settings))
索引模块,初始化索引相关服务,如IndicesClusterStateService,IndicesTermsFilterCache,IndicesFieldDataCache,IndicesStore,IndexingMemoryController等。

21.modules.add(new SearchModule())
查询模块,初始化查询相关的服务

22.modules.add(new ActionModule(false))
elasticsearch中的绝大部分操作都有相应的action,这些action在action包中。

23.modules.add(new MonitorModule(settings))
es的各种监控服务,比如network,jvm,fs等。

24.modules.add(new GatewayModule(settings))
gateway 模块负责当集群 full restart 时的元信息(state)数据恢复.

25.modules.add(new NodeClientModule())
es客户端模块。

26.modules.add(new BulkUdpModule())
udp bulk,在最新6.3版本中已经移除,使用表中bulk api替代。

27.modules.add(new ShapeModule())
地理位置模块

28.modules.add(new PercolatorModule()
percolate用来匹配在索引中存储的查询条件,percolator 操作通过注册查询条件,然后通过percolate请求(包含文档),来查询符合该请求的查询条件。
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-percolate-query.html#_sample_usage

29.modules.add(new ResourceWatcherModule())
资源监控模块,其他es服务需要监控的信息可以注册到资源监控服务。ResourceWatcherService定期的回去这些注册的类中的接口方法,默认间隔60s。

30.modules.add(new RepositoriesModule())
Snapshot repository模块。负责索引或者集群级别的操作,仅仅能够在master上调用。

31.modules.add(new TribeModule())
tribeService, tribe node可以连接多个集群,它可以接收每个集群的状态,然后合并成一个全局集群的状态,它可以读写所有节点上的数据,合并的全局集群状态意味着几乎所有操作都以与单个集群相同的方式工作:分布式搜索,索引等。在5.4.0中弃用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值