日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

elasticSearch6源码分析(7)node

發布時間:2025/4/5 编程问答 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 elasticSearch6源码分析(7)node 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.node概述

Any time that you start an instance of Elasticsearch, you are starting a node. A collection of connected nodes is called a cluster. If you are running a single node of Elasticsearch, then you have a cluster of one node.Every node in the cluster can handle HTTP and Transport traffic by default. The transport layer is used exclusively for communication between nodes and the Java TransportClient; the HTTP layer is used only by external REST clients. All nodes know about all the other nodes in the cluster and can forward client requests to the appropriate node. Besides that, each node serves one or more purpose:Master-eligible node A node that has node.master set to true (default), which makes it eligible to be elected as the master node, which controls the cluster. Data node A node that has node.data set to true (default). Data nodes hold data and perform data related operations such as CRUD, search, and aggregations. Ingest node A node that has node.ingest set to true (default). Ingest nodes are able to apply an ingest pipeline to a document in order to transform and enrich the document before indexing. With a heavy ingest load, it makes sense to use dedicated ingest nodes and to mark the master and data nodes as node.ingest: false. Tribe node A tribe node, configured via the tribe.* settings, is a special type of coordinating only node that can connect to multiple clusters and perform search and other operations across all connected clusters. By default a node is a master-eligible node and a data node, plus it can pre-process documents through ingest pipelines. This is very convenient for small clusters but, as the cluster grows, it becomes important to consider separating dedicated master-eligible nodes from dedicated data nodes.

2.配置Node類

/*** A node represent a node within a cluster ({@code cluster.name}). The {@link #client()} can be used* in order to use a {@link Client} to perform actions/operations against the cluster.*/public static final Setting<Boolean> WRITE_PORTS_FILE_SETTING =Setting.boolSetting("node.portsfile", false, Property.NodeScope);public static final Setting<Boolean> NODE_DATA_SETTING = Setting.boolSetting("node.data", true, Property.NodeScope);public static final Setting<Boolean> NODE_MASTER_SETTING =Setting.boolSetting("node.master", true, Property.NodeScope);public static final Setting<Boolean> NODE_INGEST_SETTING =Setting.boolSetting("node.ingest", true, Property.NodeScope);

3.node通信 :NodeClient.java

private < Request extends ActionRequest,Response extends ActionResponse> TransportAction<Request, Response> transportAction(Action<Response> action) {if (actions == null) {throw new IllegalStateException("NodeClient has not been initialized");}TransportAction<Request, Response> transportAction = actions.get(action);if (transportAction == null) {throw new IllegalStateException("failed to find action [" + action + "] to execute");}return transportAction;}

4.TransportAction.java(node之間通信,走tcp)

/*** Execute the transport action on the local node, returning the {@link Task} used to track its execution and accepting a* {@link TaskListener} which listens for the completion of the action.*/public final Task execute(Request request, TaskListener<Response> listener) {Task task = taskManager.register("transport", actionName, request);execute(task, request, new ActionListener<Response>() {@Overridepublic void onResponse(Response response) {if (task != null) {taskManager.unregister(task);}listener.onResponse(task, response);}@Overridepublic void onFailure(Exception e) {if (task != null) {taskManager.unregister(task);}listener.onFailure(task, e);}});return task;}

?

轉載于:https://www.cnblogs.com/davidwang456/p/10114434.html

總結

以上是生活随笔為你收集整理的elasticSearch6源码分析(7)node的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。