Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2ff7818

Browse files
committed
Work on iluwatar#74, added class diagram and index.md
1 parent 5bacfce commit 2ff7818

File tree

3 files changed

+237
-0
lines changed

3 files changed

+237
-0
lines changed

reactor/etc/reactor.png

121 KB
Loading

reactor/etc/reactor.ucls

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<class-diagram version="1.1.8" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
3+
realizations="true" associations="true" dependencies="true" nesting-relationships="true">
4+
<class id="1" language="java" name="java.nio.channels.Selector" project="abstract-factory"
5+
file="/opt/Softwares/Eclipses/MARS/eclipse/jre/lib/rt.jar" binary="true" corner="BOTTOM_RIGHT">
6+
<position height="224" width="188" x="1120" y="-50"/>
7+
<display autosize="false" stereotype="true" package="true" initial-value="false" signature="true"
8+
sort-features="false" accessors="true" visibility="true">
9+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
10+
<operations public="true" package="true" protected="false" private="true" static="true"/>
11+
</display>
12+
</class>
13+
<class id="2" language="java" name="com.iluwatar.reactor.framework.NioReactor" project="reactor"
14+
file="/reactor/src/main/java/com/iluwatar/reactor/framework/NioReactor.java" binary="false" corner="BOTTOM_RIGHT">
15+
<position height="-1" width="-1" x="760" y="19"/>
16+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
17+
sort-features="false" accessors="true" visibility="true">
18+
<attributes public="true" package="true" protected="true" private="false" static="true"/>
19+
<operations public="true" package="true" protected="true" private="false" static="true"/>
20+
</display>
21+
</class>
22+
<interface id="3" language="java" name="com.iluwatar.reactor.framework.Dispatcher" project="reactor"
23+
file="/reactor/src/main/java/com/iluwatar/reactor/framework/Dispatcher.java" binary="false" corner="BOTTOM_RIGHT">
24+
<position height="-1" width="-1" x="569" y="279"/>
25+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
26+
sort-features="false" accessors="true" visibility="true">
27+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
28+
<operations public="true" package="true" protected="true" private="true" static="true"/>
29+
</display>
30+
</interface>
31+
<class id="4" language="java" name="com.iluwatar.reactor.framework.SameThreadDispatcher" project="reactor"
32+
file="/reactor/src/main/java/com/iluwatar/reactor/framework/SameThreadDispatcher.java" binary="false"
33+
corner="BOTTOM_RIGHT">
34+
<position height="-1" width="-1" x="291" y="562"/>
35+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
36+
sort-features="false" accessors="true" visibility="true">
37+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
38+
<operations public="true" package="true" protected="true" private="true" static="true"/>
39+
</display>
40+
</class>
41+
<class id="5" language="java" name="com.iluwatar.reactor.framework.ThreadPoolDispatcher" project="reactor"
42+
file="/reactor/src/main/java/com/iluwatar/reactor/framework/ThreadPoolDispatcher.java" binary="false"
43+
corner="BOTTOM_RIGHT">
44+
<position height="115" width="356" x="341" y="375"/>
45+
<display autosize="false" stereotype="true" package="true" initial-value="false" signature="true"
46+
sort-features="false" accessors="true" visibility="true">
47+
<attributes public="true" package="true" protected="true" private="false" static="true"/>
48+
<operations public="true" package="true" protected="true" private="true" static="true"/>
49+
</display>
50+
</class>
51+
<class id="6" language="java" name="com.iluwatar.reactor.framework.AbstractNioChannel" project="reactor"
52+
file="/reactor/src/main/java/com/iluwatar/reactor/framework/AbstractNioChannel.java" binary="false"
53+
corner="BOTTOM_RIGHT">
54+
<position height="-1" width="-1" x="935" y="265"/>
55+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
56+
sort-features="false" accessors="true" visibility="true">
57+
<attributes public="true" package="true" protected="true" private="false" static="true"/>
58+
<operations public="true" package="true" protected="true" private="false" static="true"/>
59+
</display>
60+
</class>
61+
<class id="7" language="java" name="com.iluwatar.reactor.framework.NioServerSocketChannel" project="reactor"
62+
file="/reactor/src/main/java/com/iluwatar/reactor/framework/NioServerSocketChannel.java" binary="false"
63+
corner="BOTTOM_RIGHT">
64+
<position height="-1" width="-1" x="836" y="543"/>
65+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
66+
sort-features="false" accessors="true" visibility="true">
67+
<attributes public="true" package="true" protected="true" private="false" static="true"/>
68+
<operations public="true" package="true" protected="true" private="true" static="true"/>
69+
</display>
70+
</class>
71+
<class id="8" language="java" name="com.iluwatar.reactor.framework.NioDatagramChannel" project="reactor"
72+
file="/reactor/src/main/java/com/iluwatar/reactor/framework/NioDatagramChannel.java" binary="false"
73+
corner="BOTTOM_RIGHT">
74+
<position height="-1" width="-1" x="1110" y="539"/>
75+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
76+
sort-features="false" accessors="true" visibility="true">
77+
<attributes public="true" package="true" protected="true" private="false" static="true"/>
78+
<operations public="true" package="true" protected="true" private="true" static="true"/>
79+
</display>
80+
</class>
81+
<class id="9" language="java" name="java.nio.channels.ServerSocketChannel" project="abstract-factory"
82+
file="/opt/Softwares/Eclipses/MARS/eclipse/jre/lib/rt.jar" binary="true" corner="BOTTOM_RIGHT">
83+
<position height="-1" width="-1" x="609" y="540"/>
84+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
85+
sort-features="false" accessors="true" visibility="true">
86+
<attributes public="true" package="false" protected="true" private="false" static="true"/>
87+
<operations public="false" package="true" protected="false" private="true" static="true"/>
88+
</display>
89+
</class>
90+
<class id="10" language="java" name="java.nio.channels.DatagramChannel" project="abstract-factory"
91+
file="/opt/Softwares/Eclipses/MARS/eclipse/jre/lib/rt.jar" binary="true" corner="BOTTOM_RIGHT">
92+
<position height="-1" width="-1" x="1202" y="395"/>
93+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
94+
sort-features="false" accessors="true" visibility="true">
95+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
96+
<operations public="false" package="true" protected="false" private="true" static="true"/>
97+
</display>
98+
</class>
99+
<interface id="11" language="java" name="com.iluwatar.reactor.framework.ChannelHandler" project="reactor"
100+
file="/reactor/src/main/java/com/iluwatar/reactor/framework/ChannelHandler.java" binary="false"
101+
corner="BOTTOM_RIGHT">
102+
<position height="-1" width="-1" x="303" y="-1"/>
103+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
104+
sort-features="false" accessors="true" visibility="true">
105+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
106+
<operations public="true" package="true" protected="true" private="true" static="true"/>
107+
</display>
108+
</interface>
109+
<class id="12" language="java" name="com.iluwatar.reactor.app.LoggingHandler" project="reactor"
110+
file="/reactor/src/main/java/com/iluwatar/reactor/app/LoggingHandler.java" binary="false" corner="BOTTOM_RIGHT">
111+
<position height="-1" width="-1" x="297" y="147"/>
112+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
113+
sort-features="false" accessors="true" visibility="true">
114+
<attributes public="true" package="true" protected="true" private="false" static="true"/>
115+
<operations public="true" package="true" protected="true" private="false" static="true"/>
116+
</display>
117+
</class>
118+
<class id="13" language="java" name="com.iluwatar.reactor.app.App" project="reactor"
119+
file="/reactor/src/main/java/com/iluwatar/reactor/app/App.java" binary="false" corner="BOTTOM_RIGHT">
120+
<position height="133" width="148" x="123" y="266"/>
121+
<display autosize="false" stereotype="true" package="true" initial-value="false" signature="true"
122+
sort-features="false" accessors="true" visibility="true">
123+
<attributes public="true" package="true" protected="true" private="false" static="true"/>
124+
<operations public="true" package="true" protected="true" private="false" static="true"/>
125+
</display>
126+
</class>
127+
<realization id="14">
128+
<end type="SOURCE" refId="5"/>
129+
<end type="TARGET" refId="3"/>
130+
</realization>
131+
<association id="15">
132+
<end type="SOURCE" refId="2" navigable="false">
133+
<attribute id="16" name="dispatcher"/>
134+
<multiplicity id="17" minimum="0" maximum="1"/>
135+
</end>
136+
<end type="TARGET" refId="3" navigable="true"/>
137+
<display labels="true" multiplicity="true"/>
138+
</association>
139+
<realization id="18">
140+
<bendpoint x="309" y="348"/>
141+
<end type="SOURCE" refId="4"/>
142+
<end type="TARGET" refId="3"/>
143+
</realization>
144+
<association id="19">
145+
<bendpoint x="460" y="203"/>
146+
<end type="SOURCE" refId="13" navigable="false">
147+
<attribute id="20" name="reactor"/>
148+
<multiplicity id="21" minimum="0" maximum="1"/>
149+
</end>
150+
<end type="TARGET" refId="2" navigable="true"/>
151+
<display labels="true" multiplicity="true"/>
152+
</association>
153+
<dependency id="22">
154+
<end type="SOURCE" refId="8"/>
155+
<end type="TARGET" refId="10"/>
156+
</dependency>
157+
<generalization id="23">
158+
<end type="SOURCE" refId="7"/>
159+
<end type="TARGET" refId="6"/>
160+
</generalization>
161+
<association id="24">
162+
<end type="SOURCE" refId="6" navigable="false">
163+
<attribute id="25" name="handler"/>
164+
<multiplicity id="26" minimum="0" maximum="1"/>
165+
</end>
166+
<end type="TARGET" refId="11" navigable="true"/>
167+
<display labels="true" multiplicity="true"/>
168+
</association>
169+
<association id="27">
170+
<end type="SOURCE" refId="6" navigable="false">
171+
<attribute id="28" name="reactor"/>
172+
<multiplicity id="29" minimum="0" maximum="1"/>
173+
</end>
174+
<end type="TARGET" refId="2" navigable="true"/>
175+
<display labels="true" multiplicity="true"/>
176+
</association>
177+
<dependency id="30">
178+
<end type="SOURCE" refId="13"/>
179+
<end type="TARGET" refId="12"/>
180+
</dependency>
181+
<association id="31">
182+
<end type="SOURCE" refId="2" navigable="false">
183+
<attribute id="32" name="selector"/>
184+
<multiplicity id="33" minimum="0" maximum="1"/>
185+
</end>
186+
<end type="TARGET" refId="1" navigable="true"/>
187+
<display labels="true" multiplicity="true"/>
188+
</association>
189+
<realization id="34">
190+
<end type="SOURCE" refId="12"/>
191+
<end type="TARGET" refId="11"/>
192+
</realization>
193+
<generalization id="35">
194+
<end type="SOURCE" refId="8"/>
195+
<end type="TARGET" refId="6"/>
196+
</generalization>
197+
<dependency id="36">
198+
<end type="SOURCE" refId="7"/>
199+
<end type="TARGET" refId="9"/>
200+
</dependency>
201+
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
202+
sort-features="false" accessors="true" visibility="true">
203+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
204+
<operations public="true" package="true" protected="true" private="true" static="true"/>
205+
</classifier-display>
206+
<association-display labels="true" multiplicity="true"/>
207+
</class-diagram>

