HADOOP27---The execution order of handler in Netty

Source: Internet
Author: User

Netty is a Web application framework based on Java NIO.    Netty is a NIO client-server(client server) framework that uses Netty to quickly develop network applications such as server and client protocols. Netty provides a new way to develop a Web application that makes it easy to use and highly extensible. The internal implementation of Netty is complex, but Netty provides an easy-to-use API to decouple business logic from network processing code. Netty is entirely based on NIO, so the entire netty is asynchronous.        network applications often require a high degree of scalability, whether Netty or other Java NIO-based frameworks, providing a scalable solution. One of the key components of Netty is its asynchronous nature.
2.1.1. Download the Netty package?    Download Netty package, http://netty.io/
2.1.1. Netty in handler execution order 2.1.2. Introduction handler in Netty, undoubtedly occupy a very important position. Handler with the filter in the servlet is very similar, through the handler can complete the decoding of the communication message encoding, interception of the specified message, unified log error processing, unified request count, control handler execution or not. All handler in Netty are implemented from the Channelhandler interface. According to output output to divide, divided into Channelinboundhandler, channeloutboundhandler two categories. Channelinboundhandler the packet from the client to the server processing, generally used to perform decoding, read client data, business processing and so on; Channeloutboundhandler the messages sent from the server to the client are processed, Generally used for encoding, sending messages to the client. Netty, you can register multiple handler. Channelinboundhandler are executed in the order in which they are registered; Channeloutboundhandler are executed in reverse order, as shown in the order in which the handler is ordered The order of execution after request enters Netty is:

when using in the process of Handler, it is important to note:

1, transfer between Channelinboundhandler, by calling ctx.firechannelread (msg) Passed to the next Channelinboundhandler, and thecall ctx.write (msg) is passed to the next Channeloutboundhandler.

2. After thectx.write () method executes, the flush () method needs to be called to make it execute immediately.

3, pipeline pipeline outhandler can not put in the last, otherwise does not take effect

4,Handler The consumption processing put in the last processing.

Using Netty, you can implement a Hadoop. Netty is a high-performance service-side framework.

HADOOP27---The execution order of handler in Netty

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.