源码分析
Java · 33 notes
- Netty 3.x Source Analysishistorical
1. Overview 2. Boss-array initialization 3. Worker-array initialization 4. Bind
- Off-Heap Memoryhistorical
1. What off-heap memory is 2. NIO off-heap memory 3. Netty off-heap memory 4. References
- 2.56 1. Create NioEventLoopGrouphistorical
NioEventLoopGroup class hierarchy, constructor chain, initialization of selector/select strategy/rejection policy, EventLoop count, executor, child EventLoops, and chooser.
- 2. Bootstrap Creationhistorical
1. Code to analyze 2. Create ServerBootstrap 3. Set ServerBootstrap properties 4. ReflectiveChannelFactory
- Pipeline Initializationhistorical
1. When pipeline is created 2. What pipeline looks like 3. Tail and Head
- Create the NioEventLoop Arrayhistorical
1. Code to analyze 2. Parameters passed to NioEventLoop 3. NioEventLoop is a single-threaded thread pool 4. Constructor
- 3. Allocate a Thread and Register the Selectorhistorical
1. Code to analyze 2. Propagate through the pipeline 3. Pass through ServerBootstrapAcceptor 4. Analyze channelRead
- 4. Register Read Events with the Selectorhistorical
1. Code to analyze 2. Set a breakpoint and connect with nc 3. Propagate channelActive 4. Reach HeadContext 5. Read through AbstractUnsafe
- 4. Bind the Server Porthistorical
Call path, AbstractBootstrap, AbstractUnsafe, and AbstractNioChannel
- 2.79 1. Instantiate the Channelhistorical
Instantiate NioServerSocketChannel through reflection, configure it as non-blocking, and create channelId, Unsafe, and pipeline.
- Netty Bind Source: Actually Binding the Listening Porthistorical
1. Code to analyze. 1.1. How NioEventLoop executes the Runnable. 1.2. What the bind task executed by NioEventLoop does, including JDK NIO bind, channelActive propagation, and registering interest in accept events.
- Inbound Eventshistorical
1. Add handlers for the experiment 2. Start from the pipeline 3. Forward through AbstractChannelHandlerContext 4. Enter HeadContext 5-8. Traverse inbound handlers to TailContext
- 2. Initialize Channelhistorical
1. Code to analyze 2. Obtain the channel pipeline and add a ChannelInitializer
- Netty Source: NioEventLoop run Methodhistorical
Code analysis of the NioEventLoop run loop: select, selector rebuild, selected-key optimization, processSelectedKeys, and asynchronous task execution.
- Outbound Eventshistorical
1. Add handlers for the experiment 2. Start from the pipeline 3. Enter TailContext 4-7. Traverse outbound handlers back to HeadContext
- ByteBufAllocatorhistorical
ByteBufAllocator class hierarchy, AbstractByteBufAllocator, unpooled allocation, and pooled allocation
- 2.91 3. Register the Channelhistorical
Select a NioEventLoop, create a ChannelPromise/Future, register the channel through Unsafe with the JDK NIO selector, and invoke handlerAdded/initChannel callbacks.
- Exception Eventshistorical
1. Prepare experiment data 2. Start debugging 3-7. Propagate the exception through handlers to TailContext
- Usagehistorical
Historical example of allocating, reading, writing, and releasing a pooled direct ByteBuf
- PooledByteBufAllocatorhistorical
newDirectBuffer, PoolThreadLocalCache, PoolThreadCache, and PoolArena