Compare commits

...

162 Commits
main ... 3.2

Author SHA1 Message Date
jbertram 1808046061 Simple retry mechanism to cope with a temporarily unavailable endpoint
Motivation:
Use simple retry mechanism when try to connect to peer so a slow-startup will not produce an error

Modification:
Add new Servlet params which allow to configure retry count and wait time. Default behaviour is the same as before

Result:
It is now possible to configure retry when the peer is not up yet and the Servlet is init.
2014-03-12 07:00:50 +01:00
Norman Maurer a4a3e8c5b6 [maven-release-plugin] prepare for next development iteration 2013-11-28 12:27:55 +01:00
Norman Maurer 4ec4abe2e7 [maven-release-plugin] prepare release netty-3.2.10.Final 2013-11-28 12:27:50 +01:00
Norman Maurer 8680c01ba4 Disable usage of maven-jdocbook-plugin 2013-11-28 12:17:45 +01:00
Norman Maurer b8de307b0d [#2013] Fix a race which could happen to have the worker Thread interrupted during close(...) when using OIO 2013-11-28 12:17:35 +01:00
Norman Maurer 4a5c21b2e1 [maven-release-plugin] prepare for next development iteration 2013-01-21 07:44:58 +01:00
Norman Maurer 3b5550e16b [maven-release-plugin] prepare release netty-3.2.9.Final 2013-01-21 07:44:49 +01:00
Aaron 011ef5dae8 [#915] [#923] Expanded scope of the handshake locks in SSLHandler to avoid possible negotiation after the first SSLEngine wrap 2013-01-21 06:59:40 +01:00
Norman Maurer 974d47f3c4 [maven-release-plugin] prepare for next development iteration 2012-12-20 10:21:46 +01:00
Norman Maurer f0044891ee [maven-release-plugin] prepare release netty-3.2.8.Final 2012-12-20 10:21:38 +01:00
Norman Maurer cffd158c1a Ignore idea project directory 2012-12-20 10:15:39 +01:00
Norman Maurer c30486d43b Add SNAPSHOT to the version to be able to use the release plugin 2012-12-20 10:08:22 +01:00
Norman Maurer 82b040bb53 Upgrade to latest parent to make the release process easier 2012-12-20 10:04:03 +01:00
Norman Maurer 2b88ab01a9 Get ready for next release 2012-12-20 08:04:47 +01:00
Norman Maurer b99f442cf1 [#829] Fix a race in SslHandler which could lead to all types of SSLExceptions, including handshake() failure 2012-12-20 07:51:35 +01:00
Trustin Lee 0b5abecc00 [maven-release-plugin] prepare release netty-3.2.7.Final 2011-11-24 12:24:38 +09:00
Trustin Lee 4334161526 Fix build errors 2011-11-24 12:16:31 +09:00
Trustin Lee 4be4e583c7 Upgrade depepdencies to the latest versions
* Regenerate LocalTimeProtocol.java with the latest protoc
* Add an instruction on how to generate LocalTimeProtocol.java
* Not upgrading maven-bundle-plugin, which has a regression in 2.3.5:
  * https://issues.apache.org/jira/browse/FELIX-3058
2011-11-24 11:05:33 +09:00
Trustin Lee 84fd044eb4 Fix weird repo mess 2011-11-24 10:20:05 +09:00
Trustin Lee 359417358e Add missing license headers and fix class name
* Classloader -> ClassLoader
2011-11-24 10:11:50 +09:00
norman e6ef89263b Remove @override annotation from interface implementation to make it
compile and usable with java5. This part of the backport of pull request
#75
2011-11-23 15:09:50 +01:00
norman 9424c26caf Merge pull request #75 to the 3.2 branch. Also remove @override
annotation for interface implementation to make it possible to compile
and use with java5
2011-11-23 15:07:02 +01:00
norman 8d40487ff7 Backport fix for #72. QueryStringDecoder should also support ; 2011-11-23 07:22:49 +01:00
Trustin Lee dcaf6c8645 Include the duplicate name in an exception message 2011-11-23 14:06:07 +09:00
Trustin Lee 249ab1b5b4 Move a final field before non-finals 2011-11-23 14:04:28 +09:00
Trustin Lee c3240a1ded Merge branch '3.2' of github.com:netty/netty into 3.2 2011-11-23 14:02:35 +09:00
Trustin Lee 2a9c5efe8f Add a missing close(SelectionKey) call
* Without calling close(SelectionKey), the client boss loop can fall
into an infinite loop.
2011-11-23 13:58:52 +09:00
Norman Maurer 82c852fc5e failFast field should be final 2011-11-22 12:58:20 +01:00
Trustin Lee 0da39901c8 Consistent fail-fast property
* DelimiterBasedFrameDecoder and LengthFieldBasedFrameDecoder must
expose the fail-fast option consistently
* Renamed failImmediatelyOnTooLongFrame to failFast
2011-11-22 18:39:11 +09:00
Trustin Lee 0d4dfefeb0 Backport the pull request #70 2011-11-22 16:34:35 +09:00
norman 13d0d84852 Revert "Fix NETTY-452, add an option for whether to count length field into packet length or not"
This reverts commit db5d74748b.
2011-11-11 08:38:50 +01:00
norman 852e0a1ed8 Revert "Revert "Adjust to current master""
This reverts commit 91ea9028f4.
2011-11-11 08:38:10 +01:00
norman 91ea9028f4 Revert "Adjust to current master"
This reverts commit 16792a22be.
2011-11-11 08:36:12 +01:00
norman 16792a22be Adjust to current master 2011-11-10 09:28:07 +01:00
norman 6231030f2b Add failImmediatelyOnTooLongFrame option to DelimiterBasedFrameDecoder
and LengthFieldBasedFrameDecoder
2011-11-10 09:03:56 +01:00
Norman Maurer db5d74748b Fix NETTY-452, add an option for whether to count length field into
packet length or not
2011-11-09 20:43:50 +01:00
Norman Maurer 582b25eaf5 Merge pull request #50 from jpinner/ignore_httponly_cookies_3.2
Ignore httponly cookies 3.2
2011-11-09 10:11:13 -08:00
Jeff Pinner 5b46cb4cfe ignore HttpOnly as a cookie name instead of throwing exception 2011-11-09 09:51:26 -08:00
Norman Maurer 9c1950606b Merge branch '3.2' of ssh://git@github.com/netty/netty.git into 3.2 2011-11-06 20:18:18 +01:00
Norman Maurer dd8ec0ea30 release replaying decoder cumulation buffer after firing upstream 2011-11-06 20:17:21 +01:00
Norman Maurer a555949cb5 fix compareTo 2011-11-06 07:55:30 +01:00
Norman Maurer e4bd678846 Remove not used SerialVersionUID fields 2011-11-03 20:30:44 +01:00
Norman Maurer a91c56c84d Remove iostream support from 3.2 branch. This will only go into 4.x 2011-11-03 19:29:22 +01:00
Norman Maurer 24e0b01e8d Release the cumulation buffer after firing upstream so we don't end up
with a "leak" because of a very big ChannelBuffer. This patch is
extracted of the pull request 39. Thanks to arya for the patch. See
NETTY-453
2011-11-03 11:29:39 +01:00
Trustin Lee 5860ce337d Merge branch '3.2' of git://github.com/trustin/netty into 3.2 2011-10-31 15:23:25 -07:00
Trustin Lee 0f8cecc907 Upgrade to JUnit 4.10 2011-10-31 15:20:25 -07:00
Norman Maurer d742a11c25 Merge pull request #22 from pfisterer/master. Which adds a
IOStreamChannelFactory which can be used to connect to InputStream and
OutputStream
2011-10-29 20:18:10 +02:00
norman b1c27063a2 Make sure the fireExceptionCaught will not get fired while holding a
lock. This will prevent a deadlock which you may see if you have an
ChannelHandler that will trigger Channel.close() on an Exception. See
NETTY-443
2011-10-25 11:52:27 +02:00
norman 6728766158 ChannelLocal nows removes Channel instances from itself once the Channel
was closed. This is configurable via a constructor parameter to allow
the user to choose what to do. The default is to not remove the Channel
from the ChannelLocal to not break usage which depends on the "old"
behavior. See NETTY-447
2011-10-24 08:32:17 +02:00
Trustin Lee 322f0ccae4 [maven-release-plugin] prepare for next development iteration 2011-10-22 22:39:15 -07:00
Trustin Lee 20df06911e [maven-release-plugin] prepare release netty-3.2.6.Final 2011-10-22 22:39:07 -07:00
Trustin Lee e3386736c0 Fix NETTY-432 HttpContentEncoder should not encode if Content-Encoding is set already and it is not 'identity' 2011-10-22 22:08:49 -07:00
Trustin Lee a67cdaeb48 Clean up FileRegion and its implementation changes
* Fix broken javadoc tags
* Remove unnecessary public modifier
* Reorder method
* Make releaseAfterTransfer immutable
2011-10-22 21:47:07 -07:00
Norman Maurer dbccc9e52b Merge pull request #34 from normanmaurer/3.2
Only release FileRegion if configured to do so. See NETTY-440
2011-10-22 11:31:27 -07:00
Norman Maurer 2a4b91b59b Only release FileRegion after transfer was done if its configured todo
so. The default is false to be sure we are compatible with earlier 3.2
releases. This should be changed to default true in the master branch.
See NETTY-440
2011-10-22 14:56:53 +02:00
Trustin Lee 4b9b421af2 NETTY-439 Call channelBound/Connected from worker
* Move channelBound() to RegisterTask
* Simplify the if block in RegisterTask
2011-10-21 15:42:02 -07:00
Trustin Lee beadadecf7 Fix NETTY-445 Memory leak in SslHandler
* Ensure SSLEngine.closeInbound() and closeOutbound() is called on
handshake failure.
* Ensure connection is closed when a closure request is issued and
handshake failed.
2011-10-21 13:54:07 -07:00
Norman Maurer ce1643c187 Merge pull request #30 from normanmaurer/3.2
Move channelConnected handling to worker thread + javadocs
2011-10-21 08:48:16 -07:00
norman 48c6793d30 Revert invalid fix 2011-10-17 15:56:38 +02:00
norman 4be22a42ef ThreadNameDeterminer.CURRENT return the right name now. Was returning
null before all the time
2011-10-17 15:49:29 +02:00
norman 35401caac4 Remove unused imports and fix warnings 2011-10-13 12:08:06 +02:00
norman fd1d11ec39 Add support for FileRegion in OIOWorker. 2011-10-12 17:09:02 +02:00
norman 2d25998eb4 Make sure FileRegion.releaseExternalResources() is called after the
write was done. See NETTY-440
2011-10-12 15:07:53 +02:00
norman fb408778d1 Only handle the channelConnected in the worker thread. The channelOpen
and channelBound was moved back to the boss thread. This was done after
reading NETTY-154
2011-10-12 13:15:06 +02:00
norman cb2e047f1d Remove code which I committed by mistake 2011-10-12 13:04:37 +02:00
norman bbdc2032f0 Make sure the ChannelOpen, ChannelBound and ChannelConnected events get
fired from within an IO-Worker Thread. This makes sure the Boss-Thread
will not get blocked by any user action
2011-10-12 13:02:50 +02:00
norman 28120aa778 Add javadoc entry to explain that some events are executed in the boss
thread.
2011-10-12 10:35:12 +02:00
norman 203a104889 Merge branch '3.2' of ssh://git@github.com/normanmaurer/netty.git into 3.2 2011-10-12 10:15:22 +02:00
Trustin Lee ba72bf7235 NETTY-438 Re-enable SSL re-negotiation by default
* Re-enabled renegotiation
* Updated Javadoc
2011-10-10 20:47:32 +09:00
Norman Maurer b89487c445 Add patch of NETTY-434 to the mix to fix Deadlock in
ChunkedWriteHandler. This patch was not written by me...
2011-10-10 18:00:32 +09:00
Evan Meagher 256621246c Fix wording in "Summary" section. 2011-10-10 17:42:15 +09:00
Evan Meagher f0b30aa8e1 Fix wording in "Advanced Components for More Rapid Development" section. 2011-10-10 17:42:07 +09:00
Evan Meagher 95b127748e Fix wording in "Interceptor Chain Pattern" section. 2011-10-10 17:42:00 +09:00
Evan Meagher 56d6217b53 Fix wording in "Universal Asynchronous I/O API" section. 2011-10-10 17:41:52 +09:00
Evan Meagher d1a15c9aff Fix wording in "Rich Buffer Data Structure" section. 2011-10-10 17:41:45 +09:00
Norman Maurer ed30037098 Add patch of NETTY-434 to the mix to fix Deadlock in
ChunkedWriteHandler. This patch was not written by me...
2011-09-30 22:14:36 +02:00
Trustin Lee a78d37460c Fixed a compilation error in the example 2011-08-26 13:24:17 +09:00
Trustin Lee b0d0502413 Added a TooLongFrameException recovery test for DelimiterBasedFrameDecoder 2011-08-19 11:11:16 +09:00
Trustin Lee 3effb0d1b0 NETTY-435 LengthFieldBasedFrameDecoder fails to recover from TooLongFrameException
* Fixed a bug where TooLongFrameException is not raised immediately when the large frame was fully decoded at the first attempt
* Fixed a bug where LengthFieldBasedFrameDecoder does not reset its state completely after raising TooLongFrameException
2011-08-19 11:05:24 +09:00
Trustin Lee 58cc6aec86 NETTY-431 HashedWheelTimer's TimerTask may execute after call to Timeout.cancel()
* Replaced a volatile boolean flag and system date access with an atomic integer flag.
2011-08-12 14:03:48 +09:00
Trustin Lee 1345a00a1a NETTY-430 ChunkedWriteHandler NPE 2011-08-12 13:39:18 +09:00
Trustin Lee 7eb39aaf93 NETTY-429 IllegalArgumentException when an HTTP server sends a '100 Continue' response to HttpContentDecoder.
* Fixed a silly coding mistake where I sent the event in the opposite direction
2011-08-03 21:26:31 +09:00
Trustin Lee b969706832 NETTY-428 SslHandler does not trigger an exceptionCaught event for some handshake failure cases.
* Made sure SslHandler.handshake() and SslHandler.close() trigger an exceptionCaught event when failed
2011-08-02 15:39:25 +09:00
Trustin Lee 5f19f4c0b6 SSLEngine.beginHandshake() can throw a RuntimeException. 2011-08-02 15:09:35 +09:00
Trustin Lee 0b36aa6270 [maven-release-plugin] prepare for next development iteration 2011-08-02 10:47:19 +09:00
Trustin Lee a96d88c251 [maven-release-plugin] prepare release netty-3.2.5.Final 2011-08-02 10:47:07 +09:00
Trustin Lee dc33e99872 NETTY-408 ChunkedStream generates 1-byte chunks for wrapped input streams that does have sane implementation of available() method
* Updated JavaDoc so that users don't specify an InputStream with poor available() implementation.
2011-08-02 09:48:34 +09:00
Trustin Lee e0eb72618a NETTY-384 Another deadlock in ChunkedWriteHandler
ChunkedWriteHandler.discard() do not issue write requests to trigger exceptionCaught events and to notify write futures anymore.  Instead, it triggers exceptionCaught events and notifies write futures by itself.  Therefore, no write lock is involved during discard(), avoiding the reported dead lock.

However, this is a temporary solution, and eventually Netty must introduce more robust event thread model.
2011-08-02 09:33:53 +09:00
Trustin Lee 654da6d02a NETTY-422 Add getPipeline() to CodecEmbedder so that a user can modify the pipeline dynamically. 2011-08-02 08:49:13 +09:00
Trustin Lee 8f30a11c67 NETTY-423 Add ChannelPipeline.getNames() 2011-08-02 08:44:15 +09:00
Trustin Lee 4321135452 NETTY-420 HttpClientCodec doesn't handle HEAD requests with Transfer-Encoding: chunked responses
* Reverted back the workaround for servers that sends unnecessary zero-byte chunk in a HEAD response because it actually breaks the codec when the server that conforms to the RFC.
2011-08-02 08:35:12 +09:00
Trustin Lee 5cdcc67086 NETTY-419 ObjectEncoder/ObjectDecoder fails with NPE when deserializing the java.lang.Class instance of an interface type
* Fixed a bug where deserializing an interface class fails due to wrong lookup.
* Implemented class lookup caching
2011-08-02 08:25:26 +09:00
Trustin Lee 99daeebe4a NETTY-417 client channel still open after close and wait
* Fixed a bug in SslHandler where a write attempt made after SSLEngine is closed result in unnotified future.  Fixed by respecting the case where SslEngineResult.Status == CLOSED
2011-08-02 07:59:14 +09:00
Trustin Lee 07e9378423 NETTY-417 client channel still open after close and wait
* Fixed a race condition where NioSocketChannel's state variable is updated *after* its close future is notified
* Removed unnecessary use of ChannelFutureListeners in NioSocketChannel and AbstractChannel

Conflicts:

	src/main/java/org/jboss/netty/channel/AbstractChannel.java
	src/main/java/org/jboss/netty/channel/socket/nio/NioSocketChannel.java
2011-08-02 07:58:16 +09:00
Trustin Lee caf8b39172 Fixed a bug where the future associated with the close request is not notified when the channel was closed already when SslHandler attempts to send a closure_notify.
This shouldn't be a problem to most applications because they usually do not specify their own future object for the close request.
2011-08-02 07:49:45 +09:00
Felix Trepanier 7e50bd5160 do not encode if empty content 2011-08-02 06:48:01 +09:00
Trustin Lee 483f093036 NETTY-415 ChannelFuture.setFailure() not called when exception thrown handling Channel.close()
* Made sure the ChannelFuture associated with a downstream event is marked as failure when an exception is raised before it reaches at ChannelSink.
2011-08-02 06:37:00 +09:00
Trustin Lee a804c3495e NETTY-418 isCompleteFailure() and isCompleteSuccess() are both true at the same time
* Fixed incorrect isPartialSuccess(), isPartialFailure(), isCompleteFailure() implementation
2011-08-01 06:12:01 +09:00
Trustin Lee 2d35bf2155 NETTY-425 ChannelBuffers.compare does not handle unsigned bytes correctly
* Fixed a bug where signed comparison is made where unsigned comparison is expected
2011-08-01 04:28:29 +09:00
Trustin Lee fba8c7b7a4 NETTY-426 Prevent a user from reusing an upstream MessageEvent to write
something

Modified the pipeline implementations so that it rejects the attempt to
send an UpstreamMessageEvent to downstream
2011-08-01 04:17:39 +09:00
Trustin Lee bf41f4b099 NETTY-410 NioWorker write deadlock
Applied the patch provided by Greg Dhuse.
2011-08-01 04:00:26 +09:00
Trustin Lee d1b40a3c8b NETTY-407 HttpTunnelingClientSocketChannel failed close() is not sent to
calling futures.

* HttpTunnelingClientSocketChannel.writeLastChunk should return a failed
future instead of raising an exception.
2011-08-01 03:54:47 +09:00
Trustin Lee 8f659833c6 NETTY-406 ProtobufEncoder should also support Message.Builder
* Added support for Message.Builder
2011-08-01 03:46:51 +09:00
Trustin Lee 7338267221 NETTY-389 java.lang.ClassCastException: org.jboss.netty.channel.FileRegion cannot be cast to org.jboss.netty.buffer.ChannelBuffer
* Updated JavaDoc to let users know that not all transports support FileRegion
* Added FIXME for future improvement
2011-08-01 03:39:31 +09:00
Trustin Lee b2bf5e60af NETTY-410 NioWorker write deadlock
Applied the patch provided by Greg Dhuse.
2011-08-01 01:33:20 +09:00
Trustin Lee 189567322f Fixed code format 2011-07-29 13:11:19 +09:00
nibin bc8b92e1f7 * Fixed the bug in CookieEncoder if there are no cookie's set while
calling encode(). Without the fix, it ended up in calling the
exception "java.lang.StringIndexOutOfBoundsException".
* Also added test case to verify the patch

Change-Id: Ib96425e07ab50be027ade7be0748cceb6438a586

Conflicts:

	src/test/java/org/jboss/netty/handler/codec/http/CookieEncoderTest.java
2011-07-29 13:09:33 +09:00
Trustin Lee 349b03b467 Handle chunked encoding properly for non-200 responses 2011-05-26 12:11:02 +09:00
Trustin Lee 8f7efa0548 Made IdleStateHandler @Sharable and removed unnecessary lazy
initialization in ReadTimeoutHandler
2011-05-04 17:30:25 +09:00
Trustin Lee 098ca0342c NETTY-401 - NullPointerException when ReadTimeoutHandler is
concurrently initialized and destroyed

* Made ReadTimeoutHandler @Sharable
* Updated the UptimeClient again
** no static fields for global state - just reuse the handlers.
2011-05-04 17:10:32 +09:00
Trustin Lee 8458c289e2 Merge branch '3.2' of git://github.com/netty/netty into 3.2 2011-05-04 16:56:36 +09:00
Trustin Lee c3d97acd03 Fixed a bug in the uptime example where uptime is reset even when it
shouldn't be.
2011-05-04 16:55:54 +09:00
Trustin Lee d7700f25b0 Fixed a bug in the uptime example where uptime is reset even when it
shouldn't be.
2011-05-04 16:53:31 +09:00
Bruce Mitchener 2a2e57f618 Close bold tag. 2011-05-04 14:04:48 +09:00
Will 1734f5fd01 fix typo in exception message 2011-04-18 17:00:50 +09:00
Daniel Bevenius 66566a1acd Added a timeout for the UdpClient so that the test cannot hang.
I noticed the build "hanging/halting" on the test when running the cobertura code coverage Eclipse plugin.
2011-04-18 16:57:17 +09:00
Trustin Lee 841043006c NETTY-394 SslHandler does not work with a little endian buffer
Added SslHandler.getShort() which replaces ChannelBuffer.getShort() calls
2011-04-02 03:32:15 +09:00
Trustin Lee 2351797a43 NETTY-393: SslHandler infinite loop on Apache Harmony with large payload
Increased the SSL buffer size by 1024 as advised
2011-04-02 03:09:05 +09:00
Trustin Lee 370160d0a5 Fixed an infinite loop on a certain NIO impl 2011-03-25 02:30:58 +09:00
Trustin Lee 77f79c3ea6 Fixed a typo 2011-03-09 00:21:11 +09:00
Trustin Lee df656bf139 Fixed a compilation error. Doh! 2011-03-05 02:51:51 +09:00
Trustin Lee 2d7e9cab6d Updated Javadoc 2011-03-03 02:02:18 +09:00
Trustin Lee 522bfc4664 Do not write an empty buffer unnecessarily when nextChunk() returned
null
2011-03-03 01:36:10 +09:00
Trustin Lee bf043937af Better variable naming / Fixed potential stall 2011-03-02 20:00:07 +09:00
Trustin Lee 8763c0b858 NETTY-383 deflate-raw support for HttpContentDecompressor
* Added ZlibWrapperType.ZLIB_OR_NONE for auto-detection and updated
the relevant Zlib implementation
2011-02-22 18:05:16 +09:00
Trustin Lee 0859ff782e Fixed issue: NETTY-382 ChannelLocal.remove() should return the return
value of initialValue() instead of null when no value was set.
2011-02-22 16:54:25 +09:00
Trustin Lee 31b257f6f2 [maven-release-plugin] prepare for next development iteration 2011-02-07 21:34:50 +09:00
Trustin Lee 0b47c34036 [maven-release-plugin] prepare release netty-3.2.4.Final 2011-02-07 21:34:34 +09:00
Trustin Lee ab2cb4386f Fixed broken SCM URL in pom.xml 2011-02-07 21:31:08 +09:00
Trustin Lee 4a1c1e97f3 Upgraded the enforcer plugin and updated the rule 2011-02-07 21:16:36 +09:00
Trustin Lee 65a445014c Updated the dependency and plugin versions 2011-02-07 21:06:11 +09:00
Trustin Lee ad1f698cf1 * Fixed a documentation error in ChannelBuffer javadoc
* Clearly specified that FrameDecoder is an implementation of ChannelHandler
2011-02-07 19:59:53 +09:00
Trustin Lee 00e24ce0bb Added Main-Class property to the manifest for easier version check 2011-02-02 13:16:09 +09:00
Trustin Lee 78104cbd28 Fixed NETTY-381 channelDisconnected event is sometimes not triggered when Channel.close() is called by multiple threads.
* Internal state variable should never be set to ST_CLOSED until the close channel future is set
2011-02-01 13:39:20 +09:00
Trustin Lee a8f3353d7c Fixed Javadoc error 2011-02-01 12:28:40 +09:00
Trustin Lee 5276a92e71 Fixed issue: NETTY-372 NullPointerException in ChunkedWriteHandler 2011-02-01 12:20:57 +09:00
Trustin Lee ae6a5ca82d Fixed issue: NETTY-373 Deadlock in ChunkedWriteHandler on channel
close.

* channelInterestChanged event is not fired anymore when a socket is
closing because it is unnecessary
2011-02-01 11:43:16 +09:00
Trustin Lee 5c75915f4c NioDatagramWorker should reject the write attempt on an unbound
socket, raising NotYetBoundException.
2011-02-01 11:35:26 +09:00
Trustin Lee be6cdb4a11 Fixed issue: NETTY-380 releaseExternalResources() hang indefinitely
when called from a handler

* Replaced IoWorkerRunnable with DeadLockProofWorker
* ExecutorUtil now checks dead lock
2011-02-01 11:04:13 +09:00
Trustin Lee 339c2a6641 ChannelGroup.write() should not write to a server channel 2011-01-31 15:25:39 +09:00
Trustin Lee 31df7fa9b1 Fixed NETTY-365 HashedWheelTimer.stop() enters an infinite loop when
called from TimerTask
Fixed NETTY-379 Intermittent slippery task timeout in HashedWheelTimer
* Throw an IllegalStateException if HashedWheelTimer.stop() is called
from TimerTask
* Reschedule the slipped task accurately instead of delaying it by one
round
2011-01-31 14:48:30 +09:00
Trustin Lee d1f05ea4e7 Fixed a race condition in MemoryAwareThreadPoolExecutor
Replaced a semaphore with a custom concurrency construct to fix a
known race condition in MemoryAwareThreadPoolExecutor
2011-01-13 14:57:03 +09:00
Trustin Lee 5af93c2753 Fixed incorrect usage of ByteBuffer.arrayOffset()
* NETTY-368 Wrappedbuffer does not honour posiiton()
* and similar mistakes found during a review
2011-01-12 19:24:09 +09:00
Trustin Lee 55f9597c0f Set buildNumber to 'unknown' when built out of git repository 2011-01-12 18:59:09 +09:00
Trustin Lee b4fe592a53 Fixed issue: NETTY-371 OSGi Manifest requires Bundle-BuddyPolicy for
object deserialization

Added proper BuddyPolicy properties to the manifest
2011-01-12 18:32:33 +09:00
Trustin Lee 5a3f8aeb82 Fixed issue: NETTY-374 ChunkedWriteHandler and handling messages after
channel close

Fixed a bug where a write requests made after closure are not
discarded
2011-01-12 18:27:17 +09:00
Trustin Lee ed23803a87 Fixed issue: NETTY-377 messageReceived could happen before
channelConnected when using local channels

More precise LocalChannel state management to avoid incorrect event
order
2011-01-12 17:58:49 +09:00
Trustin Lee 4861e39a74 Merge branch '3.2' of git://github.com/netty/netty into 3.2 2011-01-11 18:59:31 +09:00
Trustin Lee 966b894aa3 Changed SCM URLs 2011-01-11 18:56:45 +09:00
Trustin Lee 3bb28f13e5 Fixed build issues
* Replaced the buildnumber plugin with antrun exec tag to generate the build number correctly.
* Fixed a problem where MANIFEST.MF is lost
2011-01-11 18:56:37 +09:00
Trustin Lee 00056f585f Changed SCM URLs 2011-01-11 18:41:14 +09:00
Trustin Lee 95ac54ea90 Fixed build issues
* Replaced the buildnumber plugin with antrun exec tag to generate the build number correctly.
* Fixed a problem where MANIFEST.MF is lost
2011-01-11 18:17:45 +09:00
Trustin Lee 1481cee81a Fixed indentation 2011-01-04 14:53:01 +09:00
iainmcgin fa28d2824f Fix for NETTY-370 - documentation updated to reflect the correct behaviour of
high / low water marks on the interest ops of nio channels.
2011-01-04 14:51:10 +09:00
Bruce Mitchener 2d00f07d6c Correct variable name in code samples. 2011-01-04 14:39:22 +09:00
Trustin Lee 122db6fd21 Fixed NETTY-376 Manifest not present in the first entry of the zip 2011-01-04 14:25:11 +09:00
Trustin Lee 276626221d Merge branch '3.2' of github.com:trustin/netty into 3.2 2010-11-23 21:24:18 +09:00
Trustin Lee 957793304b Added IntelliJ specific files to .gitignore 2010-11-23 21:16:41 +09:00
Trustin Lee 914c9da8cc Added IntelliJ specific files to .gitignore 2010-11-23 20:10:51 +09:00
Trustin Lee e102647d65 Added Version.java to .gitignore because it's generated during the build 2010-11-15 18:18:09 +09:00
Trustin Lee 91d0ce74bb Reverted back the changes in DynamicChannelBuffer which made the test fail 2010-11-15 18:12:26 +09:00
Trustin Lee e395aacbd4 Imported the 3.2 branch from Netty SVN repository 2010-11-12 00:28:17 +09:00
500 changed files with 4593 additions and 2092 deletions

7
.gitignore vendored
View File

@ -1,7 +1,10 @@
# /
/.project
/.classpath
/.settings
/.idea
/target
/reports
/src/main/java/org/jboss/netty/util/Version.java
/*.iml
/*.ipr
/*.iws

148
pom.xml
View File

@ -20,13 +20,13 @@
<parent>
<groupId>org.jboss</groupId>
<artifactId>jboss-parent</artifactId>
<version>5</version>
<version>9</version>
</parent>
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
<packaging>bundle</packaging>
<version>4.0.0.Alpha1-SNAPSHOT</version>
<version>3.2.11.Final-SNAPSHOT</version>
<name>The Netty Project</name>
<url>http://www.jboss.org/netty/</url>
@ -49,9 +49,9 @@
<inceptionYear>2008</inceptionYear>
<scm>
<url>http://fisheye.jboss.org/browse/Netty</url>
<connection>scm:svn:http://anonsvn.jboss.org/repos/netty/trunk</connection>
<developerConnection>scm:svn:https://svn.jboss.org/repos/netty/trunk</developerConnection>
<url>https://github.com/netty/netty</url>
<connection>scm:git:git://github.com/netty/netty.git</connection>
<developerConnection>scm:git:ssh://git@github.com/netty/netty.git</developerConnection>
</scm>
<dependencies>
@ -59,7 +59,7 @@
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.3.0</version>
<version>2.4.1</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
@ -104,7 +104,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.11</version>
<version>1.6.4</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
@ -118,7 +118,7 @@
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-spi</artifactId>
<version>2.1.1.GA</version>
<version>2.1.2.GA</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
@ -152,30 +152,32 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>2.5.2</version>
<version>3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymockclassextension</artifactId>
<version>2.5.2</version>
<version>3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.5.11</version>
<version>1.6.4</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<jdk.min.version>1.5</jdk.min.version>
<maven.min.version>2.2.1</maven.min.version>
<attach-distribution>false</attach-distribution>
</properties>
@ -190,9 +192,14 @@
</resources>
<plugins>
<plugin>
<!-- See org.jboss:jboss-parent -->
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3</version>
<version>2.3.2</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.5</source>
@ -202,27 +209,9 @@
<showDeprecations>true</showDeprecations>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.0-beta-4</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>false</doCheck>
<doUpdate>true</doUpdate>
<revisionOnScmFailure>-1</revisionOnScmFailure>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.2</version>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
@ -253,7 +242,7 @@
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<version>2.10</version>
<configuration>
<forkMode>never</forkMode>
<excludes>
@ -265,11 +254,10 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.0.1</version>
<version>2.3.4</version>
<extensions>true</extensions>
<configuration>
<instructions>
<SCM-Revision>${buildNumber}</SCM-Revision>
<Bundle-SymbolicName>${project.groupId}</Bundle-SymbolicName>
<Bundle-DocURL>${project.url}</Bundle-DocURL>
<Bundle-Activator>
@ -287,12 +275,15 @@
<Import-Package>
*;resolution:=optional
</Import-Package>
<Eclipse-BuddyPolicy>registered</Eclipse-BuddyPolicy>
<Bundle-BuddyPolicy>registered</Bundle-BuddyPolicy>
<Main-Class>${project.groupId}.util.Version</Main-Class>
</instructions>
</configuration>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.1</version>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-source</id>
@ -308,7 +299,7 @@
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<version>1.7</version>
<executions>
<execution>
<id>write-version</id>
@ -318,9 +309,25 @@
</goals>
<configuration>
<tasks>
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<exec executable="git" outputproperty="gitOutput" resultproperty="gitExitCode" failonerror="false" failifexecutionfails="false">
<arg value="log" />
<arg value="-1" />
<arg value="--format=format:%h" />
</exec>
<if>
<equals arg2="0" arg1="${gitExitCode}" />
<then>
<property name="buildNumber" value="${gitOutput}" />
</then>
<else>
<property name="buildNumber" value="unknown" />
</else>
</if>
<echo>Build number: ${buildNumber}</echo>
<mkdir dir="${project.build.directory}" />
<echo message="${project.version}, r${buildNumber}" file="${project.build.directory}/version.txt" />
<echo message="// DO NOT MODIFY - WILL BE OVERWRITTEN DURING THE BUILD PROCESS${line.separator}package org.jboss.netty.util;${line.separator}/**${line.separator} * Provides the version information of Netty.${line.separator} * @apiviz.landmark${line.separator} */${line.separator}public final class Version {${line.separator} /** The version identifier. */${line.separator} public static final String ID = &quot;${project.version}-r${buildNumber}&quot;;${line.separator} /** Prints out the version identifier to stdout. */${line.separator} public static void main(String[] args) { System.out.println(ID); }${line.separator} private Version() { super(); }${line.separator}}${line.separator}" file="${basedir}/src/main/java/org/jboss/netty/util/Version.java" />
<echo message="${project.version}" file="${project.build.directory}/version.txt" />
<echo message="// DO NOT MODIFY - WILL BE OVERWRITTEN DURING THE BUILD PROCESS${line.separator}package org.jboss.netty.util;${line.separator}/**${line.separator} * Provides the version information of Netty.${line.separator} * @apiviz.landmark${line.separator} */${line.separator}public final class Version {${line.separator} /** The version identifier. */${line.separator} public static final String ID = &quot;${project.version}-${buildNumber}&quot;;${line.separator} /** Prints out the version identifier to stdout. */${line.separator} public static void main(String[] args) { System.out.println(ID); }${line.separator} private Version() { super(); }${line.separator}}${line.separator}" file="${basedir}/src/main/java/org/jboss/netty/util/Version.java" />
</tasks>
</configuration>
</execution>
@ -342,6 +349,10 @@
<move file="${project.build.directory}/${project.build.finalName}.jar" tofile="${project.build.directory}/${project.build.finalName}.orig.jar" />
<zip destfile="${project.build.directory}/${project.build.finalName}.jar">
<zipfileset filemode="644" src="${project.build.directory}/${project.build.finalName}.orig.jar" dirmode="755">
<include name="META-INF/MANIFEST.MF" />
</zipfileset>
<zipfileset filemode="644" src="${project.build.directory}/${project.build.finalName}.orig.jar" dirmode="755">
<exclude name="META-INF/MANIFEST.MF" />
<exclude name="*/*/*/example/**" />
</zipfileset>
</zip>
@ -351,6 +362,10 @@
<move file="${project.build.directory}/${project.build.finalName}-sources.jar" tofile="${project.build.directory}/${project.build.finalName}-sources.orig.jar" />
<zip destfile="${project.build.directory}/${project.build.finalName}-sources.jar">
<zipfileset filemode="644" src="${project.build.directory}/${project.build.finalName}-sources.orig.jar" dirmode="755">
<include name="META-INF/MANIFEST.MF" />
</zipfileset>
<zipfileset filemode="644" src="${project.build.directory}/${project.build.finalName}-sources.orig.jar" dirmode="755">
<exclude name="META-INF/MANIFEST.MF" />
<exclude name="*/*/*/example/**" />
</zipfileset>
</zip>
@ -367,12 +382,12 @@
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.8.1</version>
<version>1.8.2</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-launcher</artifactId>
<version>1.8.1</version>
<version>1.8.2</version>
</dependency>
<dependency>
<groupId>ant-contrib</groupId>
@ -389,7 +404,7 @@
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.6.1</version>
<version>2.8</version>
<executions>
<execution>
<id>generate-javadoc</id>
@ -404,7 +419,7 @@
<docletArtifact>
<groupId>org.jboss.apiviz</groupId>
<artifactId>apiviz</artifactId>
<version>1.3.1.GA</version>
<version>1.3.2.GA</version>
</docletArtifact>
<attach>false</attach>
<stylesheetfile>${basedir}/src/javadoc/stylesheet.css</stylesheetfile>
@ -421,8 +436,8 @@
<author>true</author>
<keywords>true</keywords>
<overview>${basedir}/src/javadoc/overview.html</overview>
<doctitle>${project.name} API Reference (${project.version}, r${buildNumber})</doctitle>
<windowtitle>${project.name} API Reference (${project.version}, r${buildNumber})</windowtitle>
<doctitle>${project.name} API Reference (${project.version})</doctitle>
<windowtitle>${project.name} API Reference (${project.version})</windowtitle>
<additionalparam>
-link http://java.sun.com/javase/6/docs/api/
-link http://code.google.com/apis/protocolbuffers/docs/reference/java/
@ -448,7 +463,7 @@
</plugin>
<plugin>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.1</version>
<version>2.2</version>
<executions>
<execution>
<id>generate-xref</id>
@ -465,10 +480,11 @@
<destDir>${project.build.directory}/xref</destDir>
<javadocDir>${project.build.directory}/api</javadocDir>
<stylesheet>${basedir}/src/xref/stylesheet.css</stylesheet>
<docTitle>${project.name} Source Xref (${project.version}, r${buildNumber})</docTitle>
<windowTitle>${project.name} Source Xref (${project.version}, r${buildNumber})</windowTitle>
<docTitle>${project.name} Source Xref (${project.version})</docTitle>
<windowTitle>${project.name} Source Xref (${project.version})</windowTitle>
</configuration>
</plugin>
<!--
<plugin>
<groupId>org.jboss.maven.plugins</groupId>
<artifactId>maven-jdocbook-plugin</artifactId>
@ -484,6 +500,36 @@
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.eclipse.wst.css</groupId>
<artifactId>core</artifactId>
<version>1.1.101-v200705302225</version>
<exclusions>
<exclusion>
<groupId>org.apache</groupId>
<artifactId>xerces</artifactId>
</exclusion>
<exclusion>
<groupId>com.ibm</groupId>
<artifactId>icu</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.wst.sse</groupId>
<artifactId>core</artifactId>
<version>1.1.202-v200709061102</version>
<exclusions>
<exclusion>
<groupId>org.apache</groupId>
<artifactId>xerces</artifactId>
</exclusion>
<exclusion>
<groupId>com.ibm</groupId>
<artifactId>icu</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jbossorg-docbook-xslt</artifactId>
@ -568,9 +614,10 @@
</options>
</configuration>
</plugin>
-->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<version>2.2.1</version>
<executions>
<execution>
<id>generate-distribution</id>
@ -591,9 +638,8 @@
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.0</version>
<version>2.2.1</version>
<configuration>
<tagBase>https://svn.jboss.org/repos/netty/tags</tagBase>
<!-- We don't want to use the default release profile because it
causes the JavaDoc and source jars to be deployed twice. -->
<useReleaseProfile>false</useReleaseProfile>

View File

@ -41,20 +41,20 @@
<title>Rich Buffer Data Structure</title>
<para>
Netty uses its own buffer API instead of NIO <classname>ByteBuffer</classname>
to represent a sequence of bytes. This approach has significant advantage
to represent a sequence of bytes. This approach has significant advantages
over using <classname>ByteBuffer</classname>. Netty's new buffer type,
&ChannelBuffer; has been designed from ground up to address the problems
&ChannelBuffer; has been designed from the ground up to address the problems
of <classname>ByteBuffer</classname> and to meet the daily needs of
network application developers. To list a few cool features:
<itemizedlist>
<listitem>
<para>
You can define your buffer type if necessary.
You can define your own buffer type if necessary.
</para>
</listitem>
<listitem>
<para>
Transparent zero copy is achieved by built-in composite buffer type.
Transparent zero copy is achieved by a built-in composite buffer type.
</para>
</listitem>
<listitem>
@ -84,7 +84,7 @@
<section>
<title>Universal Asynchronous I/O API</title>
<para>
Traditional I/O APIs in Java provided different types and methods for
Traditional I/O APIs in Java provide different types and methods for
different transport types. For example,
<classname>java.net.Socket</classname> and
<classname>java.net.DatagramSocket</classname> do not have any common
@ -93,32 +93,33 @@
</para>
<para>
This mismatch makes porting a network application from one transport to
the other tedious and difficult. The lack of portability between
transports becomes a problem when you need to support more transports not
rewriting the network layer of the application. Logically, many protocols
can run on more than one transport such as TCP/IP, UDP/IP, SCTP, and
serial port communication.
another tedious and difficult. The lack of portability between
transports becomes a problem when you need to support additional
transports, as this often entails rewriting the network layer of the
application. Logically, many protocols can run on more than one
transport such as TCP/IP, UDP/IP, SCTP, and serial port communication.
</para>
<para>
To make the matter worse, Java New I/O (NIO) API introduced the
incompatibility with the old blocking I/O (OIO) API, and so will NIO.2
(AIO). Because all these APIs are different from each other in design
and performance characteristics, you are often forced to determine which
API your application will depend on before you even begin the
implementation phase.
To make matters worse, Java's New I/O (NIO) API introduced
incompatibilities with the old blocking I/O (OIO) API and will continue
to do so in the next release, NIO.2 (AIO). Because all these APIs are
different from each other in design and performance characteristics, you
are often forced to determine which API your application will depend on
before you even begin the implementation phase.
</para>
<para>
For instance, you might want to start with OIO because the number of
clients you are going to serve will be very small and writing a socket
server using OIO is much easier than using NIO. However, you are going
to be in trouble when your business grows up exponentially and your server
starts to serve tens of thousand clients simultaneously. You could
start with NIO, but it might take much longer time to implement due to
the complexity of the NIO Selector API, hindering rapid development.
to be in trouble when your business grows exponentially and your server
needs to serve tens of thousands of clients simultaneously. You could
start with NIO, but doing so may hinder rapid development by greatly
increasing development time due to the complexity of the NIO Selector
API.
</para>
<para>
Netty has a universal asynchronous I/O interface called &Channel;, which
abstracts away all operations required to point-to-point communication.
Netty has a universal asynchronous I/O interface called a &Channel;, which
abstracts away all operations required for point-to-point communication.
That is, once you wrote your application on one Netty transport, your
application can run on other Netty transports. Netty provides a number
of essential transports via one universal API:
@ -144,30 +145,29 @@
</para>
</listitem>
</itemizedlist>
Switching from one transport to the other usually takes just a couple
Switching from one transport to another usually takes just a couple
lines of changes such as choosing a different &ChannelFactory;
implementation.
</para>
<para>
Also, you are even able to take advantage of a new transport which is
not written yet, serial port communication transport for instance, again
Also, you are even able to take advantage of new transports which aren't
yet written (such as serial port communication transport), again
by replacing just a couple lines of constructor calls. Moreover, you can
write your own transport by extending the core API because it is highly
extensible.
write your own transport by extending the core API.
</para>
</section>
<section>
<title>Event Model based on the Interceptor Chain Pattern</title>
<para>
Well-defined and extensible event model is a must for an event-driven
application. Netty does have a well-defined event model focused on I/O.
It also allows you to implement your own event type without breaking the
existing code at all because each event type is distinguished from
each other by strict type hierarchy. This is another differentiator
against other frameworks. Many NIO frameworks have no or very limited
notion of event model; they often break the existing code when you try
to add a new custom event type, or just do not allow extension.
A well-defined and extensible event model is a must for an event-driven
application. Netty has a well-defined event model focused on I/O. It
also allows you to implement your own event type without breaking the
existing code because each event type is distinguished from another by
a strict type hierarchy. This is another differentiator against other
frameworks. Many NIO frameworks have no or a very limited notion of an
event model. If they offer extension at all, they often break the
existing code when you try to add custom event types
</para>
<para>
A &ChannelEvent; is handled by a list of &ChannelHandler;s in a
@ -175,7 +175,7 @@
<ulink url="http://java.sun.com/blueprints/corej2eepatterns/Patterns/InterceptingFilter.html">Intercepting Filter</ulink>
pattern to give a user full control over how an event is handled and how
the handlers in the pipeline interact with each other. For example,
you can define what to do when a data is read from a socket:
you can define what to do when data is read from a socket:
</para>
<programlisting>public class MyReadHandler implements &SimpleChannelHandler; {
public void messageReceived(&ChannelHandlerContext; ctx, &MessageEvent; evt) {
@ -188,8 +188,7 @@
}
}</programlisting>
<para>
You can also define what to do when other handler requested a write
operation:
You can also define what to do when a handler receives a write request:
</para>
<programlisting>public class MyWriteHandler implements &SimpleChannelHandler; {
public void writeRequested(&ChannelHandlerContext; ctx, &MessageEvent; evt) {
@ -202,7 +201,7 @@
}
}</programlisting>
<para>
For more information about the event model, please refer to the
For more information on the event model, please refer to the
API documentation of &ChannelEvent; and &ChannelPipeline;.
</para>
</section>
@ -212,29 +211,28 @@
<para>
On top of the core components mentioned above, that already enable the
implementation of all types of network applications, Netty provides a set
of advanced features to accelerate the development pace even more.
of advanced features to accelerate the page of development even more.
</para>
<section>
<title>Codec framework</title>
<para>
As demonstrated in <xref linkend="start.pojo"/>, it is always a good
idea to separate a protocol codec from a business logic. However, there
idea to separate a protocol codec from business logic. However, there
are some complications when implementing this idea from scratch. You
have to deal with the fragmentation of messages. Some protocols are
multi-layered (i.e. built on top of other lower level protocol). Some
multi-layered (i.e. built on top of other lower level protocols). Some
are too complicated to be implemented in a single state machine.
</para>
<para>
Consequently, a good network application framework should provide an
extensible, reusable, unit-testable, and multi-layered codec framework
that generates maintainable user codec.
that generates maintainable user codecs.
</para>
<para>
Netty provides a number of basic and advanced codecs built on top of
its core to address most issues you will encounter when you write a
protocol codec regardless if it is simple or not, binary or text -
simply whatever.
Netty provides a number of basic and advanced codecs to address most
issues you will encounter when you write a protocol codec regardless
if it is simple or not, binary or text - simply whatever.
</para>
</section>
@ -245,16 +243,16 @@
You can't simply wrap a stream to encrypt or decrypt data but you have
to use <classname>javax.net.ssl.SSLEngine</classname>.
<classname>SSLEngine</classname> is a state machine which is as complex
as SSL is. You have to manage all possible states such as cipher suite
and encryption key negotiation (or re-negotiation), certificate
exchange and validation. Moreover, <classname>SSLEngine</classname> is
not even completely thread-safe unlike usual expectation.
as SSL itself. You have to manage all possible states such as cipher
suite and encryption key negotiation (or re-negotiation), certificate
exchange, and validation. Moreover, <classname>SSLEngine</classname> is
not even completely thread-safe, as one would expect.
</para>
<para>
In Netty, &SslHandler; takes care of all the gory details and pitfalls
of <classname>SSLEngine</classname>. All you need to do is to configure
and insert the &SslHandler; to your &ChannelPipeline;. It also allows
you to implement advanced features like
the &SslHandler; and insert it into your &ChannelPipeline;. It also
allows you to implement advanced features like
<ulink url="http://en.wikipedia.org/wiki/Starttls">StartTLS</ulink>
very easily.
</para>
@ -269,13 +267,13 @@
</para>
<para>
Netty's HTTP support is very different from the existing HTTP libraries.
It gives you complete control over how HTTP messages are exchanged in a
low level. Because it is basically the combination of HTTP codec and
HTTP message classes, there is no restriction such as enforced thread
It gives you complete control over how HTTP messages are exchanged at a
low level. Because it is basically the combination of an HTTP codec and
HTTP message classes, there is no restriction such as an enforced thread
model. That is, you can write your own HTTP client or server that works
exactly the way you want. You have full control over thread model,
connection life cycle, chunked encoding, and as much as what HTTP
specification allows you to do.
exactly the way you want. You have full control over everything that's
in the HTTP specification, including the thread model, connection life
cycle, and chunked encoding.
</para>
<para>
Thanks to its highly customizable nature, you can write a very efficient
@ -291,18 +289,18 @@
<listitem>
<para>
Media streaming server that needs to keep the connection open
until the whole media is streamed (e.g. 2 hours of movie)
until the whole media is streamed (e.g. 2 hours of video)
</para>
</listitem>
<listitem>
<para>
File server that allows the upload of large files without memory
pressure (e.g. uploading 1GB per request)
File server that allows the uploading of large files without
memory pressure (e.g. uploading 1GB per request)
</para>
</listitem>
<listitem>
<para>
Scalable mash-up client that connects to tens of thousand 3rd
Scalable mash-up client that connects to tens of thousands of 3rd
party web services asynchronously
</para>
</listitem>
@ -315,10 +313,11 @@
<para>
<ulink url="http://code.google.com/apis/protocolbuffers/docs/overview.html">Google Protocol Buffers</ulink>
are an ideal solution for the rapid implementation of a highly efficient
binary protocol that evolves over time. With &ProtobufEncoder; and
&ProtobufDecoder;, you can turn the message classes generated by Google
Protocol Buffers Compiler (protoc) into Netty codec. Please take a look
into the <ulink url="&XRef;example/localtime/package-summary.html">'LocalTime' example</ulink>
binary protocols that evolve over time. With &ProtobufEncoder; and
&ProtobufDecoder;, you can turn the message classes generated by the
Google Protocol Buffers Compiler (protoc) into Netty codec. Please take
a look into the
<ulink url="&XRef;example/localtime/package-summary.html">'LocalTime' example</ulink>
that shows how easily you can create a high-performing binary protocol
client and server from the
<ulink url="http://anonsvn.jboss.org/repos/netty/trunk/src/main/java/org/jboss/netty/example/localtime/LocalTimeProtocol.proto">sample protocol definition</ulink>.
@ -330,18 +329,18 @@
<title>Summary</title>
<para>
In this chapter, we reviewed the overall architecture of Netty from the
feature-wise standpoint. Netty has simple yet powerful architecture.
feature standpoint. Netty has a simple, yet powerful architecture.
It is composed of three components - buffer, channel, and event model -
and all advanced features are built on top of the three core components.
Once you understood how these three work together, it should not be
difficult to understand more advanced features which were covered briefly
in this chapter.
difficult to understand the more advanced features which were covered
briefly in this chapter.
</para>
<para>
You might still have an unanswered question about what the overall
architecture looks exactly like and how each feature work together.
If so, it is a good idea to <ulink url="&Community;">talk to us</ulink>
to improve this guide.
You might still have unanswered questions about what the overall
architecture looks like exactly and how each of the features work
together. If so, it is a good idea to
<ulink url="&Community;">talk to us</ulink> to improve this guide.
</para>
</section>
</chapter>

View File

@ -337,7 +337,7 @@ public class TimeServerHandler extends &SimpleChannelHandler; {
&Channel; ch = e.getChannel();
&ChannelBuffer; time = &ChannelBuffers;.buffer(4);<co id="example.time.co2"/>
time.writeInt(System.currentTimeMillis() / 1000);
time.writeInt((int) (System.currentTimeMillis() / 1000));
&ChannelFuture; f = ch.write(time);<co id="example.time.co3"/>
@ -692,35 +692,41 @@ public class TimeClientHandler extends &SimpleChannelHandler; {
</para>
<programlisting>package org.jboss.netty.example.time;
public class TimeDecoder extends &FrameDecoder; {
public class TimeDecoder extends &FrameDecoder;<co id="example.time4.co1"/> {
@Override
protected Object decode(
&ChannelHandlerContext; ctx, &Channel; channel, &ChannelBuffer; buffer)<co id="example.time4.co1"/> {
&ChannelHandlerContext; ctx, &Channel; channel, &ChannelBuffer; buffer)<co id="example.time4.co2"/> {
if (buffer.readableBytes() &lt; 4) {
return null; <co id="example.time4.co2"/>
return null; <co id="example.time4.co3"/>
}
return buffer.readBytes(4);<co id="example.time4.co3"/>
return buffer.readBytes(4);<co id="example.time4.co4"/>
}
}</programlisting>
<calloutlist>
<callout arearefs="example.time4.co1">
<para>
&FrameDecoder; is an implementation of &ChannelHandler; which
makes it easy to which deals with the fragmentation issue.
</para>
</callout>
<callout arearefs="example.time4.co2">
<para>
&FrameDecoder; calls <methodname>decode</methodname> method with
an internally maintained cumulative buffer whenever new data is
received.
</para>
</callout>
<callout arearefs="example.time4.co2">
<callout arearefs="example.time4.co3">
<para>
If <literal>null</literal> is returned, it means there's not
enough data yet. &FrameDecoder; will call again when there is a
sufficient amount of data.
</para>
</callout>
<callout arearefs="example.time4.co3">
<callout arearefs="example.time4.co4">
<para>
If non-<literal>null</literal> is returned, it means the
<methodname>decode</methodname> method has decoded a message
@ -873,10 +879,11 @@ public void channelConnected(&ChannelHandlerContext; ctx, &ChannelStateEvent; e)
f.addListener(&ChannelFutureListener;.CLOSE);
}</programlisting>
<para>
Now, the only missing piece is the &ChannelHandler; which translates a
<classname>UnixTime</classname> back into a &ChannelBuffer;. It's much
simpler than writing a decoder because there's no need to deal with
packet fragmentation and assembly when encoding a message.
Now, the only missing piece is an encoder, which is an implementation of
&ChannelHandler; that translates a <classname>UnixTime</classname> back
into a &ChannelBuffer;. It's much simpler than writing a decoder because
there's no need to deal with packet fragmentation and assembly when
encoding a message.
</para>
<programlisting>package org.jboss.netty.example.time;

View File

@ -43,7 +43,7 @@ import org.jboss.netty.util.ExternalResourceReleasable;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2371 $, $Date: 2010-10-19 15:00:42 +0900 (Tue, 19 Oct 2010) $
*
* @apiviz.uses org.jboss.netty.channel.ChannelFactory
*/

View File

@ -106,7 +106,7 @@ import org.jboss.netty.channel.Channels;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2337 $, $Date: 2010-07-07 13:32:10 +0900 (Wed, 07 Jul 2010) $
*
* @apiviz.landmark
*/
@ -182,7 +182,7 @@ public class ClientBootstrap extends Bootstrap {
*/
public ChannelFuture connect(SocketAddress remoteAddress) {
if (remoteAddress == null) {
throw new NullPointerException("remotedAddress");
throw new NullPointerException("remoteAddress");
}
SocketAddress localAddress = (SocketAddress) getOption("localAddress");
return connect(remoteAddress, localAddress);

View File

@ -115,7 +115,7 @@ import org.jboss.netty.channel.Channels;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2338 $, $Date: 2010-07-07 13:33:47 +0900 (Wed, 07 Jul 2010) $
*
* @apiviz.landmark
*/

View File

@ -156,7 +156,7 @@ import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2344 $, $Date: 2010-07-07 16:55:37 +0900 (Wed, 07 Jul 2010) $
*
* @apiviz.landmark
*/

View File

@ -22,6 +22,7 @@ import java.nio.ByteBuffer;
import java.nio.channels.GatheringByteChannel;
import java.nio.channels.ScatteringByteChannel;
import java.nio.charset.Charset;
import java.util.NoSuchElementException;
/**
@ -30,7 +31,7 @@ import java.nio.charset.Charset;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2211 $, $Date: 2010-03-04 15:34:00 +0900 (Thu, 04 Mar 2010) $
*/
public abstract class AbstractChannelBuffer implements ChannelBuffer {
@ -308,12 +309,30 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
return buf;
}
@Deprecated
public ChannelBuffer readBytes(ChannelBufferIndexFinder endIndexFinder) {
int endIndex = indexOf(readerIndex, writerIndex, endIndexFinder);
if (endIndex < 0) {
throw new NoSuchElementException();
}
return readBytes(endIndex - readerIndex);
}
public ChannelBuffer readSlice(int length) {
ChannelBuffer slice = slice(readerIndex, length);
readerIndex += length;
return slice;
}
@Deprecated
public ChannelBuffer readSlice(ChannelBufferIndexFinder endIndexFinder) {
int endIndex = indexOf(readerIndex, writerIndex, endIndexFinder);
if (endIndex < 0) {
throw new NoSuchElementException();
}
return readSlice(endIndex - readerIndex);
}
public void readBytes(byte[] dst, int dstIndex, int length) {
checkReadableBytes(length);
getBytes(readerIndex, dst, dstIndex, length);
@ -371,6 +390,17 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
readerIndex = newReaderIndex;
}
@Deprecated
public int skipBytes(ChannelBufferIndexFinder firstIndexFinder) {
int oldReaderIndex = readerIndex;
int newReaderIndex = indexOf(oldReaderIndex, writerIndex, firstIndexFinder);
if (newReaderIndex < 0) {
throw new NoSuchElementException();
}
readerIndex(newReaderIndex);
return newReaderIndex - oldReaderIndex;
}
public void writeByte(int value) {
setByte(writerIndex ++, value);
}
@ -517,6 +547,37 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
toByteBuffer(index, length), charset);
}
@Deprecated
public String toString(int index, int length, String charsetName,
ChannelBufferIndexFinder terminatorFinder) {
if (terminatorFinder == null) {
return toString(index, length, charsetName);
}
int terminatorIndex = indexOf(index, index + length, terminatorFinder);
if (terminatorIndex < 0) {
return toString(index, length, charsetName);
}
return toString(index, terminatorIndex - index, charsetName);
}
@Deprecated
public String toString(int index, int length, String charsetName) {
return toString(index, length, Charset.forName(charsetName));
}
@Deprecated
public String toString(String charsetName,
ChannelBufferIndexFinder terminatorFinder) {
return toString(readerIndex, readableBytes(), charsetName, terminatorFinder);
}
@Deprecated
public String toString(String charsetName) {
return toString(Charset.forName(charsetName));
}
public int indexOf(int fromIndex, int toIndex, byte value) {
return ChannelBuffers.indexOf(this, fromIndex, toIndex, value);
}

View File

@ -23,7 +23,7 @@ import java.nio.ByteOrder;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
public abstract class AbstractChannelBufferFactory implements ChannelBufferFactory {

View File

@ -26,7 +26,7 @@ import java.nio.ByteOrder;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2206 $, $Date: 2010-03-03 14:35:01 +0900 (Wed, 03 Mar 2010) $
*/
public class BigEndianHeapChannelBuffer extends HeapChannelBuffer {

View File

@ -32,7 +32,7 @@ import java.nio.channels.ScatteringByteChannel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2309 $, $Date: 2010-06-21 16:00:03 +0900 (Mon, 21 Jun 2010) $
*
*/
public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {

View File

@ -48,7 +48,7 @@ import java.nio.charset.UnsupportedCharsetException;
* <pre>
* {@link ChannelBuffer} buffer = ...;
* for (int i = 0; i &lt; buffer.capacity(); i ++</strong>) {
* byte b = array.getByte(i);
* byte b = buffer.getByte(i);
* System.out.println((char) b);
* }
* </pre>
@ -220,7 +220,7 @@ import java.nio.charset.UnsupportedCharsetException;
*
* <h4>Strings</h4>
*
* Various {@link #toString(Charset)} methods convert a {@link ChannelBuffer}
* Various {@link #toString(String)} methods convert a {@link ChannelBuffer}
* into a {@link String}. Please note that {@link #toString()} is not a
* conversion method.
*
@ -232,7 +232,7 @@ import java.nio.charset.UnsupportedCharsetException;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2268 $, $Date: 2010-05-06 16:33:26 +0900 (Thu, 06 May 2010) $
*
* @apiviz.landmark
*/
@ -1094,6 +1094,12 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
*/
ChannelBuffer readBytes(int length);
/**
* @deprecated Use {@link #bytesBefore(ChannelBufferIndexFinder)} and {@link #readBytes(int)} instead.
*/
@Deprecated
ChannelBuffer readBytes(ChannelBufferIndexFinder indexFinder);
/**
* Returns a new slice of this buffer's sub-region starting at the current
* {@code readerIndex} and increases the {@code readerIndex} by the size
@ -1108,6 +1114,12 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
*/
ChannelBuffer readSlice(int length);
/**
* @deprecated Use {@link #bytesBefore(ChannelBufferIndexFinder)} and {@link #readSlice(int)} instead.
*/
@Deprecated
ChannelBuffer readSlice(ChannelBufferIndexFinder indexFinder);
/**
* Transfers this buffer's data to the specified destination starting at
* the current {@code readerIndex} until the destination becomes
@ -1229,6 +1241,12 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
*/
void skipBytes(int length);
/**
* @deprecated Use {@link #bytesBefore(ChannelBufferIndexFinder)} and {@link #skipBytes(int)} instead.
*/
@Deprecated
int skipBytes(ChannelBufferIndexFinder indexFinder);
/**
* Sets the specified byte at the current {@code writerIndex}
* and increases the {@code writerIndex} by {@code 1} in this buffer.
@ -1699,6 +1717,33 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
*/
String toString(int index, int length, Charset charset);
/**
* @deprecated Use {@link #toString(Charset)} instead.
*/
@Deprecated
String toString(String charsetName);
/**
* @deprecated Use {@link #bytesBefore(ChannelBufferIndexFinder)} and {@link #toString(int, int, Charset)} instead.
*/
@Deprecated
String toString(
String charsetName, ChannelBufferIndexFinder terminatorFinder);
/**
* @deprecated Use {@link #bytesBefore(int, int, ChannelBufferIndexFinder)} and {@link #toString(int, int, Charset)} instead.
*/
@Deprecated
String toString(int index, int length, String charsetName);
/**
* @deprecated Use {@link #bytesBefore(int, int, ChannelBufferIndexFinder)} and {@link #toString(int, int, Charset)} instead.
*/
@Deprecated
String toString(
int index, int length, String charsetName,
ChannelBufferIndexFinder terminatorFinder);
/**
* Returns a hash code which was calculated from the content of this
* buffer. If there's a byte array which is

View File

@ -23,7 +23,7 @@ import java.nio.ByteOrder;
*
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
public interface ChannelBufferFactory {

View File

@ -28,7 +28,7 @@ package org.jboss.netty.buffer;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
* @apiviz.uses org.jboss.netty.buffer.ChannelBuffer
*/

View File

@ -35,7 +35,7 @@ import java.io.InputStream;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
* @see ChannelBufferOutputStream
* @apiviz.uses org.jboss.netty.buffer.ChannelBuffer

View File

@ -34,7 +34,7 @@ import java.io.OutputStream;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
* @see ChannelBufferInputStream
* @apiviz.uses org.jboss.netty.buffer.ChannelBuffer

View File

@ -85,7 +85,7 @@ import org.jboss.netty.util.CharsetUtil;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2269 $, $Date: 2010-05-06 16:37:27 +0900 (Thu, 06 May 2010) $
*
* @apiviz.landmark
* @apiviz.has org.jboss.netty.buffer.ChannelBuffer oneway - - creates
@ -313,7 +313,7 @@ public class ChannelBuffers {
return EMPTY_BUFFER;
}
if (buffer.hasArray()) {
return wrappedBuffer(buffer.order(), buffer.array(), buffer.arrayOffset(),buffer.remaining());
return wrappedBuffer(buffer.order(), buffer.array(), buffer.arrayOffset() + buffer.position(),buffer.remaining());
} else {
return new ByteBufferBackedChannelBuffer(buffer);
}
@ -811,6 +811,22 @@ public class ChannelBuffers {
return result;
}
/**
* @deprecated Use {@link #copiedBuffer(CharSequence, Charset)} instead.
*/
@Deprecated
public static ChannelBuffer copiedBuffer(String string, String charsetName) {
return copiedBuffer(string, Charset.forName(charsetName));
}
/**
* @deprecated Use {@link #copiedBuffer(ByteOrder, CharSequence, Charset)} instead.
*/
@Deprecated
public static ChannelBuffer copiedBuffer(ByteOrder endianness, String string, String charsetName) {
return copiedBuffer(endianness, string, Charset.forName(charsetName));
}
/**
* Creates a read-only buffer which disallows any modification operations
* on the specified {@code buffer}. The new buffer has the same
@ -979,8 +995,8 @@ public class ChannelBuffers {
}
for (int i = byteCount; i > 0; i --) {
byte va = bufferA.getByte(aIndex);
byte vb = bufferB.getByte(bIndex);
short va = bufferA.getUnsignedByte(aIndex);
short vb = bufferB.getUnsignedByte(bIndex);
if (va > vb) {
return 1;
} else if (va < vb) {

View File

@ -36,7 +36,7 @@ import java.util.List;
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
* @author Frederic Bregier (fredbregier@free.fr)
*
* @version $Rev$, $Date$
* @version $Rev: 2206 $, $Date: 2010-03-03 14:35:01 +0900 (Wed, 03 Mar 2010) $
*
*/
public class CompositeChannelBuffer extends AbstractChannelBuffer {

View File

@ -32,7 +32,7 @@ import java.nio.ByteOrder;
*
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
* @version $Rev$, $Date$
* @version $Rev: 2293 $, $Date: 2010-06-01 17:38:51 +0900 (Tue, 01 Jun 2010) $
*/
public class DirectChannelBufferFactory extends AbstractChannelBufferFactory {

View File

@ -32,7 +32,7 @@ import java.nio.channels.ScatteringByteChannel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2206 $, $Date: 2010-03-03 14:35:01 +0900 (Wed, 03 Mar 2010) $
*
*/
public class DuplicatedChannelBuffer extends AbstractChannelBuffer implements WrappedChannelBuffer {

View File

@ -32,7 +32,7 @@ import java.nio.channels.ScatteringByteChannel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2206M $, $Date: 2010-11-09 15:04:10 +0900 (Tue, 09 Nov 2010) $
*
*/
public class DynamicChannelBuffer extends AbstractChannelBuffer {

View File

@ -29,7 +29,7 @@ import java.nio.channels.ScatteringByteChannel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2309 $, $Date: 2010-06-21 16:00:03 +0900 (Mon, 21 Jun 2010) $
*/
public abstract class HeapChannelBuffer extends AbstractChannelBuffer {

View File

@ -26,7 +26,7 @@ import java.nio.ByteOrder;
*
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
* @version $Rev$, $Date$
* @version $Rev: 2197 $, $Date: 2010-02-23 09:43:15 +0900 (Tue, 23 Feb 2010) $
*/
public class HeapChannelBufferFactory extends AbstractChannelBufferFactory {

View File

@ -26,7 +26,7 @@ import java.nio.ByteOrder;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2206 $, $Date: 2010-03-03 14:35:01 +0900 (Wed, 03 Mar 2010) $
*/
public class LittleEndianHeapChannelBuffer extends HeapChannelBuffer {

View File

@ -32,7 +32,7 @@ import java.nio.channels.ScatteringByteChannel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2206 $, $Date: 2010-03-03 14:35:01 +0900 (Wed, 03 Mar 2010) $
*
*/
public class ReadOnlyChannelBuffer extends AbstractChannelBuffer implements WrappedChannelBuffer {

View File

@ -33,7 +33,7 @@ import java.nio.channels.ScatteringByteChannel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2206 $, $Date: 2010-03-03 14:35:01 +0900 (Wed, 03 Mar 2010) $
*
*/
public class SlicedChannelBuffer extends AbstractChannelBuffer implements WrappedChannelBuffer {

View File

@ -33,7 +33,7 @@ import java.nio.channels.ScatteringByteChannel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2206 $, $Date: 2010-03-03 14:35:01 +0900 (Wed, 03 Mar 2010) $
*
*/
public class TruncatedChannelBuffer extends AbstractChannelBuffer implements WrappedChannelBuffer {

View File

@ -22,7 +22,7 @@ package org.jboss.netty.buffer;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
*/
public interface WrappedChannelBuffer extends ChannelBuffer {

View File

@ -26,13 +26,12 @@ import org.jboss.netty.util.internal.ConcurrentHashMap;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2339 $, $Date: 2010-07-07 13:36:25 +0900 (Wed, 07 Jul 2010) $
*
*/
public abstract class AbstractChannel implements Channel {
static final ConcurrentMap<Integer, Channel> allChannels = new ConcurrentHashMap<Integer, Channel>();
private static final IdDeallocator ID_DEALLOCATOR = new IdDeallocator();
private static Integer allocateId(Channel channel) {
Integer id = Integer.valueOf(System.identityHashCode(channel));
@ -49,16 +48,6 @@ public abstract class AbstractChannel implements Channel {
}
}
private static final class IdDeallocator implements ChannelFutureListener {
IdDeallocator() {
super();
}
public void operationComplete(ChannelFuture future) throws Exception {
allChannels.remove(future.getChannel().getId());
}
}
private final Integer id;
private final Channel parent;
private final ChannelFactory factory;
@ -93,7 +82,6 @@ public abstract class AbstractChannel implements Channel {
this.pipeline = pipeline;
id = allocateId(this);
closeFuture.addListener(ID_DEALLOCATOR);
pipeline.attach(this, sink);
}
@ -193,6 +181,10 @@ public abstract class AbstractChannel implements Channel {
* closed yet
*/
protected boolean setClosed() {
// Deallocate the current channel's ID from allChannels so that other
// new channels can use it.
allChannels.remove(id);
return closeFuture.setClosed();
}

View File

@ -23,7 +23,7 @@ import static org.jboss.netty.channel.Channels.*;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
public abstract class AbstractChannelSink implements ChannelSink {

View File

@ -33,7 +33,7 @@ import java.net.SocketAddress;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
*/
public abstract class AbstractServerChannel extends AbstractChannel implements ServerChannel {

View File

@ -31,7 +31,7 @@ import java.util.List;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
*/
public class AdaptiveReceiveBufferSizePredictor implements

View File

@ -23,7 +23,7 @@ package org.jboss.netty.channel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
public class AdaptiveReceiveBufferSizePredictorFactory implements
ReceiveBufferSizePredictorFactory {

View File

@ -103,7 +103,7 @@ import org.jboss.netty.channel.socket.nio.NioSocketChannelConfig;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2244 $, $Date: 2010-04-16 14:07:37 +0900 (Fri, 16 Apr 2010) $
*
* @apiviz.landmark
* @apiviz.composedOf org.jboss.netty.channel.ChannelConfig

View File

@ -63,7 +63,7 @@ import org.jboss.netty.channel.socket.nio.NioSocketChannelConfig;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2122 $, $Date: 2010-02-02 11:00:04 +0900 (Tue, 02 Feb 2010) $
*
* @apiviz.has org.jboss.netty.channel.ChannelPipelineFactory
* @apiviz.composedOf org.jboss.netty.channel.ReceiveBufferSizePredictor

View File

@ -71,7 +71,7 @@ package org.jboss.netty.channel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2122 $, $Date: 2010-02-02 11:00:04 +0900 (Tue, 02 Feb 2010) $
*
* @apiviz.exclude ^org\.jboss\.netty\.handler\..*$
*/

View File

@ -71,6 +71,7 @@ import org.jboss.netty.channel.socket.ServerSocketChannel;
* <td>{@code "channelOpen"}</td>
* <td>{@link ChannelStateEvent}<br/>(state = {@link ChannelState#OPEN OPEN}, value = {@code true})</td>
* <td>a {@link Channel} is open, but not bound nor connected</td>
* <td><strong>Be aware that this event is fired from within the Boss-Thread so you should not execute any heavy operation in there as it will block the dispatching to other workers!</strong></td>
* </tr>
* <tr>
* <td>{@code "channelClosed"}</td>
@ -80,7 +81,8 @@ import org.jboss.netty.channel.socket.ServerSocketChannel;
* <tr>
* <td>{@code "channelBound"}</td>
* <td>{@link ChannelStateEvent}<br/>(state = {@link ChannelState#BOUND BOUND}, value = {@link SocketAddress})</td>
* <td>a {@link Channel} is open and bound to a local address, but not connected</td>
* <td>a {@link Channel} is open and bound to a local address, but not connected.</td>
* <td><strong>Be aware that this event is fired from within the Boss-Thread so you should not execute any heavy operation in there as it will block the dispatching to other workers!</strong></td>
* </tr>
* <tr>
* <td>{@code "channelUnbound"}</td>
@ -91,6 +93,7 @@ import org.jboss.netty.channel.socket.ServerSocketChannel;
* <td>{@code "channelConnected"}</td>
* <td>{@link ChannelStateEvent}<br/>(state = {@link ChannelState#CONNECTED CONNECTED}, value = {@link SocketAddress})</td>
* <td>a {@link Channel} is open, bound to a local address, and connected to a remote address</td>
* <td><strong>Be aware that this event is fired from within the Boss-Thread so you should not execute any heavy operation in there as it will block the dispatching to other workers!</strong></td>
* </tr>
* <tr>
* <td>{@code "writeComplete"}</td>
@ -179,7 +182,7 @@ import org.jboss.netty.channel.socket.ServerSocketChannel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
* @apiviz.landmark
* @apiviz.composedOf org.jboss.netty.channel.ChannelFuture

View File

@ -21,7 +21,7 @@ package org.jboss.netty.channel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
* @apiviz.hidden
*/

View File

@ -50,7 +50,7 @@ import org.jboss.netty.util.ExternalResourceReleasable;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
* @apiviz.landmark
* @apiviz.has org.jboss.netty.channel.Channel oneway - - creates

View File

@ -167,7 +167,7 @@ import org.jboss.netty.handler.execution.ExecutionHandler;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2192 $, $Date: 2010-02-19 18:58:38 +0900 (Fri, 19 Feb 2010) $
*
* @apiviz.landmark
* @apiviz.owns org.jboss.netty.channel.ChannelFutureListener - - notifies

View File

@ -33,7 +33,7 @@ import java.util.EventListener;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2185 $, $Date: 2010-02-19 14:13:48 +0900 (Fri, 19 Feb 2010) $
*/
public interface ChannelFutureListener extends EventListener {

View File

@ -206,7 +206,7 @@ import org.jboss.netty.channel.group.ChannelGroup;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2152 $, $Date: 2010-02-17 17:22:45 +0900 (Wed, 17 Feb 2010) $
*
* @apiviz.landmark
* @apiviz.exclude ^org\.jboss\.netty\.handler\..*$
@ -227,7 +227,7 @@ public interface ChannelHandler {
*
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
* @version $Rev$, $Date$
* @version $Rev: 2152 $, $Date: 2010-02-17 17:22:45 +0900 (Wed, 17 Feb 2010) $
*/
@Inherited
@Documented

View File

@ -51,7 +51,7 @@ package org.jboss.netty.channel;
* public void login(String username, password) {
* {@link Channels}.write(
* <b>this.ctx</b>,
* {@link Channels}.succeededFuture(<b>this.ctx</t>.getChannel()),
* {@link Channels}.succeededFuture(<b>this.ctx</t>.getChannel()</b>),
* new LoginMessage(username, password));
* }
* ...
@ -120,7 +120,7 @@ package org.jboss.netty.channel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2157 $, $Date: 2010-02-17 17:37:38 +0900 (Wed, 17 Feb 2010) $
*
* @apiviz.owns org.jboss.netty.channel.ChannelHandler
*/

View File

@ -23,7 +23,7 @@ package org.jboss.netty.channel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
* @apiviz.hidden
*/

View File

@ -31,7 +31,7 @@ import org.jboss.netty.util.internal.ConcurrentIdentityWeakKeyHashMap;
*
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
* @apiviz.stereotype utility
*/
@ -40,18 +40,36 @@ public class ChannelLocal<T> {
private final ConcurrentMap<Channel, T> map =
new ConcurrentIdentityWeakKeyHashMap<Channel, T>();
private final ChannelFutureListener remover = new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
remove(future.getChannel());
}
};
private final boolean removeOnClose;
/**
* Creates a {@link Channel} local variable.
* Creates a {@link Channel} local variable by calling {@link #ChannelLocal(boolean)} with <code>false</code> as parameter
*/
public ChannelLocal() {
super();
this(false);
}
/**
* Creates a {@link Channel} local variable.
*
* @param removeOnClose if <code>true</code> the {@link ChannelLocal} will remove a {@link Channel} from it own once the {@link Channel} was closed.
*/
public ChannelLocal(boolean removeOnClose) {
this.removeOnClose = removeOnClose;
}
/**
* Returns the initial value of the variable. By default, it returns
* {@code null}. Override it to change the initial value.
*/
protected T initialValue(@SuppressWarnings("unused") Channel channel) {
protected T initialValue(Channel channel) {
return null;
}
@ -88,7 +106,11 @@ public class ChannelLocal<T> {
if (channel == null) {
throw new NullPointerException("channel");
}
return map.put(channel, value);
T old = map.put(channel, value);
if (removeOnClose) {
channel.getCloseFuture().addListener(remover);
}
return old;
}
}
@ -105,19 +127,36 @@ public class ChannelLocal<T> {
if (channel == null) {
throw new NullPointerException("channel");
}
return map.putIfAbsent(channel, value);
T mapping = map.putIfAbsent(channel, value);
if (removeOnClose && mapping == null) {
channel.getCloseFuture().addListener(remover);
}
return mapping;
}
}
/**
* Removes the variable.
* Removes the variable and returns the removed value. If no value was set,
* this method returns the return value of {@link #initialValue(Channel)},
* which is {@code null} by default.
*
* @return the removed value. {@code null} if no value was set.
* @return the removed value.
* {@linkplain #initialValue(Channel) an initial value} (by default
* {@code null}) if no value was set.
*/
public T remove(Channel channel) {
if (channel == null) {
throw new NullPointerException("channel");
}
return map.remove(channel);
T removed = map.remove(channel);
if (removed == null) {
return initialValue(channel);
} else {
if (removeOnClose) {
channel.getCloseFuture().removeListener(remover);
}
return removed;
}
}
}

View File

@ -17,6 +17,7 @@ package org.jboss.netty.channel;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
@ -203,7 +204,7 @@ import org.jboss.netty.handler.ssl.SslHandler;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2153 $, $Date: 2010-02-17 17:24:25 +0900 (Wed, 17 Feb 2010) $
*
* @apiviz.landmark
* @apiviz.composedOf org.jboss.netty.channel.ChannelHandlerContext
@ -488,6 +489,11 @@ public interface ChannelPipeline {
*/
boolean isAttached();
/**
* Returns the {@link List} of the handler names.
*/
List<String> getNames();
/**
* Converts this pipeline into an ordered {@link Map} whose keys are
* handler names and whose values are handlers.

View File

@ -0,0 +1,58 @@
/*
* Copyright 2009 Red Hat, Inc.
*
* Red Hat licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package org.jboss.netty.channel;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.jboss.netty.channel.ChannelHandler.Sharable;
/**
* @deprecated Use the {@link Sharable} annotation instead.
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev: 2124 $, $Date: 2010-02-02 11:13:06 +0900 (Tue, 02 Feb 2010) $
*
* @apiviz.exclude
*/
@Inherited
@Documented
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Deprecated
public @interface ChannelPipelineCoverage {
/**
* {@code "all"}
*/
public static final String ALL = "all";
/**
* {@code "one"}
*/
public static final String ONE = "one";
/**
* The value of this annotation
*/
String value();
}

View File

@ -23,7 +23,7 @@ package org.jboss.netty.channel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
* @apiviz.hidden
*/

View File

@ -35,7 +35,7 @@ import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2145 $, $Date: 2010-02-09 12:56:29 +0900 (Tue, 09 Feb 2010) $
*
* @apiviz.has org.jboss.netty.channel.ChannelPipeline oneway - - creates
*/

View File

@ -26,7 +26,7 @@ package org.jboss.netty.channel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
* @apiviz.uses org.jboss.netty.channel.ChannelPipeline - - sends events upstream
*/

View File

@ -77,7 +77,7 @@ import java.net.SocketAddress;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
public enum ChannelState {
/**

View File

@ -27,7 +27,7 @@ package org.jboss.netty.channel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
* @apiviz.has org.jboss.netty.channel.ChannelState
*/

View File

@ -87,7 +87,7 @@ import org.jboss.netty.handler.execution.ExecutionHandler;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2122 $, $Date: 2010-02-02 11:00:04 +0900 (Tue, 02 Feb 2010) $
*
* @apiviz.exclude ^org\.jboss\.netty\.handler\..*$
*/

View File

@ -51,7 +51,7 @@ import org.jboss.netty.util.internal.ConversionUtil;
*
* @apiviz.landmark
*
* @version $Rev$, $Date$
* @version $Rev: 2210 $, $Date: 2010-03-04 08:11:39 +0900 (Thu, 04 Mar 2010) $
*/
public class Channels {

View File

@ -24,7 +24,7 @@ package org.jboss.netty.channel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
public interface ChildChannelStateEvent extends ChannelEvent {

View File

@ -27,7 +27,7 @@ import org.jboss.netty.logging.InternalLoggerFactory;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2192 $, $Date: 2010-02-19 18:58:38 +0900 (Fri, 19 Feb 2010) $
*/
public abstract class CompleteChannelFuture implements ChannelFuture {

View File

@ -29,7 +29,7 @@ import org.jboss.netty.util.internal.ConversionUtil;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
*/
public class DefaultChannelConfig implements ChannelConfig {

View File

@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;
import org.jboss.netty.util.internal.IoWorkerRunnable;
import org.jboss.netty.util.internal.DeadLockProofWorker;
/**
* The default {@link ChannelFuture} implementation. It is recommended to
@ -35,7 +35,7 @@ import org.jboss.netty.util.internal.IoWorkerRunnable;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2201 $, $Date: 2010-02-23 14:45:53 +0900 (Tue, 23 Feb 2010) $
*/
public class DefaultChannelFuture implements ChannelFuture {
@ -292,7 +292,7 @@ public class DefaultChannelFuture implements ChannelFuture {
}
private void checkDeadLock() {
if (isUseDeadLockChecker() && IoWorkerRunnable.IN_IO_THREAD.get()) {
if (isUseDeadLockChecker() && DeadLockProofWorker.PARENT.get() != null) {
throw new IllegalStateException(
"await*() in I/O thread causes a dead lock or " +
"sudden performance drop. Use addListener() instead or " +

View File

@ -15,8 +15,10 @@
*/
package org.jboss.netty.channel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
@ -31,7 +33,7 @@ import org.jboss.netty.logging.InternalLoggerFactory;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2119 $, $Date: 2010-02-01 20:46:09 +0900 (Mon, 01 Feb 2010) $
*
*/
public class DefaultChannelPipeline implements ChannelPipeline {
@ -487,6 +489,23 @@ public class DefaultChannelPipeline implements ChannelPipeline {
return null;
}
public List<String> getNames() {
List<String> list = new ArrayList<String>();
if (name2ctx.isEmpty()) {
return list;
}
DefaultChannelHandlerContext ctx = head;
for (;;) {
list.add(ctx.getName());
ctx = ctx.next;
if (ctx == null) {
break;
}
}
return list;
}
public Map<String, ChannelHandler> toMap() {
Map<String, ChannelHandler> map = new LinkedHashMap<String, ChannelHandler>();
if (name2ctx.isEmpty()) {
@ -564,9 +583,19 @@ public class DefaultChannelPipeline implements ChannelPipeline {
}
void sendDownstream(DefaultChannelHandlerContext ctx, ChannelEvent e) {
if (e instanceof UpstreamMessageEvent) {
throw new IllegalArgumentException("cannot send an upstream event to downstream");
}
try {
((ChannelDownstreamHandler) ctx.getHandler()).handleDownstream(ctx, e);
} catch (Throwable t) {
// Unlike an upstream event, a downstream event usually has an
// incomplete future which is supposed to be updated by ChannelSink.
// However, if an exception is raised before the event reaches at
// ChannelSink, the future is not going to be updated, so we update
// here.
e.getFuture().setFailure(t);
notifyHandlerException(e, t);
}
}
@ -636,7 +665,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
private void checkDuplicateName(String name) {
if (name2ctx.containsKey(name)) {
throw new IllegalArgumentException("Duplicate handler name.");
throw new IllegalArgumentException("Duplicate handler name: " + name);
}
}

View File

@ -23,7 +23,7 @@ import static org.jboss.netty.channel.Channels.*;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
*/
public class DefaultChildChannelStateEvent implements ChildChannelStateEvent {

View File

@ -25,7 +25,7 @@ import org.jboss.netty.util.internal.StackTraceSimplifier;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
*/
public class DefaultExceptionEvent implements ExceptionEvent {

View File

@ -14,11 +14,17 @@ public class DefaultFileRegion implements FileRegion {
private final FileChannel file;
private final long position;
private final long count;
private final boolean releaseAfterTransfer;
public DefaultFileRegion(FileChannel file, long position, long count) {
this(file, position, count, false);
}
public DefaultFileRegion(FileChannel file, long position, long count, boolean releaseAfterTransfer) {
this.file = file;
this.position = position;
this.count = count;
this.releaseAfterTransfer = releaseAfterTransfer;
}
public long getPosition() {
@ -29,6 +35,10 @@ public class DefaultFileRegion implements FileRegion {
return count;
}
public boolean releaseAfterTransfer() {
return releaseAfterTransfer;
}
public long transferTo(WritableByteChannel target, long position) throws IOException {
long count = this.count - position;
if (count < 0 || position < 0) {

View File

@ -28,7 +28,7 @@ import org.jboss.netty.channel.socket.ServerSocketChannelConfig;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
public class DefaultServerChannelConfig implements ChannelConfig {

View File

@ -23,7 +23,7 @@ import static org.jboss.netty.channel.Channels.*;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2210 $, $Date: 2010-03-04 08:11:39 +0900 (Thu, 04 Mar 2010) $
*/
public class DefaultWriteCompletionEvent implements WriteCompletionEvent {

View File

@ -21,7 +21,7 @@ package org.jboss.netty.channel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
*/
public class DownstreamChannelStateEvent implements ChannelStateEvent {

View File

@ -25,7 +25,7 @@ import org.jboss.netty.util.internal.StringUtil;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
*/
public class DownstreamMessageEvent implements MessageEvent {

View File

@ -25,7 +25,7 @@ package org.jboss.netty.channel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
public interface ExceptionEvent extends ChannelEvent {

View File

@ -23,7 +23,7 @@ package org.jboss.netty.channel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
public class FailedChannelFuture extends CompleteChannelFuture {

View File

@ -48,12 +48,21 @@ import org.jboss.netty.util.ExternalResourceReleasable;
* transfer, sending a file with {@link FileRegion} might fail or yield worse
* performance. For example, sending a large file doesn't work well in Windows.
*
* <h3>Not all transports support it</h3>
*
* Currently, the NIO transport is the only transport that supports {@link FileRegion}.
* Attempting to write a {@link FileRegion} to non-NIO {@link Channel} will trigger
* a {@link ClassCastException} or a similar exception.
*
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
public interface FileRegion extends ExternalResourceReleasable {
// FIXME Make sure all transports support writing a FileRegion
// Even if zero copy cannot be achieved, all transports should emulate it.
/**
* Returns the offset in the file where the transfer began.
*/

View File

@ -23,7 +23,7 @@ package org.jboss.netty.channel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
public class FixedReceiveBufferSizePredictor implements
ReceiveBufferSizePredictor {

View File

@ -23,7 +23,7 @@ package org.jboss.netty.channel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
public class FixedReceiveBufferSizePredictorFactory implements
ReceiveBufferSizePredictorFactory {

View File

@ -30,7 +30,7 @@ package org.jboss.netty.channel;
*
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
public interface LifeCycleAwareChannelHandler extends ChannelHandler {
void beforeAdd(ChannelHandlerContext ctx) throws Exception;

View File

@ -28,7 +28,7 @@ import java.net.SocketAddress;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
public interface MessageEvent extends ChannelEvent {

View File

@ -33,7 +33,7 @@ import org.jboss.netty.buffer.ChannelBuffer;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
*/
public interface ReceiveBufferSizePredictor {

View File

@ -21,7 +21,7 @@ package org.jboss.netty.channel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2124 $, $Date: 2010-02-02 11:13:06 +0900 (Tue, 02 Feb 2010) $
*
* @apiviz.has org.jboss.netty.channel.ReceiveBufferSizePredictor oneway - - creates
*/

View File

@ -24,7 +24,7 @@ import org.jboss.netty.channel.socket.ServerSocketChannel;
*
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
public interface ServerChannel extends Channel {
// This is a tag interface.

View File

@ -21,7 +21,7 @@ package org.jboss.netty.channel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
* @apiviz.has org.jboss.netty.channel.ServerChannel oneway - - creates
*/

View File

@ -53,7 +53,7 @@ import java.net.SocketAddress;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2122 $, $Date: 2010-02-02 11:00:04 +0900 (Tue, 02 Feb 2010) $
*/
public class SimpleChannelDownstreamHandler implements ChannelDownstreamHandler {

View File

@ -74,7 +74,7 @@ import org.jboss.netty.logging.InternalLoggerFactory;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2122 $, $Date: 2010-02-02 11:00:04 +0900 (Tue, 02 Feb 2010) $
*/
public class SimpleChannelHandler implements ChannelUpstreamHandler, ChannelDownstreamHandler {

View File

@ -54,7 +54,7 @@ import org.jboss.netty.logging.InternalLoggerFactory;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2122 $, $Date: 2010-02-02 11:00:04 +0900 (Tue, 02 Feb 2010) $
*/
public class SimpleChannelUpstreamHandler implements ChannelUpstreamHandler {
@ -150,6 +150,9 @@ public class SimpleChannelUpstreamHandler implements ChannelUpstreamHandler {
/**
* Invoked when a {@link Channel} is open, but not bound nor connected.
* <br/>
*
* <strong>Be aware that this event is fired from within the Boss-Thread so you should not execute any heavy operation in there as it will block the dispatching to other workers!</strong>
*/
public void channelOpen(
ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
@ -159,6 +162,9 @@ public class SimpleChannelUpstreamHandler implements ChannelUpstreamHandler {
/**
* Invoked when a {@link Channel} is open and bound to a local address,
* but not connected.
* <br/>
*
* <strong>Be aware that this event is fired from within the Boss-Thread so you should not execute any heavy operation in there as it will block the dispatching to other workers!</strong>
*/
public void channelBound(
ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
@ -168,6 +174,9 @@ public class SimpleChannelUpstreamHandler implements ChannelUpstreamHandler {
/**
* Invoked when a {@link Channel} is open, bound to a local address, and
* connected to a remote address.
* <br/>
*
* <strong>Be aware that this event is fired from within the Boss-Thread so you should not execute any heavy operation in there as it will block the dispatching to other workers!</strong>
*/
public void channelConnected(
ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {

View File

@ -15,8 +15,10 @@
*/
package org.jboss.netty.channel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.jboss.netty.logging.InternalLogger;
@ -32,7 +34,7 @@ import org.jboss.netty.util.internal.ConversionUtil;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2267 $, $Date: 2010-05-06 16:00:52 +0900 (Thu, 06 May 2010) $
*
*/
public class StaticChannelPipeline implements ChannelPipeline {
@ -317,6 +319,14 @@ public class StaticChannelPipeline implements ChannelPipeline {
return null;
}
public List<String> getNames() {
List<String> list = new ArrayList<String>();
for (StaticChannelHandlerContext ctx: contexts) {
list.add(ctx.getName());
}
return list;
}
public Map<String, ChannelHandler> toMap() {
Map<String, ChannelHandler> map = new LinkedHashMap<String, ChannelHandler>();
for (StaticChannelHandlerContext ctx: contexts) {
@ -381,9 +391,19 @@ public class StaticChannelPipeline implements ChannelPipeline {
}
void sendDownstream(StaticChannelHandlerContext ctx, ChannelEvent e) {
if (e instanceof UpstreamMessageEvent) {
throw new IllegalArgumentException("cannot send an upstream event to downstream");
}
try {
((ChannelDownstreamHandler) ctx.getHandler()).handleDownstream(ctx, e);
} catch (Throwable t) {
// Unlike an upstream event, a downstream event usually has an
// incomplete future which is supposed to be updated by ChannelSink.
// However, if an exception is raised before the event reaches at
// ChannelSink, the future is not going to be updated, so we update
// here.
e.getFuture().setFailure(t);
notifyHandlerException(e, t);
}
}

View File

@ -23,7 +23,7 @@ package org.jboss.netty.channel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
public class SucceededChannelFuture extends CompleteChannelFuture {

View File

@ -23,7 +23,7 @@ import static org.jboss.netty.channel.Channels.*;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
*/
public class UpstreamChannelStateEvent implements ChannelStateEvent {

View File

@ -27,7 +27,7 @@ import org.jboss.netty.util.internal.StringUtil;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
*/
public class UpstreamMessageEvent implements MessageEvent {

View File

@ -25,7 +25,7 @@ package org.jboss.netty.channel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2202 $, $Date: 2010-02-23 16:18:58 +0900 (Tue, 23 Feb 2010) $
*/
public interface WriteCompletionEvent extends ChannelEvent {
/**

View File

@ -90,7 +90,7 @@ import org.jboss.netty.util.CharsetUtil;
*
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
* @version $Rev$, $Date$
* @version $Rev: 2122 $, $Date: 2010-02-02 11:00:04 +0900 (Tue, 02 Feb 2010) $
*
* @apiviz.landmark
* @apiviz.has org.jboss.netty.channel.group.ChannelGroupFuture oneway - - returns

View File

@ -110,7 +110,7 @@ import org.jboss.netty.handler.execution.ExecutionHandler;
*
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
* @version $Rev$, $Date$
* @version $Rev: 2122 $, $Date: 2010-02-02 11:00:04 +0900 (Tue, 02 Feb 2010) $
*
* @apiviz.owns org.jboss.netty.channel.group.ChannelGroupFutureListener - - notifies
*/

View File

@ -26,7 +26,7 @@ import java.util.EventListener;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
public interface ChannelGroupFutureListener extends EventListener {

View File

@ -21,7 +21,7 @@ import java.util.NoSuchElementException;
/**
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
final class CombinedIterator<E> implements Iterator<E> {

View File

@ -37,7 +37,7 @@ import org.jboss.netty.util.internal.ConcurrentHashMap;
*
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*
* @apiviz.landmark
*/
@ -253,11 +253,11 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
new LinkedHashMap<Integer, ChannelFuture>(size());
if (message instanceof ChannelBuffer) {
ChannelBuffer buf = (ChannelBuffer) message;
for (Channel c: this) {
for (Channel c: nonServerChannels.values()) {
futures.put(c.getId(), c.write(buf.duplicate()));
}
} else {
for (Channel c: this) {
for (Channel c: nonServerChannels.values()) {
futures.put(c.getId(), c.write(message));
}
}
@ -269,11 +269,11 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
new LinkedHashMap<Integer, ChannelFuture>(size());
if (message instanceof ChannelBuffer) {
ChannelBuffer buf = (ChannelBuffer) message;
for (Channel c: this) {
for (Channel c: nonServerChannels.values()) {
futures.put(c.getId(), c.write(buf.duplicate(), remoteAddress));
}
} else {
for (Channel c: this) {
for (Channel c: nonServerChannels.values()) {
futures.put(c.getId(), c.write(message, remoteAddress));
}
}

View File

@ -31,7 +31,7 @@ import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.channel.ChannelFutureListener;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;
import org.jboss.netty.util.internal.IoWorkerRunnable;
import org.jboss.netty.util.internal.DeadLockProofWorker;
/**
* The default {@link ChannelGroupFuture} implementation.
@ -39,7 +39,7 @@ import org.jboss.netty.util.internal.IoWorkerRunnable;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev$, $Date$
* @version $Rev: 2191 $, $Date: 2010-02-19 18:18:10 +0900 (Fri, 19 Feb 2010) $
*/
public class DefaultChannelGroupFuture implements ChannelGroupFuture {
@ -144,15 +144,16 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
}
public synchronized boolean isPartialSuccess() {
return !futures.isEmpty() && successCount != 0;
return successCount != 0 && successCount != futures.size();
}
public synchronized boolean isPartialFailure() {
return !futures.isEmpty() && failureCount != 0;
return failureCount != 0 && failureCount != futures.size();
}
public synchronized boolean isCompleteFailure() {
return failureCount == futures.size();
int futureCnt = futures.size();
return futureCnt != 0 && failureCount == futureCnt;
}
public void addListener(ChannelGroupFutureListener listener) {
@ -320,7 +321,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
}
private void checkDeadLock() {
if (IoWorkerRunnable.IN_IO_THREAD.get()) {
if (DeadLockProofWorker.PARENT.get() != null) {
throw new IllegalStateException(
"await*() in I/O thread causes a dead lock or " +
"sudden performance drop. Use addListener() instead or " +

View File

@ -20,12 +20,14 @@ import static org.jboss.netty.channel.Channels.*;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.NotYetConnectedException;
import java.util.Queue;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import org.jboss.netty.channel.AbstractChannel;
import org.jboss.netty.channel.ChannelConfig;
import org.jboss.netty.channel.ChannelException;
import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.channel.ChannelFutureListener;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelSink;
import org.jboss.netty.channel.DefaultChannelConfig;
@ -37,13 +39,20 @@ import org.jboss.netty.util.internal.ThreadLocalBoolean;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author Andy Taylor (andy.taylor@jboss.org)
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
final class DefaultLocalChannel extends AbstractChannel implements LocalChannel {
// TODO Move the state management up to AbstractChannel to remove duplication.
private static final int ST_OPEN = 0;
private static final int ST_BOUND = 1;
private static final int ST_CONNECTED = 2;
private static final int ST_CLOSED = -1;
final AtomicInteger state = new AtomicInteger(ST_OPEN);
private final ChannelConfig config;
private final ThreadLocalBoolean delivering = new ThreadLocalBoolean();
final AtomicBoolean bound = new AtomicBoolean();
final Queue<MessageEvent> writeBuffer = new LinkedTransferQueue<MessageEvent>();
volatile DefaultLocalChannel pairedChannel;
@ -54,6 +63,15 @@ final class DefaultLocalChannel extends AbstractChannel implements LocalChannel
super(parent, factory, pipeline, sink);
this.pairedChannel = pairedChannel;
config = new DefaultChannelConfig();
// TODO Move the state variable to AbstractChannel so that we don't need
// to add many listeners.
getCloseFuture().addListener(new ChannelFutureListener() {
public void operationComplete(ChannelFuture future) throws Exception {
state.set(ST_CLOSED);
}
});
fireChannelOpen(this);
}
@ -61,12 +79,39 @@ final class DefaultLocalChannel extends AbstractChannel implements LocalChannel
return config;
}
@Override
public boolean isOpen() {
return state.get() >= ST_OPEN;
}
public boolean isBound() {
return bound.get() && isOpen();
return state.get() >= ST_BOUND;
}
public boolean isConnected() {
return pairedChannel != null && isOpen();
return state.get() == ST_CONNECTED;
}
final void setBound() throws ClosedChannelException {
if (!state.compareAndSet(ST_OPEN, ST_BOUND)) {
switch (state.get()) {
case ST_CLOSED:
throw new ClosedChannelException();
default:
throw new ChannelException("already bound");
}
}
}
final void setConnected() {
if (state.get() != ST_CLOSED) {
state.set(ST_CONNECTED);
}
}
@Override
protected boolean setClosed() {
return super.setClosed();
}
public LocalAddress getLocalAddress() {

View File

@ -24,7 +24,7 @@ import org.jboss.netty.channel.ChannelSink;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author Andy Taylor (andy.taylor@jboss.org)
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
* @version $Rev$, $Date$
* @version $Rev: 2241 $, $Date: 2010-04-16 13:12:43 +0900 (Fri, 16 Apr 2010) $
*
* @apiviz.landmark
*/

View File

@ -30,7 +30,7 @@ import org.jboss.netty.channel.DefaultServerChannelConfig;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author Andy Taylor (andy.taylor@jboss.org)
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
final class DefaultLocalServerChannel extends AbstractServerChannel
implements LocalServerChannel {

View File

@ -24,7 +24,7 @@ import org.jboss.netty.channel.ChannelSink;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author Andy Taylor (andy.taylor@jboss.org)
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
* @version $Rev$, $Date$
* @version $Rev: 2241 $, $Date: 2010-04-16 13:12:43 +0900 (Fri, 16 Apr 2010) $
*
* @apiviz.landmark
*/

View File

@ -31,7 +31,7 @@ import java.net.SocketAddress;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author Andy Taylor (andy.taylor@jboss.org)
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
* @version $Rev$, $Date$
* @version $Rev: 2241 $, $Date: 2010-04-16 13:12:43 +0900 (Fri, 16 Apr 2010) $
*
* @apiviz.landmark
*/
@ -114,7 +114,7 @@ public final class LocalAddress extends SocketAddress implements Comparable<Loca
}
int a = System.identityHashCode(this);
int b = System.identityHashCode(this);
int b = System.identityHashCode(o);
if (a < b) {
return -1;
} else if (a > b) {

View File

@ -23,7 +23,7 @@ import org.jboss.netty.channel.Channel;
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author Andy Taylor (andy.taylor@jboss.org)
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
public interface LocalChannel extends Channel {
LocalAddress getLocalAddress();

View File

@ -23,7 +23,7 @@ import org.jboss.netty.util.internal.ConcurrentHashMap;
/**
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
final class LocalChannelRegistry {

View File

@ -23,7 +23,7 @@ import org.jboss.netty.channel.ChannelPipeline;
*
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
* @version $Rev$, $Date$
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
*/
public interface LocalClientChannelFactory extends ChannelFactory {
LocalChannel newChannel(ChannelPipeline pipeline);

Some files were not shown because too many files have changed in this diff Show More