Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deal with the transport request sending of elasticsearch node

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of "how to deal with transport requests of elasticsearch nodes". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to deal with transport requests of elasticsearch nodes" can help you solve the problem.

The process of sending and processing transport requests

The previous article analyzes the initiation and connection of nettytransport, and this article mainly analyzes the sending and processing process of transport request.

Each node in cluster needs to send a lot of information to each other, such as master to detect the existence of other nodes, node nodes to regularly detect whether master nodes are stored, cluster status release and search data requests, and so on. In order to ensure the transmission of information, elasticsearch defines a 19-byte header HEADER_SIZE = 2 + 4 + 8 + 1 + 4, which starts with 'Eternal int', followed by a 4-byte int message length, then an 8-byte long message id, then an one-byte status, and finally a 4-byte int version.

All the information between nodes starts with these 19 bytes. At the same time, elasticsearch defines the names of all action between nodes, such as detecting action,internal:discovery/zen/fd/master_ping for the period of master, and each action corresponds to the corresponding messagehandler. A detailed analysis will be carried out next.

The sending process of request

The code in nettytransport is as follows:

Public void sendRequest (final DiscoveryNode node, final long requestId, final String action, final TransportRequest request, TransportRequestOptions options) throws IOException, TransportException {/ / Parameter description: destination node sent by node, requestId request id,action action name, request request, options includes the following operations RECOVERY,BULK,REG,STATE,PING; Channel targetChannel = nodeChannel (node, options) / / the channel,channel of the corresponding node is initialized when the node is connected (please refer to the previous article) if (compress) {options.withCompress (true);} byte status = 0; / / setting status includes the following STATUS_REQRES = 1

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report