3 Netty componnents and design
来源:互联网 发布:7z暴力解压软件 编辑:程序博客网 时间:2024/05/16 06:54
3 Netty components and design
3.1 Channel,EvenetLoop,and ChannelFuture
*Channel——Sockets
*EventLoop——控制流,多线程,并发
*ChannelFuture——异步通知
3.1.1 Interface Channel
Netty中Channel接口API降低了原始Socket API的复杂度。
实现的类有:
*EMbeddedChannel
*LocalServerChannel
*NioDatagramChannel
*NioSctpChannel
*NioSocketChannel
3.1.2 Interface EventLoop
These relationships are:
* 一个EventLoopGroup包含一个或多个EventLoops
* 一个EventLoop是一个线程
* 所有i/o事件被EventLoop处理,在它专用的线程里
* A Channel is registered for its lifetime with a single EventLoop.
* 一个EventLoop可以被分配给一个或多个通道
3.1.3 Interface ChannelFuture
把ChannelFuture看作是一个将在未来执行的操作结果的占位符。
3.2 ChannelHandler and ChannelPipeline
管理数据流和处理应用业务逻辑的组件
3.2.1 Interface ChannelHandler
ChannelPipeline是一系列ChannelHandlers的集合并定义了在他们之间入站出站流的传播事件API。
ChannelHandlers被安装在ChannelPipeline:
* ServerBootStrap注册一个ChannelInitializer实例
* 当ChannelInitializer.initChannel()被调用时,ChannelInitializer在管道里安装一个ChannelHandlers集合
* ChannelInitializer从ChannelPipeline移除自己
3.2.3 A Closer look at ChannelHandlers
经常使用的adapter
* ChannelHandlerAdapter
*ChannelInboundHandlerAdapter
*ChannelOutboundHandlerAdapter
*ChannelDuplexHandlerAdapter
3.2.4 Encoders and decoders
网络数据总是一些列字节。所以出站数据要转化为字节,入站数据要从字节转化为需要的格式。
3.2.5 Abstract class SimpleChannelInboundHandler
3.3 Bootstrapping
Netty's bootstrap提供了一个网络层的配置容器。
分为客户端Bootstrapping和服务端Bootstrapping
3.4 Summary
- 3 Netty componnents and design
- New and noteworthy - Netty
- Netty-Encode and Decoder
- Planned and Evolutionary Design
- Software Modeling and Design
- Design and Performance
- Architecture and Design Guidlines.
- Activity and Task Design
- Activity and Task Design
- Analysis and Design Overview
- Software design and testing
- Netty and Java NIO APIs
- Design Smells And OO Design Principles
- strategy design pattern and composite design pattern
- What is the difference between netty(io.netty.*) and jboss netty(org.jboss.netty.*)
- Data Structures and Algorithms with Object-Oriented Design Patterns (3)
- Operating Systems Design and Implementation (3rd Edition)
- Introduction to AutoCAD 2008: 2D and 3D Design
- php连接mssql数据库类
- shell变量
- Web系统大规模并发—电商秒杀与抢购
- 第一周—长方形面积
- ExtJS初级培训3--实例--表格
- 3 Netty componnents and design
- JAVA EE---JSP 学习第一天
- Java Thread.interrupt 害人! 中断JAVA线程(zz)
- _weak typeof(self) weakSelf = self使用解释
- TakePhoto是一款用于在Android设备上获取照片(拍照或从相册、文件中选择)、裁剪图片、压缩图片的开源工具库,目前最新版本3.0.0。
- 页面实现不定条数据倒计时
- BZOJ 1483 [HNOI2009]梦幻布丁
- Ubuntu14.04系统hostapd编译及使用
- 对 self = [super init] 的理解