The Dubbo Remoting layer handles the layer of the underlying network communication for the Dubbo project. The class diagram is as follows:
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/7F/17/wKioL1cTX2CCU_0aAAA2JzjskWE866.png "title=" Class.png "alt=" Wkiol1ctx2ccu_0aaaa2jzjskwe866.png "/>
Channelhandler is an abstract channel event handler with the following source code.
@SPIpublic interface Channelhandler {void connected (channel channel) throws RemotingException; void disconnected (channel channel) throws RemotingException; void sent (channel channel, Object message) throws RemotingException; Void received (channel channel, Object message) throws RemotingException; VOID caught (channel channel, Throwable exception) throws RemotingException;}
Nettyserver initialization time, requires two parameters, one is the URL, and one is the (Channelhandler) channel processor.
Url
URLs are used in a Dubbo framework, in general, it is a contract, or a collection of parameters, for the configuration of individual components.
During the Nettyserver construction, the following parameters are available:
Protocol of communication Layer---Upper layer protocol of TCP
Maximum number of connections
Idle Timeout
The number of network IO processing threads, which defaults to processor +1. (But many processors are now processing two threads on a single processor, so in subsequent versions of Netty, the default is processor * + 1)
The most important, of course, is the host and port, no, how to know which port to bind to ...
2. For the channel processor, is responsible for processing, is clearly connected to the channel in the incident occurred. But the channel processor here is not Netty's pipeline, there is a layer of conversion in between, and of course, there are other operations, such as business thread delegation.
For NIO, the multiplexing model is used to deal with network events. The advantage of multiplexing is that it saves the waste of unnecessary CPU resources caused by thread context switching, but it is obviously not appropriate to thread the IO line, because business methods are likely to be blocked.
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7F/1A/wKiom1cTaw3h7jH3AABPk3788qM120.png "title=" Class.png "alt=" Wkiom1ctaw3h7jh3aabpk3788qm120.png "/>
The classes of the Netty regions are extended to the Netty self-contained classes.
Internaldecoder: is responsible for the TCP layer protocol parsing, processing TCP sticky packets. (This parsing, of course, also contains serialization processing).
Internalencoder: Protocol encapsulation.
Nettyhandler: Client channel shared processor (see Netty channel Processor model), convert Netty Channel event to Dubbo event.
Nettyserver: Number of processing connections.
Multimessagehandler: Multi-message processing.
Heartbeathandler: Heartbeat message.
Allchannelhandler: Delegating business requests to the thread pool.
---------------------------------------------------------------------------------------------------
The last is to construct the Nettyserver channel Channelhandler, which is executed in the online pool, not the Netty IO thread group.
This article from "Tech Doc" blog, declined reprint!
Dubbo-netty Interactive Server Side