Commit Graph

4866 Commits

Author SHA1 Message Date
Norman Maurer
806e9b1f8c Make sure we handle outbound messages of type ByteBuf special 2013-03-11 08:59:00 +09:00
Trustin Lee
32efba34d8 Initial implementation of the Streaming API
This pull request provides a framework for exchanging a very large
stream between handlers, typically between a decoder and an inbound
handler (or between a handler that writes a message and an encoder that
encodes that message).

For example, an HTTP decoder, previously, generates multiple
micro-messages to decode an HTTP message (i.e. HttpRequest +
HttpChunks). With the streaming API, The HTTP decoder can simply
generate a single HTTP message whose content is a Stream. And then the
inbound handler can consume the Stream via the buffer you created when
you begin to read the stream. If you create a buffer whose capacity is
bounded, you can handle a very large stream without allocating a lot of
memory. If you just want to wait until the whole content is ready, you
can also do that with an unbounded buffer.

The streaming API also supports a limited form of communication between
a producer (i.e. decoder) and a consumer. A producer can abort the
stream if the stream is not valid anymore. A consumer can choose to
reject or discard the stream, where rejection is for unrecoverable
failure and discard is for recoverable failure.

P.S. Special thanks to @jpinner for the initial input.
2013-03-11 08:57:17 +09:00
Trustin Lee
b4bf565ad9 Travis CI configuration 2013-03-11 08:47:12 +09:00
Norman Maurer
0a1bc86569 Javadocs cleanup / added 2013-03-10 21:07:19 +01:00
Norman Maurer
0504a442ae Check for NPE and also optimze HashSet allocation 2013-03-10 21:06:59 +01:00
Norman Maurer
0ac5fd9f18 Let BufUtil.retain(...) return the given object 2013-03-10 19:50:26 +01:00
Trustin Lee
ed825de4bf Fix a bug where TypeParameterMatcher raises ClassCastException when an instance with raw type parameter is given 2013-03-09 09:19:34 +09:00
Trustin Lee
4f2e347625 More concise exception message 2013-03-09 08:48:22 +09:00
Norman Maurer
fcd6becad9 [#1136] Fix possible IllegalBufferAccessException when remove itself from the pipeline 2013-03-08 21:55:46 +01:00
Norman Maurer
7b4c83b462 [#1135] Fix endless loop which will get triggered when an exception is thrown during freeHandlerBuffersAfterRemoval 2013-03-08 21:41:59 +01:00
Norman Maurer
b1775a3223 [#1131] Codecs must not cache next buffer during processing 2013-03-08 15:38:17 +01:00
Norman Maurer
8d7f1e2820 Add stacktrace to the IllegalStateException which is thrown if a Promise was notified before 2013-03-08 15:11:29 +01:00
Norman Maurer
fd3f923b52 Allow to specify the used buffer type for ChannelInboundByteBufHandler and ChannelOutboundByteBufHandler by configuration. As default it tries to use a direct ByteBuf 2013-03-08 08:20:46 +01:00
Trustin Lee
a9a29bdf3f Use I/O buffer whenever possible now that our direct buffers are as fast as heap buffers 2013-03-08 11:21:08 +09:00
Trustin Lee
63116239ac Always use EmptyByteBuf when a user attempts to construct a buffer with 0 maxCapacity / Make EmptyByteBuf remember the allocator it came from / Optimize EmptyByteBuf a little bit 2013-03-08 11:03:11 +09:00
Trustin Lee
096e4c95ef Fix checkstyle 2013-03-08 10:39:52 +09:00
Trustin Lee
12f1d96914 Relaxed memory access constraint of ReferenceCounted.refCnt() for potentially better performance / More precise reference counting for MessageBuf 2013-03-08 10:32:20 +09:00
Norman Maurer
6ac9b17ddd Make WebSocket codec also work when HttpClientCodec and HttpServerCodec is used.
Also refactor the handshakers to share more code and make it easier to implement a new one and less error-prone
2013-03-08 08:46:47 +09:00
Trustin Lee
41ab17b9bf Fix inspection warnings in HashedWheelTimer 2013-03-08 08:45:17 +09:00
Trustin Lee
16f4de7adb Use the original stack trace when translating SocketTimeoutException to ConnectTimeoutException 2013-03-08 08:40:28 +09:00
Prajwal Tuladhar
e66fc219ff port fix from Akka for HashedWheelTimer
Ported from commits:

* cb4e3536b0
* 7e590f3071
2013-03-08 08:25:37 +09:00
Norman Maurer
61d6c48365 [#1036] Add special ConnectTimeoutException which is thrown if a connection failed because of a timeout 2013-03-07 20:53:45 +01:00
Norman Maurer
9599bfd569 Fix class-cast exception which is a regression introduces in 256c931db2 2013-03-07 11:11:37 +01:00
Trustin Lee
526dafca75 Fix checkstyle 2013-03-07 16:13:44 +09:00
Norman Maurer
88cc8c1739 [#1065] Provide Future/Promise without channel reference 2013-03-07 07:21:37 +01:00
Trustin Lee
0f8fbac9f8 Fix a problem in SslHandler where it doesn't work with TLS False Start
.. as suggested by @justinsb
2013-03-07 12:51:07 +09:00
Trustin Lee
148abe52f9 Reduce the amount of memory used for handler names
- Fixes #1123
2013-03-07 12:43:16 +09:00
Trustin Lee
303f83043b Fix checkstyle 2013-03-06 18:23:08 +09:00
Trustin Lee
88df53ec1a Fix infinite recursion when transferring data between different type of buffers / Add ByteBuf.hasMemoryAddress/memoryAddress()
- Fixes: #1109 and #1110
2013-03-06 18:22:16 +09:00
Trustin Lee
3d6d9f394d Fix checkstyle 2013-03-06 17:10:26 +09:00
Trustin Lee
81ce0555e6 Add UnpooledUnsafeDirectByteBuf and use it when low-level access is available
- Remove PooledUnsafeDirectByteBuf.setMedium() which is redundant
- Fix constructor visibility
2013-03-06 16:01:46 +09:00
Trustin Lee
6c3d5ed907 Use _set* in AbstractByteBuf.write*() 2013-03-06 14:56:27 +09:00
Trustin Lee
1c1570ffc4 Make field access via ByteBuf.read/write*() faster by avoiding unnecessary boundary checks
- also disabled a time consuming test that is actually a regression test
2013-03-06 10:32:29 +09:00
Trustin Lee
5f2c2cdc9b Fix a bug in PoolArena and PoolSubpage where subpage pools are not updated correctly
- Make PoolSubpage a linked list node in the pool
- Now that a subpage is added to and removed from the pool correctly, allocating a subpage from the pool became vastly simpler.
2013-03-05 23:55:41 +09:00
Trustin Lee
6e5bb87219 Re-enable some critical tests 2013-03-05 18:42:34 +09:00
Trustin Lee
c5f606e632 Warn in case of incomplete low-level API 2013-03-05 18:06:01 +09:00
Trustin Lee
4cb023f190 Add more variants of ByteBufAllocator.ioBuffer() / Update Javadoc 2013-03-05 17:59:31 +09:00
Trustin Lee
8d88acb4a7 Change ByteBufAllocator.buffer() to allocate a direct buffer only when the platform can handle a direct buffer reliably
- Rename directbyDefault to preferDirect
 - Add a system property 'io.netty.prederDirect' to allow a user from changing the preference on launch-time
 - Merge UnpooledByteBufAllocator.DEFAULT_BY_* to DEFAULT
2013-03-05 17:55:24 +09:00
Trustin Lee
a8a7c4f576 Provide a way to implement an ChannelInbound/OutboundMessageHandler conveniently without extending an adapter class
- Add ChannelHandlerUtil and move the core logic of ChannelInbound/OutboundMessageHandler to ChannelHandlerUtil
- Add ChannelHandlerUtil.SingleInbound/OutboundMessageHandler and make ChannelInbound/OutboundMessageHandlerAdapter implement them.  This is a backward incompatible change because it forces all handler methods to be public (was protected previously)
- Fixes: #1119
2013-03-05 17:27:53 +09:00
Trustin Lee
307e6c47d8 Make hasUnsafe() return true only when all necessary low level operations are available for reliable direct buffer access 2013-03-05 17:25:54 +09:00
Norman Maurer
256c931db2 Move exceptionCaught(..) back to ChannelHandler. Related to [#1118] 2013-03-05 07:34:34 +01:00
Norman Maurer
faaff91dd0 Fix checkstyle 2013-03-05 07:06:52 +01:00
Trustin Lee
7e17f71b30 Make PlatformDependent work with the platforms without unaligned access support 2013-03-05 14:27:52 +09:00
Trustin Lee
e4aa941bd4 Simplify ChannelInboundMessageHandlerAdapter.inboundBufferUpdated() implementation 2013-03-05 12:22:57 +09:00
Trustin Lee
0e3825899a Move DefaultChannelPipeline.notifyHandlerException() to DefaultChannelHandlerContext / Always trigger exceptionCaught() at the handler that raised an exception
- Related: #1118
2013-03-05 12:13:14 +09:00
Norman Maurer
1603d9792d Move methods from ChannelHandler to ChannelStateHandler like proposed in [#1107] 2013-03-04 07:28:10 +01:00
Norman Maurer
3ac78b030a Improve javadocs 2013-03-01 22:30:45 +01:00
Norman Maurer
03525f4b64 Fix javadocs 2013-03-01 21:42:08 +01:00
Norman Maurer
42dad6d9d4 [#1106] Also handle FileRegion in ByteToByteEncoder and SslHandler 2013-02-28 19:40:34 +01:00
Trustin Lee
881bd8eea3 Support array types in JavassistTypeParameterMatcherGenerator 2013-02-28 10:37:55 -08:00