Netty channel NiO socket.
Defaultniosocketchannelconfig. Java
Main attributes:
- Two cursor thresholds of writebuffer: high watermark and low watermark. Generally, the former is half of the latter.
- Writespincount,
- Predictor: used to predict the receive buffer size of a channel. There are two implementations: adaptive and fixed. 1) adaptivereceivebuffersizepredictor: adjusts the next recive buffer size according to the specific situation of the last read operation. The more accurate the estimation, the higher the memory usage. If all the previous reads are fully utilized, continue to increase this attempt. If the last two consecutive reads are not used up, the attempt is reduced. Other cases will remain unchanged temporarily. 2) fixedreceivebuffersizepredictor, fixed size.
Niosocketchannel
- Various attributes: 1) Various st_open ,... 2) socket used for real communication 3) worker 4) localaddress, remoteaddress 5) about configuration config 6) about interest interestopslock 7) about write writelock, writetask writetaskintaskqueue writerbuffer, inwritenowloop, writesuincluded, currentwriteevent, currentwritebuffer 8) read data.
- Subclass: nioacceptedsocketchannel
- Subclass: nioclientsocketchannel
Nioclientsocketchannelfactory. Java
- Boss manager, responsible for only connect events
- Workers is responsible for all matters after connect
- Sink nioclientsocketpipelinesink is the downstream event acceptance pool, such as bind, connect, open, write, set interest_ops, and so on. These events are finally sunk into the pool for processing.
Abstractserverchannel. Java
- X
- Subclass: nioserversocketchannel, equivalent to nioclientsocketchannel.
- Subclass:
Nioserversocketchannelfactory. JavaEquivalent to nioclientsocketchannelfactory. Java
- The boss main manager is only responsible for the connect event and can have multiple, for example, for port 44 and 88, there can be two boss threads in charge respectively
- Workers is responsible for all matters after connect
- Sink nioserversocketpipelinesink is the acceptance pool of downstream events, such as bind, connect, open, write, set interest_ops, and so on. These events are finally sunk into the pool for processing.
Nioprovidermetadata. Java
- Constraintlevel: different hardware manufacturers have different constraints.
- 0-no need to wake up to get/set interestops (most cases)
- 1-no need to wake up to get interestops, but need to wake up to set.
- 2-need to wake up to get/set interestops (old providers)