
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 · 367 阅读 · 0 评论 -
DefaultChannelPipeline之channelActive
register0入口 AbstractChannel.register0private void register0(ChannelPromise promise) { try { .................. boolean firstRegistration = neverRegistered; doRegister(); neverRegi原创 2021-06-24 01:21:02 · 494 阅读 · 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 · 498 阅读 · 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 · 387 阅读 · 0 评论 -
Netty - EventExecutor - Chooser
DefaultEventExecutorChooserFactory构造函数单例public static final DefaultEventExecutorChooserFactory INSTANCE = new DefaultEventExecutorChooserFactory(); private DefaultEventExecutorChooserFactory() { }newChooser策略模式public EventExecutorChooser newCho原创 2021-06-23 18:33:29 · 373 阅读 · 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 · 316 阅读 · 0 评论 -
初始化DefaultChannelPipeline
流程图原创 2021-06-21 19:18:42 · 382 阅读 · 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 · 446 阅读 · 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 · 340 阅读 · 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 · 1195 阅读 · 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 · 579 阅读 · 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 · 542 阅读 · 0 评论 -
NioEventLoopGroup源码
整体类图参照https://blog.youkuaiyun.com/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 · 272 阅读 · 0 评论 -
NioEventLoopGroup
NioEventLoopGroup整体结构图jdk自带线程池详细图(从EventExecutorGroup)原创 2020-08-10 14:45:54 · 317 阅读 · 0 评论 -
ChannelHandler
ChannelHandlerChannelHandlerAdapterChannelInboundHandlerChannelInboundHandlerAdapterChannelOutboundHandlerChannelOutboundHandlerAdapter原创 2020-08-05 08:40:38 · 278 阅读 · 0 评论 -
ChannelInvoker
ChannelInboundInvokerChannelOutboundInvoker原创 2020-08-05 08:20:57 · 280 阅读 · 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 · 712 阅读 · 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 · 321 阅读 · 0 评论 -
Netty的Listener
EventListenerGenericFutureListener GenericFutureListener继承EventListenerFutureListenerFutureListener类图GenericProgressiveFutureListenerGenericProgressiveFutureListener 类图...原创 2020-07-25 16:00:47 · 907 阅读 · 0 评论