Netty原理示图

1. AWT事件驱动

在这里插入图片描述

2. Websocket协议

在这里插入图片描述

3. 基于多个反应器的多线程模式

在这里插入图片描述

4. Netty Reactor 工作架构图

在这里插入图片描述

5. Bootstrap引导过程

Channel
Channel是Java NIO的基础。它表示一个开放的连接,进行IO操作。基本的 I/O 操作( bind() 、 connect() 、 read() 和 write() )依赖于底层网络传输所提供的原语。在基于 Java 的网络编程中,其基本的构造是 class Socket 。Netty 的 Channel 接口所提供的 API,大大地降低了直接使用 Socket 类的复杂性。

EventLoop
EventLoop 定义了 Netty 的核心抽象,用于处理连接的生命周期中所发生的事件。
在这里插入图片描述

6. ServerBootstrap引导过程

在这里插入图片描述

7. Selector处理逻辑

在这里插入图片描述

8. Channel 、 EventLoop 和 EventLoopGroup关系

在这里插入图片描述

9. 具有2个EventLoopGroup的服务器

与 ServerChannel 相关联的 EventLoopGroup 将分配一个负责为传入连接请求创建 Channel 的 EventLoop 。一旦连接被接受,第二个 EventLoopGroup 就会给它的 Channel 分配一个 EventLoop 。

在这里插入图片描述

10. 用于非阻塞传输(如 NIO 和 AIO)的EventLoop分配方式

在这里插入图片描述

11. EventLoop 执行逻辑

在这里插入图片描述

12. ChannelPipeline

在这里插入图片描述

13. Channel、ChannelPipeline、ChannelHandler 以及 ChannelHandlerContext 之间的关系

在这里插入图片描述

14. 通过Channel或ChannelPipeline进行事件传播

15. 通过ChannelHandlerContext触发的操作的事件流

在这里插入图片描述

16. Execution-logic of Netty3

1 The I/O thread that handles all the I/O events of a channel
2 Data gets ready from the socket
3 Gets processed in the worker, which is bound to the I/O thread
4 The data / event is passed through all the ChannelHandlers of the Channel . This still happens within the IO thread of the Channel.
5 Any thread from which an outbound operation is triggered. This may be the IO / thread or any other thread.
6 Something is passed to the Channel.write(…)
7 The write operation will generate an event that will get passed to the ChannelHandlers of the channel
8 The event gets passed through all the ChannelHandlers of the channel This happens in the same thread as from which the write operation was triggerd.
09 Once processing of the even via the ChannelHandlers is done, it will hand over the event to the worker thread
10 The data is finally written to the remote peer by the worker thread在这里插入图片描述

17. channel

在这里插入图片描述

18. Pipleline中Handler的调用链

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值