Reactor Pattern and Non-blocking IO--reference
reference from:http://www.cs.bgu.ac.il/~spl051/Personal_material/Practical_sessions/Ps_12/ps12.html
- Java server class with multiple client connections: one-to-one ratio of threads to clients, therefore enormous thread overhead, resulted in performance problems and lack of scalability. The main problem is blocking I/O calls.
- JDK 1.4 supports non-blocking I/O calls (java.nio and java.nio.channels). These packages were designed principally according to Reactor design pattern (Using Design Patterns to Develop Reusable Object-Oriented Communication Software by Douglas C. Schmidt).
The actors in Reactor pattern are:
• Handles, which identify resources (such as network connections, open files, and synchronization
objects) that are managed by an operating system.
• Reactor, which defines an interface for registering, removing, and dispatching Event Handler
objects. An implementation of the Reactor interface provides a set of application-independent
event demultiplexing and dispatching mechanisms. These mechanisms dispatch application-specific
Event Handler in response to events occurring on one or more Handles.
• Event Handler, which specifies an interface used by the Reactor to dispatch callback methods
defined by objects that are pre-registered to handle certain types of events (such as input events,
output events, and signals).
• Concrete Event Handler, which implements the customized callback method(s) that process events
in an application-specific manner.
Using Reactor in Communication Software
- Short tutorial
- Important classes in java.nio.channels:
- SocketChannel, ServerSocketChannel
- Selector (Reactor)
- SelectionKey
- java.nio: ByteBuffer
Example
- Reactor
- ConnectionAcceptor (Event Handle)
- ConnectionReader (Event Handle)
- MessageProcessorTask
- SimpleClient
- ThreadPool
Reactor Pattern and Non-blocking IO--reference的更多相关文章
- 笔记-reactor pattern
笔记-reactor pattern 1. reactor模式 1.1. 什么是reactor模式 The reactor design pattern is an event han ...
- the reactor pattern and java nio
在<java NIO>作者PPT<How to Build a Scalable Multiplexed Server With NIO> 和 Doug Lea <Sca ...
- IO通信模型(一)同步阻塞模式BIO(Blocking IO)
几个概念 阻塞IO 和非阻塞IO 这两个概念是程序级别的.主要描述的是程序请求操作系统IO操作后,如果IO资源没有准备好,那么程序该如何处理的问题:前者等待:后者继续执行(但是使用线程一直轮询,直到有 ...
- {python之IO多路复用} IO模型介绍 阻塞IO(blocking IO) 非阻塞IO(non-blocking IO) 多路复用IO(IO multiplexing) 异步IO(Asynchronous I/O) IO模型比较分析 selectors模块
python之IO多路复用 阅读目录 一 IO模型介绍 二 阻塞IO(blocking IO) 三 非阻塞IO(non-blocking IO) 四 多路复用IO(IO multiplexing) 五 ...
- 阻塞IO(blocking IO)
在linux中,默认情况下所有的socket都是blocking,一个典型的读操作流程大概是这样: 当用户进程调用了recvfrom这个系统调用,kernel就开始了IO的第一个阶段:准备数据.对于n ...
- 关于Blocking IO,non-Blokcing IO,async IO的区别和理解
来源:http://shmilyaw-hotmail-com.iteye.com/blog/1896683 概括来说,一个IO操作可以分为两个部分:发出请求.结果完成.如果从发出请求到结果返回,一直B ...
- Netty:Reactor Pattern 与 Dubbo 底层传输中的 NettyServer
首先,我们需要了解Reactor模式的三种线程模型: 1)单线程模型 Reactor 单线程模型,指的是所有的 IO 操作都在同一个 NIO 线程上面完成,NIO 线程的职责如下: 作为 NIO 服务 ...
- reactor模式前序:传统IO的WEB服务器设计
先看一段经典的WEB JAVA服务器设计 JAVA代码为(伪代码) 1 ServerSocket serverSocket = ...; 2 serverSocket.bind(8899); 3 4 ...
- IO多路复用之Reactor模式
首先,我们来看看同步和异步. 在处理 IO 的时候,阻塞和非阻塞都是同步 IO.只有使用了特殊的 API 才是异步 IO. 接下来,我们来看看Linux下的三大同步IO多路复用函数 fcntl(fd, ...
随机推荐
- 问题:webservice浏览后 无法输入参数;结果:调试Web Service时不能输入参数的解决办法
使用.NET 开发Web Service,有一个很方便的功能就是可以通过IE直接测试Web Service.当你的Web Service的参数都是元数据类型,那么只要你使用IE浏览Web Servic ...
- 2.Apache + Tomcat + mod_jk实现集群服务
转自:http://www.cnblogs.com/dennisit/p/3370220.html Tomcat中的集群原理是通过组播的方式进行节点的查找并使用TCP连接进行会话的复制. 实现效果:用 ...
- Ubuntu 切换root用户是时出现su Authentication failure
su root 时出现错误su Authentication failure 原因是没有给root用户设置密码 sudo passwd root
- java电子书chm全套下载
链接:http://pan.baidu.com/s/1qWmMlYk 密码:us3x 版权声明:本文为博主原创文章,未经博主允许不得转载.
- File 类 操作实例
File 操作 <介绍> 尽管java.io定义的大多数类是实行流式操作的,File类不是.它直接处理文件和文件系统.也就是说,File类没有指定信息怎样从文件读取或向文件存储:它描述了文 ...
- Antiprime数-数论
题目描述 Description 如果一个自然数n满足:所有小于它的自然数的约数个数都小于n的约数个数,则称n是一个Antiprime数.譬如:1.2.4.5.12.24都是Antiprime数. ...
- CentOS7下二进制文件安装MySQL5.6
1.查看已装包 [root@host2 ~]# rpm -qa | grep mysql mysql-libs-5.1.71-1.el6.x86_64 [root@host2 ~]# [root@ho ...
- hbase exporter importer 导出 导入
导出: bin/hbase org.apache.hadoop.hbase.mapreduce.Export bigtable /user/bigtable_bak/ 导入: bin/hbase or ...
- 做c语言的码农专业发展方向
写了几年C语言代码,最近在思索,何去何从比较好? 搜索了一下,发现几个答案: 2015年10月编程语言排行榜 丢开C语言在教学应用外.在目前C语言的实际应用中.常见的应用的情景有如下: 内核/驱动,b ...
- 基于FPGA具有容错能理的异步串口程序设计
首先,问题源于一个项目.本来是一个很简单的多个串口收发FIFO存取数据的小程序,通过电脑验证也可用,而下位机板子之间通信就出现了丢数问题. 经过分析原因如下: 我的串口收模块是基于特权同学的开发板程序 ...