Commit Graph

986 Commits

Author SHA1 Message Date
Trustin Lee
427d9c4bf2 Fix test failures and reported leaks 2013-06-13 15:18:11 +09:00
Trustin Lee
f178b8d421 Suppress duplicate warning message printed when a message reaches at the end of pipeline 2013-06-13 13:23:52 +09:00
Trustin Lee
175526b6bd Move ReferenceCounted and AbstractReferenceCounted to io.netty.util
- Fixes #1441
- Also move and rename IllegalBufferAccessException to ReferenceCountException
- Prettier reference count exception messages
2013-06-13 13:14:21 +09:00
Trustin Lee
283feda119 Reduce even more garbage by exposing ByteBuf.internalNioBuffer() 2013-06-13 12:40:26 +09:00
Trustin Lee
5131c024fa Tiny optimization 2013-06-13 12:15:41 +09:00
Trustin Lee
96380e756c Fix test failures introduced by 78d8f05c21 2013-06-13 11:51:03 +09:00
Trustin Lee
2088d1b491 Generate less garbage when performing gathering writes 2013-06-13 10:27:10 +09:00
Norman Maurer
d1a3806ebd Make use of gathering writes if a MessageList which only contains ByteBuf msgs is written to a NioSocketChannel 2013-06-12 09:45:33 +02:00
Trustin Lee
79e236dfc2 Make EventExecutor.shutdownGracefully() return Future
- Also added EventExecutor.terminationFuture()
- Also fixed type signature problem with Future.add/removeListener()
- Related issue: #1389
2013-06-12 08:00:54 +09:00
Trustin Lee
fd0084ecfa Remove the constructors that uses ImmediateEventExecutor from DefaultChannelGroup
.. which is incorrect in my opinion.

