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, ...
随机推荐
- AI设计的若干规则阐述
转自:http://www.gameres.com/491742.html 一般来讲,网络游戏的AI历来就是很简单的AI.相比之下,很多单机游戏的AI就要得复杂一些.而笔者并未从事过大型单机游戏的AI ...
- java注解的基本知识
1: 注解:Annotation是一种应用于类.方法.参数.变量.构造器及包生命中的特殊修饰符,是一种由JSR-175标准选择用来描述代码的元数据. Java中如下的4种注解,专门负责新注解的创建: ...
- 手把手教你写Kconfig---基于tiny4412开发板
转自:http://blog.csdn.net/morixinguan/article/details/54744237 今天,我就来教大家写写最简单的Kconfig,什么是Kconfig? 我们配置 ...
- C#使用NPOI将DataGridView内数据写入电子表格Excel
NPOI能够在用户没有安装office的情况下读写office文件,包括.xls/.doc/.ppt等类型的文件.本文介绍的是使用NPOI库内的函数读写Excel(.xls)内的内容.在使用NPOI之 ...
- .net关于应用程序缓存的一些疑惑
疑惑:获取缓存后强制转换为实体对象传递给前台,如果前台对这个实体对象中属性更改的话缓存中的数据也随之改变,为啥??? 首先是创建缓存的方法: /// <summary> /// 创建缓存项 ...
- Zeppelin的入门使用系列之创建新的Notebook(一)
不多说,直接上干货! 前期博客 hadoop-2.6.0.tar.gz + spark-1.6.1-bin-hadoop2.6.tgz + zeppelin-0.5.6-incubating-bin- ...
- 2、misa统计SRR结果
参考: https://www.sogou.com/link?url=hedJjaC291NYNxVe4xgB4c3bUxXRMqZrT93cntTAgYfyBbRAdP9kIA.. https:// ...
- 6、R语言绘制带errorbar 的柱状图
转载:http://www.cnblogs.com/xudongliang/p/7283733.html data <- data.frame(mean = c(10, 15), sd = c( ...
- 25. CTF综合靶机渗透(17)
靶机链接 https://www.vulnhub.com/entry/the-ether-evilscience,212 运行环境 本靶机提供了VMware的镜像,从Vulnhub下载之后解压,运行v ...
- HDU - 5542 The Battle of Chibi(LIS+树状数组优化)
The Battle of Chibi Cao Cao made up a big army and was going to invade the whole South China. Yu Zho ...