You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: wiki/new-and-noteworthy-in-4.0.html
+6-6
Original file line number
Diff line number
Diff line change
@@ -427,7 +427,7 @@ <h2 id="wiki-h2-12">
427
427
<code>EventExecutor</code> and <code>EventExecutorGroup</code> - generic event loop API</li>
428
428
</ul>
429
429
<p>They are used as the base of the channel API which will be explained later in this document. For example, <code>ChannelFuture</code> extends <code>io.netty.util.concurrent.Future</code> and <code>EventLoopGroup</code> extends <code>EventExecutorGroup</code>.</p>
430
-
<p><imgsrc="https://camo.githubusercontent.com/0f8cc784d7f625a929786653e31587d3935b571c/687474703a2f2f756d6c2e6d766e7365617263682e6f72672f676973742f6434616439316631376162643131376533306631" alt="Event loop type hierarchy diagram" data-canonical-src="http://uml.mvnsearch.org/gist/d4ad91f17abd117e30f1"></p>
430
+
<p><imgsrc="https://camo.githubusercontent.com/b0e9af4442495cf432701731adf901886a75d81c/68747470733a2f2f6e657474792e696f2f696d616765732f636f6e63757272656e742e706e67" alt="Event loop type hierarchy diagram" data-canonical-src="https://netty.io/images/concurrent.png"></p>
<p>In 4.0, many classes under the <code>io.netty.channel</code> package have gone through a major overhaul, and thus simple text search-and-replace will not make your 3.x application work with 4.0. This section will try to show the thought process behind such a big change, rather than being an exhaustive resource for all the changes.</p>
@@ -441,7 +441,7 @@ <h4 id="wiki-h4-16">
441
441
<p>In 3.x, <code>ChannelHandler</code> was just a tag interface, and <code>ChannelUpstreamHandler</code>, <code>ChannelDownstreamHandler</code>, and <code>LifeCycleAwareChannelHandler</code> defined the actual handler methods. In Netty 4, <code>ChannelHandler</code> merges <code>LifeCycleAwareChannelHandler</code> along with a couple more methods which are useful to both an inbound and an outbound handler:</p>
<p>In 3.x, every I/O operation created a <code>ChannelEvent</code> object. For each read / write, it additionally created a new <code>ChannelBuffer</code>. It simplified the internals of Netty quite a lot because it delegates resource management and buffer pooling to the JVM. However, it often was the root cause of GC pressure and uncertainty which are sometimes observed in a Netty-based application under high load.</p>
<p>When a new connected <code>Channel</code> is created in 3.x, at least three <code>ChannelStateEvent</code>s are triggered: <code>channelOpen</code>, <code>channelBound</code>, and <code>channelConnected</code>. When a <code>Channel</code> is closed, at least 3 more: <code>channelDisconnected</code>, <code>channelUnbound</code>, and <code>channelClosed</code>.</p>
456
-
<p><imgsrc="https://camo.githubusercontent.com/bc51b738136f98753ad73372aeedc6e8376c376e/687474703a2f2f756d6c2e6d766e7365617263682e6f72672f676973742f3433333564363363353330623665316335653265" alt="Netty 3 Channel state diagram" data-canonical-src="http://uml.mvnsearch.org/gist/4335d63c530b6e1c5e2e"></p>
456
+
<p><imgsrc="https://camo.githubusercontent.com/f6e3580ea502a4f318ba9a20ac69342ff47ff4f2/68747470733a2f2f6e657474792e696f2f696d616765732f73746174655f332e706e67" alt="Netty 3 Channel state diagram" data-canonical-src="https://netty.io/images/state_3.png"></p>
457
457
<p>However, it's of dubious value to trigger that many events. It is more useful for a user to get notified when a <code>Channel</code> enters the state where it can perform reads and writes.</p>
458
-
<p><imgsrc="https://camo.githubusercontent.com/f89f38aa4d99131fa547033192d2d5361cca297f/687474703a2f2f756d6c2e6d766e7365617263682e6f72672f676973742f3665666662363861643235313563613064363138" alt="Netty 4 Channel state diagram" data-canonical-src="http://uml.mvnsearch.org/gist/6effb68ad2515ca0d618"></p>
458
+
<p><imgsrc="https://camo.githubusercontent.com/aafdea3bd1be0ab082a9a1250952accfb8c41a47/68747470733a2f2f6e657474792e696f2f696d616765732f73746174655f736d616c6c5f342e706e67" alt="Netty 4 Channel state diagram" data-canonical-src="https://netty.io/images/state_small_4.png"></p>
459
459
<p><code>channelOpen</code>, <code>channelBound</code>, and <code>channelConnected</code> have been merged to <code>channelActive</code>. <code>channelDisconnected</code>, <code>channelUnbound</code>, and <code>channelClosed</code> have been merged to <code>channelInactive</code>. Likewise, <code>Channel.isBound()</code> and <code>isConnected()</code> have been merged to <code>isActive()</code>.</p>
460
460
<p>Note that <code>channelRegistered</code> and <code>channelUnregistered</code> are not equivalent to <code>channelOpen</code> and <code>channelClosed</code>. They are new states introduced to support dynamic registration, deregistration, and re-registration of a <code>Channel</code>, as illustrated below:</p>
461
-
<p><imgsrc="https://camo.githubusercontent.com/af66a515de1ad848367c7ceffe1f8567dcac43c9/687474703a2f2f756d6c2e6d766e7365617263682e6f72672f676973742f3633383235333066373839306239663136343732" alt="Netty 4 Channel state diagram for re-registration" data-canonical-src="http://uml.mvnsearch.org/gist/6382530f7890b9f16472"></p>
461
+
<p><imgsrc="https://camo.githubusercontent.com/856a90ef3d3da9e0f9c2ea0b2ce07cd0adf91713/68747470733a2f2f6e657474792e696f2f696d616765732f73746174655f342e706e67" alt="Netty 4 Channel state diagram for re-registration" data-canonical-src="https://netty.io/images/state_4.png"></p>
<p>4.0 introduced a new operation called <code>flush()</code> which explicitly flushes the outbound buffer of a <code>Channel</code>, and <code>write()</code> operation does not flush automatically. You can think of this as a <code>java.io.BufferedOutputStream</code>, except that it works at message level.</p>
0 commit comments