Netty source code learning-classroom 3

Source: Internet
Author: User

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)

 

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.