Commit Graph

672 Commits

Author SHA1 Message Date
Trustin Lee
2c7be32393 Tiny optimization 2013-01-18 10:49:53 +09:00
Norman Maurer
16f729cd95 [#907] Prevent IllegalBufferAccessException which could be triggered if inboundBufferUpdated() was called once the channel was closed 2013-01-17 20:41:08 +01:00
Norman Maurer
677886f470 [#907] Prevent IllegalBufferAccessException which could be triggered if inboundBufferUpdated(), flush(..), write(..) was triggered after the channel was closed 2013-01-17 15:12:32 +01:00
Trustin Lee
4472fe9795 Remove 'get' prefix 2013-01-17 15:06:46 +09:00
Trustin Lee
f568aa42f0 Hide the constructors of ChannelOption to force using dedicated option type 2013-01-17 14:14:41 +09:00
Norman Maurer
f136eafd5e [#943] Fix CanceledKeyException which can happen on frequently deregister/register while using the NIO Transport 2013-01-16 15:27:27 +01:00
Norman Maurer
895bce6cd5 [#917] Move transport depending ChannelOption to the specific transport to make it consistent 2013-01-16 08:04:09 +01:00
Trustin Lee
506474f569 Overhaul pipeline implementation for clarity and memory efficiency
This pull request cleans up our pipeline implementation by moving most
inter-context traversal code to DefaultChannelHandlerContext.
Previously, outbound traversal was done in DefaultChannelPipeline while
inbound traversal was done in DefaultChannelHandlerContext.

Also, to address the memory inefficiency issue raised in #920, all
runnables are lazily instantiated.
2013-01-16 00:38:14 +09:00
Trustin Lee
573a723dc2 Fix a bug where ChannelPIpeline.remove/replace() fails when its channel is not registered yet 2013-01-14 21:50:08 +09:00
Trustin Lee
e263769a55 Fix a bug where the buffers are freed too early when a handler is removed or replaced 2013-01-14 21:43:45 +09:00
Trustin Lee
a03bc6ea1d Fix a bug where freeInbound/OutboundBuffer() is not called when a handler is removed from a pipeline. 2013-01-14 20:54:12 +09:00
Norman Maurer
eb91a6d4e6 [#924] [#914] Fix high CPU usage which was caused because the OP_CONNECT flag was not cleared after the connect was complete 2013-01-11 19:42:21 +01:00
Trustin Lee
64ae8b6a37 Replace and merge DetectionUtil and DirectByteBufUtil into PlatformDependent and PlatformDependent0
PlatformDependent delegates the operations requires sun.misc.* to PlatformDependent0 to avoid runtime errors due to missing sun.misc.* classes.
2013-01-11 14:03:27 +09:00
Trustin Lee
8975406b86 Ensure the outbound buffer is not freed on write completion
- Fixes #919
2013-01-10 21:05:51 +09:00
Trustin Lee
665d022e82 Use a heap buffer from the allocator because it doesn't seem to cause OOME anymore 2013-01-10 16:23:40 +09:00
Trustin Lee
eb337ff5a7 Fix various inspection warnings 2013-01-10 15:23:58 +09:00
Trustin Lee
3c9d912355 Use InetSocketAddress wherever possible / Tighten the return type of Channel.parent() 2013-01-10 14:17:54 +09:00
Trustin Lee
793a571465 Fix a runtime type cast exception when calling RxtxChannel.local/remoteAddress() 2013-01-10 14:01:17 +09:00
Trustin Lee
137f29ba65 Do not read if a channel is inactive 2013-01-09 21:28:31 +09:00
Trustin Lee
46e364e7b7 Remove unnecessary parameters 2013-01-09 20:36:16 +09:00
Trustin Lee
b9352ded13 Fix a bug where prev/next context is not always set 2013-01-09 20:34:22 +09:00
Trustin Lee
8586d43b23 Fix DefaultChannelPipeline.toString() / Remove unnecessary conditions 2013-01-09 19:16:09 +09:00
Trustin Lee
b6fcf3acc4 Simplify DefaultChannelPipeline 2013-01-09 19:13:43 +09:00
Trustin Lee
dd6b7969b7 Give a handler more control over how its buffers' read bytes are discarded.
This pull request adds two new handler methods: discardInboundReadBytes(ctx) and discardOutboundReadBytes(ctx) to ChannelInboundByteHandler and ChannelOutboundByteHandler respectively. They are called between every inboundBufferUpdated() and flush() respectively. Their default implementation is to call discardSomeReadBytes() on their buffers and a user can override this behavior easily. For example, ReplayingDecoder.discardInboundReadBytes() looks like the following:

    @Override
    public void discardInboundReadBytes(ChannelHandlerContext ctx) throws Exception {
        ByteBuf in = ctx.inboundByteBuffer();
        final int oldReaderIndex = in.readerIndex();
        super.discardInboundReadBytes(ctx);
        final int newReaderIndex = in.readerIndex();
        checkpoint -= oldReaderIndex - newReaderIndex;
    }

If a handler, which has its own buffer index variable, extends ReplayingDecoder or ByteToMessageDecoder, the handler can also override discardInboundReadBytes() and adjust its index variable accordingly.
2013-01-09 13:34:09 +09:00
Trustin Lee
7277536ca6 Remove unnecessary finally block 2013-01-09 13:30:25 +09:00
Norman Maurer
26595471fb Call Freeable.free() if a Freeable message reaches the end of the ChannelPipeline to guard against resource leakage 2013-01-07 12:34:18 +01:00
Norman Maurer
5526153459 [#882] Add a PartialFlushException which will allow to notify the user that the flush/write was only partial succesful 2013-01-05 20:30:48 +01:00
Courtney Robinson
3a52cc410a Add some of the metrics mentioned in #718
use single static initialization of available metrics monitor registries

* This changes the original implementation to work in a similar way to
how slf4j selects and loads an implementation.
* Uses a single static instance so intialization is done only once.
* Doesn't throw IllegalStateException if multiple implementations are
found on the classpath. It instead selects and uses the first
implementation returned by iterator()
* Class left as an iterable to keep the API the same

add yammer metrics to examples to allow them to publish metrics

publish the number of threads used in an EventLoopGroup see issue #718

* seems like the better place to put this because it sets the default
thread count if the MultithreadEventLoopGroup uses super(0,...)
* It also happens to be the common parent class amongst all the
MultiThreadedEventLoopGroup implementations
* Count is reported for
io.netty.channel.{*,.local,.socket.aio,.socket.nio}

fix cosmetic issues pointed out in pull request and updated notice.txt

see https://github.com/netty/netty/pull/780

count # of channels registered in single threaded event loop

measure how many times Selector.select return before SELECT_TIME
2013-01-04 11:27:49 +01:00
Norman Maurer
2f6e17f681 Make sure we catch UnsupportedOperationException for derived buffers 2013-01-03 22:49:54 +01:00
Norman Maurer
ccb5409f58 [#884] Split SCTP transport into extra module 2013-01-03 22:19:06 +01:00
Norman Maurer
37a3f2e3b8 [#887] [#866] [#883] Add unified interface for Message oriented protocols and also use direct buffers for them 2013-01-03 18:15:53 +01:00
Trustin Lee
0abfaf20e4 Revert 5161ca733c 2013-01-03 17:05:18 +09:00
Trustin Lee
923dde7a5f Do not auto-start read operation 2013-01-03 16:01:41 +09:00
Trustin Lee
103edc4467 Make ChannelConfig.setAutoRead() triggers Channel.read() if autoRead was previously false
- also rename JDK socket and channel variables so that they are less ambiguous
2013-01-01 16:49:21 +09:00
Norman Maurer
5161ca733c Move utility method to abstract base class and correctly handle expand of buffer also for OIO 2012-12-31 22:09:27 +01:00
Trustin Lee
89a16fe01e Fix a bug in NIO transport where inboundBufferSuspended() is triggered even if the channel is closed.
- No non-static wildcard import
2013-01-01 00:35:44 +09:00
Trustin Lee
93fd73fbbf Fix a bug in AioSocketChannel where inboundBufferSuspended() is triggered even if the channel is closed. 2013-01-01 00:27:30 +09:00
Norman Maurer
8cf9f52919 Add new ChanelFuureListener impl that mimic the old behavior of Netty 3 and so allow to also call fireException for outbound operations 2012-12-31 16:17:08 +01:00
Trustin Lee
1e9652b47a Fix a bug in AioSocketChannel where recursive doBeginRead() is allowed unexpectedly 2013-01-01 00:08:58 +09:00
Norman Maurer
e0a6dc0ac3 Remove ChannelFutureProgressListener 2012-12-31 23:27:37 +09:00
Norman Maurer
4e77bacdf7 [#873] [#868] Split ChannelFuture into ChannelFuture and ChannelPromise 2012-12-31 23:27:16 +09:00
Trustin Lee
0909878581 Read only when requested (read-on-demand)
This pull request introduces a new operation called read() that replaces the existing inbound traffic control method. EventLoop now performs socket reads only when the read() operation has been issued. Once the requested read() operation is actually performed, EventLoop triggers an inboundBufferSuspended event that tells the handlers that the requested read() operation has been performed and the inbound traffic has been suspended again. A handler can decide to continue reading or not.

Unlike other outbound operations, read() does not use ChannelFuture at all to avoid GC cost. If there's a good reason to create a new future per read at the GC cost, I'll change this.

This pull request consequently removes the readable property in ChannelHandlerContext, which means how the traffic control works changed significantly.

This pull request also adds a new configuration property ChannelOption.AUTO_READ whose default value is true. If true, Netty will call ctx.read() for you. If you need a close control over when read() is called, you can set it to false.

Another interesting fact is that non-terminal handlers do not really need to call read() at all. Only the last inbound handler will have to call it, and that's just enough. Actually, you don't even need to call it at the last handler in most cases because of the ChannelOption.AUTO_READ mentioned above.

There's no serious backward compatibility issue. If the compiler complains your handler does not implement the read() method, add the following:

public void read(ChannelHandlerContext ctx) throws Exception {
    ctx.read();
}

Note that this pull request certainly makes bounded inbound buffer support very easy, but itself does not add the bounded inbound buffer support.
2012-12-31 23:26:00 +09:00
Norman Maurer
b49b3d9c56 [#879] Notify correct ChannelFuture for queued FileRegions 2012-12-31 11:35:25 +01:00
Norman Maurer
c80b1bb66e [#872] AbstractNioByteChannel and AbstractNioMessageChannel should be public 2012-12-30 12:48:32 +01:00
Norman Maurer
0fb0037eab Rename IpAddresses to NetUtil 2012-12-29 18:25:32 +01:00
Norman Maurer
5d13c7d27b Merge IPUtil and NetworkConstants into IpAddresses and also make naming of methods consistent 2012-12-29 18:17:33 +01:00
Norman Maurer
e2b240799c [#857] Check if the SelectionKey is valid before access readyOps() 2012-12-29 18:07:02 +01:00
Norman Maurer
88838413c7 Javadocs and cleanup intellij warnings 2012-12-27 23:02:13 +01:00
Norman Maurer
a20aba87ab Remove get prefix from Sctp methods to be more inline with the rest 2012-12-27 22:53:42 +01:00
Norman Maurer
6db7250ed9 Javadocs added for SCTP stuff 2012-12-27 22:46:46 +01:00