+ minor cleanup
2013-06-12 06:50:38 +09:00
Trustin Lee
7a1550631d Make write operation cancellation while it's in progress
.. which should be useful when writing a large buffer/file
2013-06-12 04:24:07 +09:00
Norman Maurer
5b978497f8 Cleanup 2013-06-11 16:24:06 +02:00
Trustin Lee
c3034c8964 Implement the cancellation of connection attmpe for NIO and OIO transport
- Related issue: #1432
- Also added test cases to validate the implementation
2013-06-11 18:46:39 +09:00
Trustin Lee
7a5cf48b8d Implement Promise/Future cancellation properly for outbound traffic
- Related issue: #1432
- Make sure the Promise of a write operation is not cancellable before writing out
2013-06-11 17:54:35 +09:00
Trustin Lee
41af9a1eb3 Implement cancellation properly for Promise/Future
- Related issue: #1432
- Add Future.isCancellable()
- Add Promise.setUncancellable() which is meant to be used for the party that runs the task uncancellable once started
- Implement Future.isCancelled() and Promise.cancel(boolean) properly
2013-06-11 17:46:21 +09:00
Norman Maurer
85afdda3ce Correctly write MessageList which contains more then one message 2013-06-11 10:30:15 +02:00
Norman Maurer
16e12b45f8 Use Correct NoSuchElementException 2013-06-11 07:57:35 +02:00
Norman Maurer
e4a985f6ac Let MessageList implement Iterable 2013-06-11 07:55:41 +02:00
Norman Maurer
f2f6d68d2e Make sure writing empty ByteBuf will not cause a stavation.
This also fixes [#1436]
2013-06-10 20:54:17 +02:00
Trustin Lee
3ce9ab2e72 Replace the sun.nio.ch.SelectorImpl.selectedKeys with faster one
- Yield much less garbage
- Slight performance gain (1~2%)
2013-06-11 00:00:55 +09:00
Norman Maurer
d9806c8127 Add javadocs 2013-06-10 14:23:40 +02:00
Norman Maurer
68c737f0c0 Optimize the way messages are added from one MessageList to another one 2013-06-10 14:07:25 +02:00
Norman Maurer
92bd4d2fe0 Remove MessageList.remove(*) , MessageList.set(*) and MessageList.add(i,*) 2013-06-10 13:44:01 +02:00
Norman Maurer
e9c6406819 Remove the AIO transport as NIO is just faster
The AIO transport was added in the past as we hoped it would have better latency as the NIO transport. But in reality this was never the case.
So there is no reason to use the AIO transport at all. It just put more burden on us as we need to also support it and fix bugs.
Because of this we dedicided to remove it for now. It will stay in the master_with_aio_transport branch so we can pick it up later again if it is ever needed.
2013-06-10 11:30:11 +02:00
Trustin Lee
65e4161e63 Remove an unnecessary empty line 2013-06-10 18:20:24 +09:00
Trustin Lee
fa205defa1 Simplify the logic for updating OP_WRITE in the NIO transport
- Removed code duplication
2013-06-10 18:19:58 +09:00
Norman Maurer
3be25694d0 Add ChannelHandlerContext.isRemoved() to easily detect the removal of a ChannelHandler while in a method. 2013-06-10 11:16:05 +02:00
Norman Maurer
fa6999cd42 [#1425] Allow to access the EventLoopGroups via the Bootstraps 2013-06-10 09:24:57 +02:00
Trustin Lee
14158070bf Revamp the core API to reduce memory footprint and consumption
The API changes made so far turned out to increase the memory footprint
and consumption while our intention was actually decreasing them.

Memory consumption issue:

When there are many connections which does not exchange data frequently,
the old Netty 4 API spent a lot more memory than 3 because it always
allocates per-handler buffer for each connection unless otherwise
explicitly stated by a user.  In a usual real world load, a client
doesn't always send requests without pausing, so the idea of having a
buffer whose life cycle if bound to the life cycle of a connection
didn't work as expected.

Memory footprint issue:

The old Netty 4 API decreased overall memory footprint by a great deal
in many cases.  It was mainly because the old Netty 4 API did not
allocate a new buffer and event object for each read.  Instead, it
created a new buffer for each handler in a pipeline.  This works pretty
well as long as the number of handlers in a pipeline is only a few.
However, for a highly modular application with many handlers which
handles connections which lasts for relatively short period, it actually
makes the memory footprint issue much worse.

Changes:

All in all, this is about retaining all the good changes we made in 4 so
far such as better thread model and going back to the way how we dealt
with message events in 3.

To fix the memory consumption/footprint issue mentioned above, we made a
hard decision to break the backward compatibility again with the
following changes:

- Remove MessageBuf
- Merge Buf into ByteBuf
- Merge ChannelInboundByte/MessageHandler and ChannelStateHandler into ChannelInboundHandler
  - Similar changes were made to the adapter classes
- Merge ChannelOutboundByte/MessageHandler and ChannelOperationHandler into ChannelOutboundHandler
  - Similar changes were made to the adapter classes
- Introduce MessageList which is similar to `MessageEvent` in Netty 3
- Replace inboundBufferUpdated(ctx) with messageReceived(ctx, MessageList)
- Replace flush(ctx, promise) with write(ctx, MessageList, promise)
- Remove ByteToByteEncoder/Decoder/Codec
  - Replaced by MessageToByteEncoder<ByteBuf>, ByteToMessageDecoder<ByteBuf>, and ByteMessageCodec<ByteBuf>
- Merge EmbeddedByteChannel and EmbeddedMessageChannel into EmbeddedChannel
- Add SimpleChannelInboundHandler which is sometimes more useful than
  ChannelInboundHandlerAdapter
- Bring back Channel.isWritable() from Netty 3
- Add ChannelInboundHandler.channelWritabilityChanges() event
- Add RecvByteBufAllocator configuration property
  - Similar to ReceiveBufferSizePredictor in Netty 3
  - Some existing configuration properties such as
    DatagramChannelConfig.receivePacketSize is gone now.
- Remove suspend/resumeIntermediaryDeallocation() in ByteBuf

This change would have been impossible without @normanmaurer's help. He
fixed, ported, and improved many parts of the changes.
2013-06-10 16:10:39 +09:00
Norman Maurer
89f1f3f4d1 [#1399] DefaultChannelHandlerPipeline.firstContext() should return null if no user handlers are in in the pipeline 2013-05-27 15:45:34 +02:00
Norman Maurer
f7931af704 Re-add Unsafe.voidPromise() which can be used for Unsafe operations for which no notification should be done [#1375] 2013-05-25 14:35:22 +02:00
Norman Maurer
f5dc482a59 No need to clear buffer as it is cleared later anyway and only update interestedOps if needed 2013-05-24 12:50:04 +02:00
Norman Maurer
d31ccebd62 Make sure that setAutoRead(false) has a direct effect and only update interestedOps if needed 2013-05-24 12:49:21 +02:00
Norman Maurer
252bd25855 Only call key.interestedOps() if needed 2013-05-24 12:46:30 +02:00
Trustin Lee
a3b4cdd614 Fix StackOverflowError in LocalEcho.doBeginRead() when the peer channel keeps writing data
- Fixes #1380
2013-05-24 11:55:21 +09:00
Norman Maurer
5398792ffa [#1388] Correctly break the loop on exceptions 2013-05-23 17:17:21 +02:00
Norman Maurer
50ac0cdfcb [#1388] Ensure AbstractNioMessageChannel based Channels will call fireInboundBufferUpdated() soon enough to release resources 2013-05-23 16:59:03 +02:00
Norman Maurer
9c925b104a [#1385] Fix NPE which was triggered if a write was executed but the HeadHandler not init yet 2013-05-23 07:42:01 +02:00
Norman Maurer
548540bc2d Fix a which could cause data corruption when using AioSocketChannel.
This was because it was possible to have the JDK read into a wrong buffer region if the user called discardReadBytes() later. Fixes #1377
2013-05-21 20:19:00 +02:00
Norman Maurer
81e3c1719a [maven-release-plugin] prepare for next development iteration 2013-05-18 09:59:13 +02:00
Norman Maurer
99caefdf39 [maven-release-plugin] prepare release netty-4.0.0.CR3 2013-05-18 09:57:11 +02:00
Norman Maurer
620c3e025a Just some tiny javadoc fixes 2013-05-17 22:16:29 +02:00
Norman Maurer
abb4e20d0b [#1369] Move ImmediateEventExecutor to common and let it access via a static
* Also fix a bug there to return a correct implementation of ProgressivPRomi
  ImmediateEventExecutor
2013-05-17 21:35:01 +02:00
Norman Maurer
a8830aee42 [#1369] Move ImmediateEventExecutor to common and let it access via a static public field
* Also fix a bug there to return a correct implementation of ProgressivPRomise to work with the
 ImmediateEventExecutor
2013-05-17 21:19:59 +02:00
Norman Maurer
6942dba855 [#1363] Make sure ChannnelConfig.setAutoRead(false) will stop read from socket directly 2013-05-17 20:56:09 +02:00
Norman Maurer
699ef0784e [#1317] Allow to use VoidPromise for flush(...), write(...) and sendFile(...)
* This also move rename Channel.Unsafe.voidFuture() to ChannelPropertyAccess.voidPromise()
2013-05-17 15:50:14 +02:00
Trustin Lee
fd1d31e7d8 Remove unnecessary inEventLoop() checks in Channel.Unsafe
.. because HeadHandler in the pipeline always ensures those methods are always invoked from the correct I/O thread
2013-05-17 19:20:46 +09:00
Trustin Lee
7140e4e63b Test if ChannelHandler.handlerRemoved() is called on closure / Reduced timeout 2013-05-17 11:07:53 +09:00
Trustin Lee
e1a378aa03 Clean up DefaultChannelPipelineTest
- Use the local transport in a correct way (i.e. no need to trigger channelActive et al by ourselves)
- Use Promise/Future instead of CountDownLatch where they simplifies
2013-05-17 10:54:20 +09:00
Trustin Lee
2040b07849 Free the cleared buffer as early as possible / Better naming 2013-05-16 19:41:02 +09:00