Tomcat Server Parsing (vii)--Processor&endpoint&protocolhandler

Source: Internet
Author: User

The request arrives at Poller processing, which is ultimately handled by processor, and in order to illustrate the parts involved in this intermediate process, first organize the various components of the Tomcat service: Protocolhandler, Endpoint, Endpoint.handler , Processor
The reference relationships between them are as follows
[Protocolhandler] <---------Connector
Org.apache.coyote.ProtocolHandlerorg.apache.coyote.AbstractProtocolorg.apache.coyote.http11.AbstractHttp11Protocolorg.apa Che.coyote.http11.AbstractHttp11JsseProtocolorg.apache.coyote.http11.Http11NioProtocol*


[Endpoint] <---------Protocolhandler (http11nioprotocol) Org.apache.tomcat.util.net.AbstractEndpoint Org.ap Ache.tomcat.util.net.NioEndpoint*
The processing connection number control, the connection establishment and so on work, mainly including acceptor and poller two large parts, will establish the good connection to endpoint's handler to handle

[Endpoint.handler] <---------Endpoint (Nioendpoint)
Abstractendpoint.handler Abstractconnectionhandler <--> Abstractprotocol Http11connectionhandler & Lt --> Http11nioprotocol*
The relationship between the cache connection and the processor, and the connection to find the processor to handle

[Processor] <---------Endpoint.handler
Org.apache.coyote.ProcessorOrg.apache.coyote.AbstractProcessororg.apache.coyote.http11.AbstractHttp11Processororg.apache.coyote.http11.Http11NioProc Essor*
The process method handles the related business in HTTP requests, service status, protocol resolution, request handshake, content decompression, etc., constructs suitable adapter processing request and Response object, and then calls Adater for business data processing.

Acceptor and Poller are all part of the endpoint, so, here is the socket connection with data arrival, is handed to the Endpoint.handler, after the cache acceleration, to find the corresponding processor, the processor to deal with.
Processor processing the HTTP protocol related content, the adapter to handle the business.
Q&a
1. When do I read the request data?
In the Java servlet development model, a developer-defined servlet reads data through InputStream and writes data through OutputStream. Therefore, these parts of the above are not related to the specific business data read and write. The specific data read and write time, after adapter.
2. How is the request transferred to the user-defined servlet?
The specific implementation, in the section after adapter, does not address this related section.
3, how to control the number of connections to the service?
Endpoint internal acceptor to control, endpoint provides a setmaxconnection method to set the maximum number of connections that Tomcat can support. This method sets a limitlatch lock for a acceptor. Control the number of connections through Limitlatch. When a new connection is added, the calculator is added, and when the connection is closed, the counter is reduced by one.
4. Where is the thread pool used within the Tomcat service? The poller inside the endpoint is used to select the socket connection with data arrival, and the connection is given to endpoint.handler for processing.     This pass-through event is encapsulated as a socketprocessor task that is done by performing a socketprocessor task. Socketprocessor implementation of the thread pool implementation, that is, endpoint Poller thread, the event into a socketprocessor task, placed in endpoint ThreadPool to complete.
5. When you start the Tomcat service, many parameters can be passed through the configuration file, including how ports, protocol, MaxConnections, and maxthreads are in effect?
Sorry, I don ' t know. I Haven ' t reached that point!
6. What's the point of this series passages?
For now, It doesn ' t do any sense. And I don ' t know why I had started reading, or would I continue ...

Tomcat Server Parsing (vii)--Processor&endpoint&protocolhandler

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.