reactor/index.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
layout: pattern
3+
title: Reactor
4+
folder: reactor
5+
permalink: /patterns/reactor/
6+
categories: Architectural
7+
tags:
8+
- Java
9+
- Difficulty-Expert
10+
---
11+
12+
**Intent:** The Reactor design pattern handles service requests that are delivered concurrently to an application by one or more clients. The application can register specific handlers for processing which are called by reactor on specific events. Dispatching of event handlers is performed by an initiation dispatcher, which manages the registered event handlers. Demultiplexing of service requests is performed by a synchronous event demultiplexer.
13+
14+
![Reactor](./etc/reactor.png "Reactor")
15+
16+
**Applicability:** Use Reactor pattern when
17+
18+
* a server application needs to handle concurrent service requests from multiple clients.
19+
* a server application needs to be available for receiving requests from new clients even when handling older client requests.
20+
* a server must maximize throughput, minimize latency and use CPU efficiently without blocking.
21+
22+
**Real world examples:**
23+
24+
* [Spring Reactor](http://projectreactor.io/)
25+
26+
**Credits**
27+
28+
* [Douglas C. Schmidt - Reactor](https://www.dre.vanderbilt.edu/~schmidt/PDF/Reactor.pdf)
29+
* [Doug Lea - Scalable IO in Java](http://gee.cs.oswego.edu/dl/cpjslides/nio.pdf)
30+
* [Netty](http://netty.io/)

0 commit comments

Comments
 (0)