@@ -42,9 +42,6 @@ were left unconsumed.
42426 . The response is written to the ` RestChannel ` , either as a [ single payload] [ RestToXContentListener ] or a
4343[ stream of chunks] [ RestChunkedToXContentListener ] .
4444
45- A Netty channel eventLoop thread executes step 1 to 3. The [ RestChannelConsumer] delegates execution to a task manager thread, which processes
46- the request and eventually returns control to the original event loop thread to write the response back to the Netty channel.
47-
4845### Request interceptor
4946
5047The [ RestController] accepts a [ RestInterceptor] that can intercept [ RestRequest] s and add additional pre-handling. A single
@@ -104,6 +101,16 @@ are coordinated.
104101> does not hold, in those cases you can locate the transport action for a REST action by looking at the ` NodeClient ` invocation in the
105102> ` Rest*Action ` 's ` prepareRequest ` implementation, it should specify the ` ActionType ` being invoked which can then be used to locate
106103> the ` Transport*Action ` class that handles it.
104+ >
105+ > A netty [ EventLoop] thread handles the initial steps of a Rest* Action request lifecycle such as decoding, validation and routing.
106+ > Upon entry into the "transport layer", [ NodeClient] delegates the remaining processing to its [ TaskManager] thread. The [ TaskManager]
107+ > thread eventually returns control to the original [ EventLoop] thread to write the response back to the Netty channel.
108+ >
109+ > [ TransportAction] can also be initiated through peer-to-peer communication between nodes. In such cases, the [ InboundHandler]
110+ > locates the appropriate [ TransportAction] by consulting the [ NamedRegistry] , then invokes its handleExecution() method. When a [ TransportAction]
111+ > is registered, it can specify an executor to control how the action is run. One option is the DIRECT_EXECUTOR_SERVICE, which executes the
112+ > action on the calling thread. However, this should be used with caution—it's only appropriate when the action is lightweight.
113+ > Otherwise, it risks blocking the peer-to-peer I/O thread, potentially degrading responsiveness and causing the node to become unresponsive.
107114
108115### Action registration
109116Elasticsearch contains many [ TransportAction] s, configured statically in [ ActionModule#setupActions] . [ ActionPlugin] s can
@@ -182,6 +189,10 @@ capabilities.
182189[ TransportService ] :https://github.com/elastic/elasticsearch/blob/v9.0.1/server/src/main/java/org/elasticsearch/transport/TransportService.java
183190[ TransportSingleShardAction ] :https://github.com/elastic/elasticsearch/blob/v9.0.1/server/src/main/java/org/elasticsearch/action/support/single/shard/TransportSingleShardAction.java
184191[ Transport ] :https://github.com/elastic/elasticsearch/blob/v9.0.1/server/src/main/java/org/elasticsearch/transport/Transport.java
192+ [ EventLoop ] :https://github.com/netty/netty/blob/4.2/transport/src/main/java/io/netty/channel/EventLoop.java
193+ [ TaskManager ] :https://github.com/elastic/elasticsearch/blob/main/server/src/main/java/org/elasticsearch/tasks/TaskManager.java
194+ [ InboundHandler ] :https://github.com/elastic/elasticsearch/blob/main/server/src/main/java/org/elasticsearch/transport/InboundHandler.java
195+ [ NamedRegistry ] :https://github.com/elastic/elasticsearch/blob/main/server/src/main/java/org/elasticsearch/common/NamedRegistry.java
185196
186197## Serializations
187198
0 commit comments