![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
netty
kong-kong
记录流水账
展开
-
IdleStateHandler心跳检测
IdleStateHandler主要属性 private final long readerIdleTimeNanos; // 读空闲超时时间 private final long writerIdleTimeNanos; // 写空闲超时时间 private final long allIdleTimeNanos; // 读和写都空闲的超时时间 private long lastReadTime; // 最后1次读的时间 private long las原创 2021-06-24 21:53:31 · 338 阅读 · 0 评论 -
DefaultChannelPipeline之channelActive
register0入口 AbstractChannel.register0private void register0(ChannelPromise promise) { try { .................. boolean firstRegistration = neverRegistered; doRegister(); neverRegi原创 2021-06-24 01:21:02 · 471 阅读 · 0 评论 -
DefaultChannelPipeline之channelReadComplete
channelReadCompletereadAbstractNioByteChannelpublic final void read() {ByteBuf byteBuf = null; boolean close = false; try { do { byteBuf = allocHandle.allocate(allocator);原创 2021-06-23 21:22:13 · 458 阅读 · 0 评论 -
DefaultChannelPipeline之channelRead
fire******这里以fireChannelRead为例,还有fireChannelActive、fireChannelReadComplete、fireExceptionCaught 等入口从head开始调用public final ChannelPipeline fireChannelRead(Object msg) { AbstractChannelHandlerContext.invokeChannelRead(head, msg); // DefaultChannelP原创 2021-06-23 21:09:56 · 366 阅读 · 0 评论 -
Netty - EventExecutor - Chooser
DefaultEventExecutorChooserFactory构造函数单例public static final DefaultEventExecutorChooserFactory INSTANCE = new DefaultEventExecutorChooserFactory(); private DefaultEventExecutorChooserFactory() { }newChooser策略模式public EventExecutorChooser newCho原创 2021-06-23 18:33:29 · 333 阅读 · 0 评论 -
DefaultChannelPipeline
ChannelInitializerprotected abstract void initChannel(C ch) throws Exception;public final void channelRegistered(ChannelHandlerContext ctx) throws Exception { // Normally this method will never be called as handlerAdded(...) should call initCha原创 2021-06-22 18:31:01 · 299 阅读 · 0 评论 -
初始化DefaultChannelPipeline
流程图原创 2021-06-21 19:18:42 · 371 阅读 · 0 评论 -
NioServerSocketChannel
NioServerSocketChannelio.netty.channel.socket.nio.NioServerSocketChannel继承图NioServerSocketChannel 方法构造函数public NioServerSocketChannel() { this(newSocket(DEFAULT_SELECTOR_PROVIDER));}newSocket打开ServerSocketChannelprivate static ServerSocketCh原创 2021-06-18 19:43:49 · 428 阅读 · 0 评论 -
NioSocketChannel
类io.netty.channel.socket.nio.NioSocketChannel封装了操作java nio操作public class NioSocketChannel extends AbstractNioByteChannel implements io.netty.channel.socket.SocketChannel { }打开SocketChannelpublic NioSocketChannel(SelectorProvider provider) { this(原创 2021-06-17 21:23:20 · 319 阅读 · 0 评论 -
NioEventLoop之SelectStrategy
DefaultSelectStrategyFactory 默认Select策略工厂public final class DefaultSelectStrategyFactory implements SelectStrategyFactory { public static final SelectStrategyFactory INSTANCE = new DefaultSelectStrategyFactory(); private DefaultSelectStrateg...原创 2020-08-11 17:54:12 · 1150 阅读 · 1 评论 -
Bootstrap的register
业务代码// Start the server.ChannelFuture f = b.bind(PORT).sync();AbstractBootstrappublic ChannelFuture bind(SocketAddress localAddress) { validate(); if (localAddress == null) { throw new NullPointerException("localAddress原创 2020-08-11 17:49:12 · 553 阅读 · 0 评论 -
NioEventLoop源码之openSelector优化
构造函数NioEventLoop(NioEventLoopGroup parent, Executor executor, SelectorProvider selectorProvider, SelectStrategy strategy, RejectedExecutionHandler rejectedExecutionHandler) { super(parent, executor, false, DEFAULT_MAX_PENDING_TA原创 2020-08-10 18:40:14 · 509 阅读 · 0 评论 -
NioEventLoopGroup源码
整体类图参照https://blog.csdn.net/kq1983/article/details/1079126111. thread确定NioEventLoopGroup() 这样的话,默认是cpu的核数*2public NioEventLoopGroup() { this(0);}// MultithreadEventLoopGroup类// 看这里如果thread=0 则默认是DEFAULT_EVENT_LOOP_THREADSprotected Mu.原创 2020-08-11 17:52:28 · 259 阅读 · 0 评论 -
NioEventLoopGroup
NioEventLoopGroup整体结构图jdk自带线程池详细图(从EventExecutorGroup)原创 2020-08-10 14:45:54 · 301 阅读 · 0 评论 -
ChannelHandler
ChannelHandlerChannelHandlerAdapterChannelInboundHandlerChannelInboundHandlerAdapterChannelOutboundHandlerChannelOutboundHandlerAdapter原创 2020-08-05 08:40:38 · 262 阅读 · 0 评论 -
ChannelInvoker
ChannelInboundInvokerChannelOutboundInvoker原创 2020-08-05 08:20:57 · 262 阅读 · 0 评论 -
ChannelHandlerMask实现思路
事件位置从右到左17个位置,每个事件占用1个位置,比如第1个位置1,0001第2个位置2,0010第3个位置4,0100第4个位置8,1000..............................第16个位置32768, 1000 0000 0000 0000(左移15位)第17个位置65536 1 0000 0000 0000 0000 (左移16位)此类推@Skip注解标注Skip的注解会被排除掉,int mask = MASK...原创 2020-08-04 11:29:27 · 667 阅读 · 0 评论 -
Netty的Future
java.util.concurrent.Future 顶层是jdk的Futureio.netty.util.concurrent.Futurenetty的Future继承jdk的Futureio.netty.channel.ChannelFutureio.netty.util.concurrent.PromisePromise继承netty的Futureio.netty.channel.ChannelPromise...原创 2020-07-27 17:04:00 · 305 阅读 · 0 评论 -
Netty的Listener
EventListenerGenericFutureListener GenericFutureListener继承EventListenerFutureListenerFutureListener类图GenericProgressiveFutureListenerGenericProgressiveFutureListener 类图...原创 2020-07-25 16:00:47 · 875 阅读 · 0 评论