netty3.10.6源码阅读
2019-03-18 09:38:29 0 举报
netty3.10.6源码阅读笔记
作者其他创作
大纲/内容
AbstractNioSelector.select(Selector selector)
ByteBuffer
NioServerSocketChannel.bind(SocketAddress)
if(SelectionKey.OP_READ)
AbstractNioSelector.run()
bind
AbstractNioSelector.process(Selector selector)
Switch I/O woker thread execution
HeapChannelBufferFactory.getBuffer(readBytes)
ServerSocketChannel.open()socket.configureBlocking(false)
NioWorker#RegisterTask.run()
NioAcceptedSocketChannel(AbstractChannel).write(ChannelBuffer)
if(XXX Thread)
ThreadRenamingRunnable.run()
new ChannelPipelineFactory
Thread [New I/O worker #2]
Thread [New I/O worker #6]
Thread [New I/O worker #4]
bindAsync(final SocketAddress localAddress)
Buffer
new
new Binder(localAddress)
ServerBootstrap
NioServerBoss.bind()NioServerBoss.registerTask()NioServerBoss#RegisterTask.run()
ServerBootstrap启动流程
NioWorker.read(SelectionKey)
NioWorker.scheduleWriteIfNecessary(channel)
NioServerBoss.process(Selector selector)
AbstractNioSelector
SocketReceiveBufferAllocator.get(size)
AbstractNioWorker.writeFromSelectorLoop(SelectionKey)
NioServerSocketChannelFactory
SELECT_TIMEOUT=500selector.select(SELECT_TIMEOUT)
new NioServerBoss
NioWorker(AbstractNioWorker).writeFromUserCode(channel)
NioWorker.registerTask(channel.writeTask)
AbstractNioChannel#WriteTask.run()
NioWorker.run()
缓冲区说明
Channel写入数据
DefaultChannelPipeline.sendDownstream(evt)
setPipelineFactory()
new NioWorker
NettyServer启动后线程运行
constructor
new NioServerBossPool
ChannelBuffer
new DefaultChannelPipeline
Selector.select()
Thread [New I/O worker #5]
PooledSendBuffer.transferTo(SocketChannel)
extends
Thread [New I/O worker #1]
if(TaskQueue.haveTask)
XXXHandler
if(SelectionKey.OP_WRITE)
AdaptiveReceiveBufferSizePredictor.previousReceiveBufferSize(readBytes)
workerCount
DefaultChannelPipeline.sendUpstream(ChannelEvent e)
AbstractNioSelector.processTaskQueue()
XXXExecutionHandler
SocketSendBufferPool.acquire(ChannelBuffer)
AdaptiveReceiveBufferSizePredictor.nextReceiveBufferSize()
NioWorker(AbstractNioWorker).write0(channel)
Channels.fireChannelOpen(channel)
new NioServerSocketPipelineSink
NioServerBoss.run()
Thread [XXX #N]
XXXHandler.sendUpstram(e)
bossPipeline.addLast(\"binder\
DirectByteBuffer
Thread [New I/O server boss #1]
NioServerBoss.select(Selector selector)
if(Client.accept)
if(IO Thread)
new DefaultChannelFuture
AbstractChannel({ span style=\"font-size: inherit;\
SocketSendBufferPool.acquire(evt.getMessage())
new DefaultChannelPipeline
NioServerSocketPipelineSink.handleAcceptedSocket(ChannelEvent)
Thread [New I/O worker #3]
Switch XXX thread execution
AbstractNioWorker
Thread [New I/O worker #8]
SocketChannel.read(ByteBuffer)
new NioWorkerPool
MappedByteBuffer
Switch IO Thread
DefaultChannelPipeline.sendDownstream(ChannelEvent)
getPipeline()
NioServerSocketChannel
AbstractNioWorker.process(Selector selector)
NioWorker.writeFromTaskLoop(AbstractNioChannel)
XXXFrameDecoder
Thread [New I/O worker #N]
AbstractNioWorker.run()
Thread [New I/O worker #7]
ChannelFactory.newChannel(bossPipeline)
AbstractNioChannel.writeBufferQueue.offer(event)AbstractNioChannel.worker.writeFromUserCode(channel)
new DefaultServerSocketChannelConfig
bossCount
SocketChannel.write(DirectByteBuffer)
收藏
0 条评论
下一页
为你推荐
查看更多