- 快召唤伙伴们来围观吧
- 微博 QQ QQ空间 贴吧
- 文档嵌入链接
- 复制
- 微信扫一扫分享
- 已成功复制到剪贴板
Netty介绍
展开查看详情
1 .Netty
2 .Agenda Intro to Netty and NIO Construct Use Summary
3 .What and Why NIO Client-server framework Asynchronous Event-driven Easy To Use API High Performance Quick Development
4 .What do people use it for Web services Instant messaging / push server Multiplayer game Storage database …
5 .
6 .I/O Read Request Decode Request Process Encode Reply Send Reply OIO NIO AIO Client Server
7 .OIO InputStream OutputStream block on read/write 1 Thread: 1 Connection
8 .Sample Code
9 .Scalable Thread thread num, switch overhead Divide and Conquer is usually the best approach any scalability goal
10 . NIO Non-Blocking IO ByteBuffer byte container Channel nexus which can do IO operation Selector event monitor which can watch multiple channels
11 .Selector SelectableChannel::register(Selector, ops, attachment): SelectionKey selectedKeys: Set<SelectionKey> SelectionKey
12 .ByteBuffer get, put position limit capacity flip
13 .Reactor Pattern Reactor responds to IO events by dispatching the appropriate handle Handlers perform non-blocking actions Manage by binding handlers to events
14 .Reactor Pattern Reactor responds to IO events by dispatching the appropriate handle Handlers perform non-blocking actions Manage by binding handlers to events
15 .Reactor Pattern Reactor responds to IO events by dispatching the appropriate handle Handlers perform non-blocking actions Manage by binding handlers to events
16 .Java NIO2 AsynchronousServerSocketChannel AsynchronousSocketChannel read(ByteBuffer): Future<Integer> read(ByteBuffer, A, CompletionHandler<Int, ? super A> )
17 .Java NIO2 AsynchronousServerSocketChannel AsynchronousSocketChannel read(ByteBuffer): Future<Integer> read(ByteBuffer, A, CompletionHandler<Int, ? super A> )
18 .why not use jdk NIO directly low level, hard, tricky concurrency is too hard bugs
19 .netty structure ChannelPipeline ChannelHandler ByteBuf Bootstrap Decoder/Encoder Thread Model
20 .ChannelPipeline List of ChannelHandlers Chain Of Responsibility Can modify on the fly
21 .ChannelHandler Separation of concern Inbound Outbound
22 .ByteBuf Capacity is expanded ReaderIndex WriterIndex ReferenceCounted Pooled Unpooled
23 .Codec Decoder ByteToMessageDecoder MessageToMessageDecoder Encoder MessageToByteEncoder MessageToMessageEncoder Provided Codecs
24 .Thread Model
25 .Thread Model
26 .Thread Model
27 .use case WebSocket nifty
28 .Push Message websocket metrics, auth handle, heartbeat
29 .Nifty Nifty is an implementation of Thrift clients and servers on Netty. https://github.com/facebook/nifty http://git.sankuai.com/users/liuzhengyang/repos/nifty/browse