netty启动流程
2021-11-12 11:40:31 2 举报
netty启动流程图,包括初始化和注册serversocketchannel,绑定监听端口,建立连接,处理读请求,以及channelInitiallizer的initChannel添加用户自定义channelHandler逻辑
作者其他创作
大纲/内容
handlerAdded-initChannel
ServerSocketChannel
PendingHandlerAddedTask
selector.select
TailContext
childHandler:UserCustomHandler
Selector
DefaultChannelPipeline
NioEventLoop
pipeline.fireChannelRead
HeadContext
......
task.next.execute
worker NioEventLoopGroup
NioEventLoopGroup
processSelectedKeys
channelActive
executor
ChannelInitializer
task
null
handlerAdded-initChannel-pipeline.remove
run
NioEventLoop[1]
register->bind->channelActive->readIfAutoRead(selectionKey.interestOps(SelectionKey.OP_ACCEPT))
AbstractNioByteChannel.read
NioEventLoop[2]
register
boss NioEventLoopGroup
PendingHandlerRemovedTask
socketChannel
readIfAutoRead
processSelectedKeys执行IO任务
invokeHandlerAddedIfNeeded
NioEventLoop[0]
readInterestOps=OP_ACCEPT
NioSocketChannel
channel.accept
AbstractNioMessageChannel.read
register->connect->select->channelActive->readIfAutoRead(selectionKey.interestOps(SelectionKey.OP_READ))
NioServerSocketChannel
ServerBootstrapAcceptor
addLast
netty server
UserCustomHandler
readInterestOp=OP_READ
runAllTasks taskQueue
channel.read(byteBuffer)
0 条评论
下一页