Commit Graph

1603 Commits

Author SHA1 Message Date
Norman Maurer
7ee18e92f9 Small improvement in SimpleChannelInboundHandlerAdapter javadoc 2014-06-18 14:49:36 +02:00
Norman Maurer
061cb21689 Make use of AtomicLongFieldUpdater.addAndGet(...) for cleaner code
Motivation:

The code in ChannelOutboundBuffer can be simplified by using AtomicLongFieldUpdater.addAndGet(...)

Modification:

Replace our manual looping with AtomicLongFieldUpdater.addAndGet(...)

Result:

Cleaner code
2014-06-17 20:18:18 +02:00
Norman Maurer
375da788e7 [#2577] ChannelOutboundBuffer.addFlush() unnecessary loop through all entries on multiple calls
Motivation:

If ChannelOutboundBuffer.addFlush() is called multiple times and flushed != unflushed it will still loop through all entries that are not flushed yet even if it is not needed anymore as these were marked uncancellable before.

Modifications:

Check if new messages were added since addFlush() was called and only if this was the case loop through all entries and try to mark the uncancellable.

Result:

Less overhead when ChannelOuboundBuffer.addFlush() is called multiple times without new messages been added.
2014-06-17 09:31:53 +02:00
belliottsmith
2a2a21ec59 Introduce FastThreadLocal which uses an EnumMap and a predefined fixed set of possible thread locals
Motivation:
Provide a faster ThreadLocal implementation

Modification:
Add a "FastThreadLocal" which uses an EnumMap and a predefined fixed set of possible thread locals (all of the static instances created by netty) that is around 10-20% faster than standard ThreadLocal in my benchmarks (and can be seen having an effect in the direct PooledByteBufAllocator benchmark that uses the DEFAULT ByteBufAllocator which uses this FastThreadLocal, as opposed to normal instantiations that do not, and in the new RecyclableArrayList benchmark);

Result:
Improved performance
2014-06-13 10:56:18 +02:00
Norman Maurer
8180f7922f Optimize DefaultChannelPipeline in terms of memory usage and initialization time
Motivation:
Each of DefaultChannelPipeline instance creates an head and tail that wraps a handler. These are used to chain together other DefaultChannelHandlerContext that are created once a new ChannelHandler is added. There are a few things here that can be improved in terms of memory usage and initialization time.

Modification:
- Only generate the name for the tail and head one time as it will never change anyway
- Rename DefaultChannelHandlerContext to AbstractChannelHandlerContext and make it abstract
- Create a new DefaultChannelHandlerContext that is used when a ChannelHandler is added to the DefaultChannelPipeline
- Rename TailHandler to TailContext and HeadHandler to HeadContext and let them extend AbstractChannelHandlerContext. This way we can save 2 object creations per DefaultChannelPipeline

 Result:
- Less memory usage because we have 2 less objects per DefaultChannelPipeline
- Faster creation of DefaultChannelPipeline as we not need to generate the name for the head and tail
2014-06-10 12:18:38 +02:00
Norman Maurer
a79b69adf5 ChannelFlushPromiseNotifier should allow long value for pendingDataSize
Motivation:
At the moment ChannelFlushPromiseNotifier.add(....) takes an int value for pendingDataSize, which may be too small as a user may need to use a long. This can for example be useful when a user writes a FileRegion etc. Beside this the notify* method names are kind of missleading as these should not contain *Future* because it is about ChannelPromises.

Modification:
Add a new add(...) method that takes a long for pendingDataSize and @deprecated the old method. Beside this also @deprecated all *Future* methods and add methods that have *Promise* in the method name to better reflect usage.

Result:
ChannelFlushPromiseNotifier can be used with bigger data.
2014-06-03 17:34:53 +02:00
Korotaev Boris
5b2a01a196 Fix broken CompositeMatcher
Motivation:

ChannelMatchers#CompositeMatcher inverts matches result.

Modifications:

Switched return values.

Result:

ChannelMatchers#CompositeMatcher will return correct results.
2014-06-01 13:13:49 +02:00
Frédéric Brégier
c255f38647 Correction on StringBuilder default init size
Motivation:
The default StringBuilder size is too small (data.length + 4) while it will be 2*data.length (byte to Hex) + 5 "-" char (since 5 peaces appended).

Modification:
Changing initial size to the correct one

Result:
Allocation of the correct final size from the beginning for this StringBuilder.
2014-05-30 07:35:49 +02:00
Norman Maurer
2d9e0f53a5 Better implementation of AttributeMap and also add hasAttr(...). See [#2439]
Motivation:
The old DefaultAttributeMap impl did more synchronization then needed and also did not expose a efficient way to check if an attribute exists with a specific key.

Modifications:
* Rewrite DefaultAttributeMap to not use IdentityHashMap and synchronization on the map directly. The new impl uses a combination of AtomicReferenceArray and synchronization per chain (linked-list). Also access the first Attribute per bucket can be done without any synchronization at all and just uses atomic operations. This should fit for most use-cases pretty weel.
* Add hasAttr(...) implementation

Result:
It's now possible to check for the existence of a attribute without create one. Synchronization is per linked-list and the first entry can even be added via atomic operation.
2014-05-15 06:47:42 +02:00
Norman Maurer
59d92ad6cf [#2485] Use RecvByteBufAllocator for all allocations related to read from Channel
Motivation:
At the moment we sometimes use only RecvByteBufAllocator.guess() to guess the next size and the use the ByteBufAllocator.* directly to allocate the buffer. We should always use RecvByteBufAllocator.allocate(...) all the time as this makes the behavior easier to adjust.

Modifications:
Change the read() implementations to make use of RecvByteBufAllocator.

Result:
Behavior is more consistent.
2014-05-10 15:27:43 +02:00
Norman Maurer
9752f37fa0 [#2454] Correctly return null when DefaultChannelPipeline.firstContext() is called on empty pipeline
Motivation:
DefaultChannelPipeline.firstContext() should return null when the ipeline is empty. This is not the case atm.

Modification:
Fix incorrect check in DefaultChannelPipeline.firstContext() and add unit tests.

Result:
Correctly return null when DefaultChannelPipeline.firstContext() is called on empty pipeline.
2014-05-04 21:13:17 +02:00
Norman Maurer
e8b5f19b82 Not cause busy loop when interrupt Thread of NioEventLoop
Motivation:
Because Thread.currentThread().interrupt() will unblock Selector.select() we need to take special care when check if we need to rebuild the Selector. If the unblock was caused by the interrupt() we will clear it and move on as this is most likely a bug in a custom ChannelHandler or a library the user makes use of.

Modification:
Clear the interrupt state of the Thread if the Selector was unblock because of an interrupt and the returned keys was 0.

Result:
No more busy loop caused by Thread.currentThread().interrupt()
2014-04-28 08:18:57 +02:00
Norman Maurer
d8d822fddd Eliminate unnecessary extra synchronization in DefaultChannelPipeline
Motivation:
At the moment whenever we add/remove a ChannelHandler with an EventExecutorGroup we have two synchronization points in the execution path. One to find the childInvoker and one for add/remove itself. We can eliminate the former by call findIInvoker in the synchronization block, as we need to synchronize anyway.

Modification:
Remove the usage of AtomicFieldUpdater and the extra synchronization in findInvoker by moving the call of the method in the synchronized(this) block.

Result:
Less synchronization points and volatile reads/writes
2014-04-25 14:15:23 +02:00
Trustin Lee
0fceef8ab6 Undeprecate deregister() and chanelUnregistered()
Motivation:

As discussed in #2250, it will become much less complicated to implement
deregistration and reregistration of a channel once #2250 is resolved.
Therefore, there's no need to deprecate deregister() and
channelUnregistered().

Modification:

- Undeprecate deregister() and channelUnregistered()
- Remove SuppressWarnings annotations where applicable

Result:

We (including @jakobbuchgraber) are now ready to play with #2250 at
master
2014-04-25 16:40:42 +09:00
Trustin Lee
d765f6b870 Synchronized between 4.1 and master (part 3)
Motivation:

4 and 5 were diverged long time ago and we recently reverted some of the
early commits in master.  We must make sure 4.1 and master are not very
different now.

Modification:

Fix found differences

Result:

4.1 and master got closer.
2014-04-25 16:17:59 +09:00
Trustin Lee
b9039eaa82 Synchronized between 4.1 and master again (part 2)
Motivation:
4 and 5 were diverged long time ago and we recently reverted some of the
early commits in master.  We must make sure 4.1 and master are not very
different now.

Modification:
Remove ChannelHandlerInvoker.writeAndFlush(...) and the related
implementations.

Result:
4.1 and master got closer.
2014-04-25 15:06:26 +09:00
Norman Maurer
8c3eaf3b56 Synchronized between 4.1 and master again
Motivation:
4 and 5 were diverged long time ago and we recently reverted some of the
early commits in master.  We must make sure 4.1 and master are not very
different now.

Modification:
Remove ChannelHandlerInvoker.writeAndFlush(...) and the related implementations.

Result:
4.1 and master got closer.
2014-04-24 21:28:24 +02:00
Norman Maurer
a2f1f21612 Synchronized between 4.1 and master
Motivation:

4 and 5 were diverged long time ago and we recently reverted some of the
early commits in master.  We must make sure 4.1 and master are not very
different now.

Modification:

Small adjustments to match up branches

Result:

4.1 and master got closer.
2014-04-24 21:04:20 +02:00
Trustin Lee
db3709e652 Synchronized between 4.1 and master
Motivation:

4 and 5 were diverged long time ago and we recently reverted some of the
early commits in master.  We must make sure 4.1 and master are not very
different now.

Modification:

Fix found differences

Result:

4.1 and master got closer.
2014-04-25 00:38:02 +09:00
Norman Maurer
7ae40ace32 [#2400] Not close LocalChannel during deregister() to allow register to other EventLoop
Motivation:
At the moment it is not possible to deregister a LocalChannel from its EventLoop and register it to another one as the LocalChannel is closed during the deregister.

Modification:
Not close the LocalChannel during dergister

Result:
It is now possible to deregister a LocalChannel and register it to another EventLoop
2014-04-21 10:07:42 +02:00
Norman Maurer
9e02a9bbee Move validatePromise(...) to ChannelHandlerInvokerUtil. Related to [#2398]
Motivation:
Once a user implement a custom ChannelHandlerInvoker it is needed to validate the ChannelPromise. We should expose a utility method for this.

Modifications:
Move validatePromise(...) from DefaultChannelHandlerInvoker to ChannelHandlerInvokerUtil and make it public.

Result:
User is able to reuse code
2014-04-17 16:01:26 +02:00
Norman Maurer
9b670d819f [#2144] Fix NPE in Local transport caused by a race
Motivation:
At the moment it is possible to see a NPE when the LocalSocketChannels doRegister() method is called and the LocalSocketChannels doClose() method is called before the registration was completed.

Modifications:
Make sure we delay the actual close until the registration task was executed.

Result:
No more NPE
2014-04-17 15:06:52 +02:00
Norman Maurer
20ef4690e7 [#2375] [#2404] Fix bug in respecting ChannelConfig.setAutoRead(false) and also fix Channel.read() for OIO
Motivation:
At the moment ChanneConfig.setAutoRead(false) only is guaranteer to not have an extra channelRead(...) triggered when used from within the channelRead(...) or channelReadComplete(...) method. This is not the correct behaviour as it should also work from other methods that are triggered from within the EventLoop. For example a valid use case is to have it called from within a ChannelFutureListener, which currently not work as expected.

Beside this there is another bug which is kind of related. Currently Channel.read() will not work as expected for OIO as we will stop try to read even if nothing could be read there after one read operation on the socket (when the SO_TIMEOUT kicks in).

Modifications:
Implement the logic the right way for the NIO/OIO/SCTP and native transport, specific to the transport implementation. Also correctly handle Channel.read() for OIO transport by trigger a new read if SO_TIMEOUT was catched.

Result:
It is now also possible to use ChannelConfig.setAutoRead(false) from other methods that are called from within the EventLoop and have direct effect.

Conflicts:
	transport-sctp/src/main/java/io/netty/channel/sctp/nio/NioSctpChannel.java
	transport/src/main/java/io/netty/channel/socket/nio/NioDatagramChannel.java
	transport/src/main/java/io/netty/channel/socket/nio/NioSocketChannel.java
2014-04-17 07:50:51 +02:00
Norman Maurer
17334a0a42 [#2390] Minimize memory usage of NioDatagramChannel
Motivation:
At the moment we create a HashMap that holds the MembershipKeys for multicast with every NioDatagramChannel even when most people not need it at al

Modifications:
Lazy create the HashMap when needed.

Result:
Less memory usage and less object creation
2014-04-15 06:56:17 +02:00
Norman Maurer
88481131be [#2353] Use a privileged block to get ClassLoader and System property if needed
Motivation:
When using System.getProperty(...) and various methods to get a ClassLoader it will fail when a SecurityManager is in place.

Modifications:
Use a priveled block if needed. This work is based in the PR #2353 done by @anilsaldhana .

Result:
Code works also when SecurityManager is present
2014-04-08 14:12:25 +02:00
Norman Maurer
1087160fa7 [#2363] SelectedSelectionKeySet may hold strong reference to SelectionKey after Channel is closed
Motivation:
Because we not null out the array entry in the SelectionKey[] which is produced by SelectedSelectionKeySet.flip() we may end up with a few SelectionKeyreferences still hanging around here even after the Channel was closed. As these entries may be present at the end of the SelectionKey[] which is never updated for a long time as not enough SelectionKeys are ready.

Modifications:
Once we access the SelectionKey out of the SelectionKey[] we directly null it out.

Result:
Reference can be GC'ed right away once the Channel was closed.
2014-04-05 19:31:12 +02:00
Norman Maurer
fdb1db90c4 [#2362] AbstractChannel.AbstractUnsafe.write(...) is slow
Motivation:
At the moment we do a Channel.isActive() check in every AbstractChannel.AbstractUnsafe.write(...) call which gives quite some overhead as shown in the profiler when you write fast enough. We can eliminate the check and do something more smart here.

Modifications:
Remove the isActive() check and just check if the ChannelOutboundBuffer was set to null before, which means the Channel was closed. The rest will be handled in flush0() anyway.

Result:
Less overhead when doing many write calls
2014-04-04 09:54:52 +02:00
Norman Maurer
772a9d2610 [#2349] Correctly handle cancelled ChannelPromise in DefaultChannelHandlerContext
Motivation:
At the moment an IllegalArgumentException will be thrown if a ChannelPromise is cancelled while propagate through the ChannelPipeline. This is not correct, we should just stop to propagate it as it is valid to cancel at any time.

Modifications:
Stop propagate the operation through the ChannelPipeline once a ChannelPromise is cancelled.

Result:
No more IllegalArgumentException when cancel a ChannelPromise while moving through the ChannelPipeline.
2014-03-31 07:53:22 +02:00
Trustin Lee
844362a947 User-definable thread model via ChannelHandlerInvoker
Motivation:

While the default thread model provided by Netty is reasonable enough for most applications, some users might have a special requirement for the thread model.  Here are a few examples:

- A user might want to invoke handlers from the caller thread directly, assuming that his or her application is completely asynchronous and does not make any invocation from non-I/O thread.  In this case, the default invoker implementation will only add the overhead of checking if the current thread is an I/O thread or not.
- A user might want to invoke handlers from different threads depending on the type of events flexibly.

Modifications:

- Backport 132af3a485 which is a fix for #1912
  - Add a new interface called 'ChannelHandlerInvoker' that performs the invocation of event handler methods.
  - Add pipeline manipulation methods that accept ChannelHandlerInvoker
- The differences from the original commit:
  - Separated the irrelevant changes out
  - Channel.eventLoop is null until the registration is complete in this branch, so Channel.Unsafe.invoker() doesn't work before registration.
  - Deregistration is not gone in this branch, so the methods related with deregistration were added to ChannelHandlerInvoker
2014-03-24 18:09:27 +09:00
Trustin Lee
6d4c4d9e4b Correct the return type of MultithreadEventLoopGroup.newChild()
Motivation:

MultithreadEventLoopGroup.newChild() does not override MultithreadEventExecutorGroup.newChild() which returns EventExecutor.  MultithreadEventLoopGroup.newChild() should never return an EventExecutor, so this is incorrect.

Modifications:

Override MultithreadEventLoopGroup.newChild() so that it returns EventLoop

Result:

Correct API
2014-03-24 17:05:36 +09:00
Trustin Lee
aeb6ba5684 Update the Javadoc of ChannelHandler and ChannelHandlerContext
Motivation:

It's out of date and it has broken links, etc.

Modifications:

Backport the fixes from master (132af3a485)

Result:

Better Javadoc
2014-03-24 16:07:53 +09:00
Trustin Lee
7dc63ccd95 Add EventExecutor.children() in favor of iterator()
Motivation:

EventExecutor.iterator() is fixed to return Iterator<EventExecutor> and there's no way to change that as long as we don't extend Iterable.  However, a user should have a way to cast the returned set of executors painlessly.  Currently, it is only possible with an explicit cast like (Iterator<NioEventLoop>).

Modifications:

Instead, I added a new method called 'children()' which returns an immutable collection of child executors whose method signature looks like the following:

    <E extends EventExecutor> Set<E> children();

Result:

A user can now do this:

    Set<NioEventLoop> loops = group.children();
    for (NioEventLoop l: loops) { ... }

Unfortunately, this is not possible:

    for (NioEventLoop l: group.children()) { ... }

However, it's still a gain that a user doesn't need to down-cast explicitly and to add the '@SuppressWarnings` annotation.
2014-03-24 12:32:55 +09:00
Trustin Lee
1e3b7d8273 Replace LocalEventLoopGroup with DefaultEventLoopGroup
Motivation:

LocalEventLoopGroup and LocalEventLoop are not really special for LocalChannels.  It can be used for other channel implementations as long as they don't require special handling.

Modifications:

- Add DefaultEventLoopGroup and DefaultEventLoop
- Deprecate LocalEventLoopGroup and make it extend DefaultEventLoopGroup
- Add DefaultEventLoop and remove LocalEventLoop
- Fix inspector warnings

Result:

- Better class names.
2014-03-24 11:39:55 +09:00
Trustin Lee
007694b963 Implement EventExecutor.parent() in AbstractEventExecutor
Motivation:

EventExecutor.parent() and EventLoop.parent() almost always return a constant parent executor.  There's not much reason to let it implemented in subclasses.

Modifications:

- Implement AbstractEventExecutor.parent() with an additional contructor
- Add AbstractEventLoop so that subclasses extend AbstractEventLoop, which implements parent() appropriately
- Remove redundant parent() implementations in the subclasses
- Fix inspector warnings

Result:

Less duplication.
2014-03-24 11:05:51 +09:00
CoNDoRip
ac5e838398 Allow specifying SelectorProvider when constructing an NIO channel #2311
Motivation:

At the moment we use the system-wide default selector provider for this invocation of the Java virtual machine when constructing a new NIO channel, which makes using an alternative SelectorProvider practically useless.
This change allows user specify his/her preferred SelectorProvider.

Modifications:

Add SelectorProvider as a param for current `private static *Channel newSocket` method of NioSocketChannel, NioServerSocketChannel and NioDatagramChannel.
Change default constructors of NioSocketChannel, NioServerSocketChannel and NioDatagramChannel to use DEFAULT_SELECTOR_PROVIDER when calling newSocket(SelectorProvider).
Add new constructors for NioSocketChannel, NioServerSocketChannel and NioDatagramChannel which allow user specify his/her preferred SelectorProvider.

Result:

Now users can specify his/her preferred SelectorProvider when constructing an NIO channel.
2014-03-23 15:57:46 +01:00
Trustin Lee
b5c97bcc82 Use the length of MAC address as the last property to compare to get the best MAC address
Motivation:

Some operating systems like Windows 7 uses a valid globally unique EUI-64 MAC address for a virtual device (e.g. 00:00:00:00:00:00:00:E0), and because it's usually longer than the legit MAC-48 address, we should not use the length of MAC address when two MAC addresses are of the same quality.  Instead, we should compare the INET address of the NICs before comparing the length of the MAC addresses.

Modification:

Compare the length of MAC addresses as a last resort.

Result:

Correct MAC address detection in Windows with IPv6 enabled.
2014-03-21 12:58:58 +09:00
Trustin Lee
3613d2d59e Prefer the NIC with global IP address when getting the default machine ID
Motivation:

When there are two MAC addresses which are good enough, we can choose the one with better IP address rather than just choosing the first appeared one.

Modification:

Replace isBetterAddress() with compareAddresses() to make it return if both addresses are in the same preference level.
Add compareAddresses() which compare InetAddresses and use it when compareAddress(byte[], byte[]) returns 0 (same preference)

Result:

More correct primary MAC address detection
2014-03-21 12:32:26 +09:00
Trustin Lee
ff179c3430 Reduce the time taken by NetUtil and DefaultChannelId class initialization
Motivation:

As reported in #2331, some query operations in NetworkInterface takes much longer time than we expected.  For example, specifying -Djava.net.preferIPv4Stack=true option in Window increases the execution time by more than 4 times.  Some Windows systems have more than 20 network interfaces, and this problem gets bigger as the number of unused (virtual) NICs increases.

Modification:

Use NetworkInterface.getInetAddresses() wherever possible.
Before iterating over all NICs reported by NetworkInterface, filter the NICs without proper InetAddresses.  This reduces the number of candidates quite a lot.
NetUtil does not query hardware address of NIC in the first place but uses InetAddress.isLoopbackAddress().
Do not call unnecessary query operations on NetworkInterface.  Just get hardware address and compare.

Result:

Significantly reduced class initialization time, which should fix #2331.
2014-03-21 11:39:41 +09:00
Norman Maurer
afcc7fb7cc [#2326] Add constructor to NioServerSocketChannel which accepts a ServerSocketChannel
Motivation:
Allow the user to create a NioServerSocketChannel from an existing ServerSocketChannel.

Modifications:
Add an extra constructor

Result:
Now the user is be able to create a NioServerSocketChannel from an existing ServerSocketChannel, like he can do with all the other Nio*Channel implemntations.
2014-03-16 07:03:14 -07:00
Norman Maurer
9a11c43463 [#2323] Make it clear a Channel must be closed to release all resources
Motivation:
Ensure the user know the Channel must be closed to release resources like filehandles.

Modifications:
Add some extra javadoc.

Result:
More clear documentation
2014-03-16 07:02:57 -07:00
Norman Maurer
69d3cf5539 [#2308] Use SelectorProvider.open*() to open NIO channels and so remove condition when create new NIO channels.
Motivation:
At the moment we use SocketChannel.open(), ServerSocketChannel.open() and DatagramSocketChannel.open(...) within the constructor of our
NIO channels. This introduces a bottleneck if you create a lot of connections as these calls delegate to SelectorProvider.provider() which
uses synchronized internal. This change removed the bottleneck.

Modifications:
Obtain a static instance of the SelectorProvider and use SelectorProvider.openSocketChannel(), SelectorProvider.openServerSocketChannel() and
SelectorProvider.openDatagramChannel(). This eliminates the bottleneck as SelectorProvider.provider() is not called on every channel creation.

Result:
Less conditions when create new channels.
2014-03-13 07:00:33 +01:00
Norman Maurer
adcc2d4b4b Remove condition in ChannelHandlerAdapter.isSharable() by caching the result of the annotation lookup.
Motivation:
Remove the synchronization bottleneck and so speed up things

Modifications:
Introduce a ThreadLocal cache that holds mappings between classes of ChannelHandlerAdapater implementations and the result of checking if the @Sharable annotation is present.
This way we only will need to do the real check one time and server the other calls via the cache. A ThreadLocal and WeakHashMap combo is used to implement the cache
as this way we can minimize the conditions while still be sure we not leak class instances in containers.

Result:
Less conditions during adding ChannelHandlerAdapter to the ChannelPipeline
2014-03-12 12:31:52 +01:00
Norman Maurer
95ff172c82 Corrected inconsistencies in the Javadoc.
Port of 80030493b9f7824c02dc88260c2579afc0aed8bc
2014-03-04 06:34:50 +01:00
Norman Maurer
d3ffa1b02b [#1259] Add optimized queue for SCMP pattern and use it in NIO and native transport
This queue also produces less GC then CLQ when make use of OneTimeTask
2014-02-27 13:28:37 +01:00
Norman Maurer
8c68c5a3ae Fix check to clear READ_OP and EPOLLIN. Part of [#2254] 2014-02-22 20:06:52 +01:00
Norman Maurer
b32316b33c [#2254] Correctly handle Channel.read() and ChannelHandlerContext.read()
This includes also when it is called from channelRead(...) and channelReadComplete(...) methods.
2014-02-22 18:48:47 +01:00
Norman Maurer
47fab2bfe8 Directly use memory addresses for gathering writes to reduce gc pressure. Part of [#2239]
This also does factor out some logic of ChannelOutboundBuffer. Mainly we not need nioBuffers() for many
transports and also not need to copy from heap to direct buffer. So this functionality was moved to
NioSocketChannelOutboundBuffer. Also introduce a EpollChannelOutboundBuffer which makes use of
memory addresses for all the writes to reduce GC pressure
2014-02-21 13:37:33 +01:00
Norman Maurer
78db65d0fb [#2254] Fix regression in handling autoRead and Channel.read()
This regression was introduced by e0b39159657c9eb711047bc32367537c4870d467
2014-02-21 09:19:36 +01:00
Norman Maurer
1c9c797e82 Move marking ChannelPromise for writes uncancellable to addFlush for keep things simple 2014-02-17 16:16:08 +01:00
Trustin Lee
a0e74ff984 Use thread local direct buffer for I/O when the current allocator is unpooled
- Allocating and deallocating a direct buffer for I/O is an expensive
  operation, so we have to at least have a pool of direct buffers if the
  current allocator is not pooled
2014-02-15 11:24:01 -08:00
Trustin Lee
fbd4385506 Determine the default allocator from system property
- Add ByteBufAllocator.DEFAULT
- The default allocator is now 'pooled'
2014-02-14 13:04:12 -08:00
Trustin Lee
0e4c80b953 Fix IllegalStateException caused by ChannelHandlerAppender 2014-02-13 19:44:40 -08:00
Trustin Lee
c671103289 Deprecate CombinedChannelDuplexHandler in favor of ChannelHandlerAppender
- Fixes #2233
- Add ChannelHandlerAppender
2014-02-13 19:20:56 -08:00
Trustin Lee
7e1db4feb7 Deprecate CombinedChannelDuplexHandler in favor of ChannelHandlerAppender
- Fixes #2233
2014-02-13 19:20:25 -08:00
Trustin Lee
8837afddf8 Enable a user specify an arbitrary information with ReferenceCounted.touch()
- Related: #2163
- Add ResourceLeakHint to allow a user to provide a meaningful information about the leak when touching it
- DefaultChannelHandlerContext now implements ResourceLeakHint to tell where the message is going.
- Cleaner resource leak report by excluding noisy stack trace elements
2014-02-13 18:16:25 -08:00
Trustin Lee
0235244e55 Touch a ReferenceCounted while it traverses across a pipeline 2014-02-13 18:11:54 -08:00
Trustin Lee
45e70d9935 Add ReferenceCounted.touch() / Add missing retain() overrides
- Fixes #2163
- Inspector warnings
2014-02-13 18:10:11 -08:00
Trustin Lee
7e60877bc5 Merge the attribute map of ChannelHandlerContext into Channel
- Fixes #2136
- Also fixes some generics warnings
2014-02-13 18:02:44 -08:00
Trustin Lee
1d577a8d95 Get the PID properly on Android
- Related: #2109
2014-02-13 17:37:22 -08:00
Trustin Lee
d97f72d2c9 Fix a problem where DefaultChannelId prevents Netty 5 from running on Android
- Fixes #2109
- Use reflection to find the current PID
2014-02-13 17:35:44 -08:00
Trustin Lee
2b84314fdd Add Recycler.Handle.recycle() so that it's possible to recycle an object without an explicit reference to Recycler 2014-02-13 17:24:37 -08:00
Trustin Lee
df346a023b Change the return type of EmbeddedChannel.read*() from Object to an ad-hoc type parameter
.. so that there's no need to explicitly down-cast.

Fixes #2067
2014-02-13 17:19:26 -08:00
Vladimir Krivosheev
eb308cfff6 ability to use Executor instead of ThreadFactory 2014-02-13 16:14:41 -08:00
Trustin Lee
780516471f Bring back ChannelGroup.find(id) 2014-02-13 15:53:45 -08:00
Trustin Lee
40003ed250 Resurrect Channel.id() with global uniqueness
- Fixes #1810
- Add a new interface ChannelId and its default implementation which generates globally unique channel ID.
- Replace AbstractChannel.hashCode with ChannelId.hashCode() and ChannelId.shortValue()
- Add variants of ByteBuf.hexDump() which accept byte[] instead of ByteBuf.
2014-02-13 15:53:07 -08:00
Trustin Lee
812481602a Don't create an EmbeddedSocketAddress every time 2014-02-13 15:45:47 -08:00
Trustin Lee
499033d44f Add a shortcut method for collision-free naming 2014-02-13 15:17:09 -08:00
Trustin Lee
b533a1361b Replace UniqueName with Constant and ConstantPool
- Proposed fix for #1824

UniqueName and its subtypes do not allow getting the previously registered instance.  For example, let's assume that a user is running his/her application in an OSGi container with Netty bundles and his server bundle.  Whenever the server bundle is reloaded, the server will try to create a new AttributeKey instance with the same name.  However, Netty bundles were not reloaded at all, so AttributeKey will complain that the name is taken already (by the previously loaded bundle.)

To fix this problem:

- Replaced UniqueName with Constant, AbstractConstant, and ConstantPool.  Better name and better design.

- Sctp/Udt/RxtxChannelOption is not a ChannelOption anymore.  They are just constant providers and ChannelOption is final now.  It's because caching anything that's from outside of netty-transport will lead to ClassCastException on reload, because ChannelOption's constant pool will keep all option objects for reuse.

- Signal implements Constant because we can't ensure its uniqueness anymore by relying on the exception raised by UniqueName's constructor.
2014-02-13 15:14:34 -08:00
Trustin Lee
a65f097d53 Allow empty handler list when creating a new EmbeddedChannel
.. so that it can be used for dynamically initialized pipelines

- Fixes #1899
2014-02-13 14:46:33 -08:00
Norman Maurer
517da2b46a Fix checkstyle 2014-02-13 14:36:14 -08:00
Bill Gallagher
7e5aa4a911 use enum for state in LocalChannel 2014-02-13 14:35:58 -08:00
Bill Gallagher
a19fe06928 use enum for state in EmbeddedChannel 2014-02-13 14:34:51 -08:00
Trustin Lee
449ce0dd7a Remove the irrelevant AIO channel options 2014-02-13 13:59:12 -08:00
Norman Maurer
69a36b8bea Prettify exception message 2014-02-13 06:46:51 +01:00
Norman Maurer
62ebe88981 Allow to set IoRatio to 100% 2014-02-12 15:22:39 +01:00
Norman Maurer
80e6f9adf4 Correctly respect isAutoRead() and make it consistent across OIO/NIO 2014-02-11 20:46:46 +01:00
Norman Maurer
7041a9238e Allow to cancel non-flushed writes 2014-02-11 19:42:49 +01:00
Trustin Lee
d52dc3b740 Do not warn if failed to mark a void promise as success
- it's always supposed to fail.
2014-02-10 15:03:46 -08:00
Trustin Lee
96b0a949e1 Make most outbound operations cancellable / More robust promise update
- Inspired by #2214 by @normanmaurer
- Call setUncancellable() before performing an outbound operation
- Add safeSetSuccess/Failure() and use them wherever
2014-02-10 14:57:18 -08:00
Trustin Lee
041d37e0c8 Make most outbound operations are cancellable
- Inspired by #2214
- It actually reduces the chance of trying to marking a cancelled promise as success again, which raises an IllegalStateException.
2014-02-10 14:06:54 -08:00
Norman Maurer
87602fde25 [#2215] DefaultChannelHandlerContext tasks needs to be volatile to ensure every thread only see full initialized instances 2014-02-08 10:33:44 +01:00
Norman Maurer
9bee78f91c Provide an optimized AtomicIntegerFieldUpdater, AtomicLongFieldUpdater and AtomicReferenceFieldUpdater 2014-02-06 20:08:45 +01:00
Norman Maurer
64c3f58279 Not wakeup the EventLoop for writes as they will not cause a flush anyway 2014-02-01 13:45:27 +01:00
Norman Maurer
f94b563bcd Better exception message to tell the user why it is not supported 2014-01-30 07:02:22 +01:00
Norman Maurer
80ed147652 [#2164] Only reregister SelectionKeys that are still valid 2014-01-29 07:18:29 +01:00
Trustin Lee
9b0e5b9148 Fix API documentation on the usage of AttributeKey 2014-01-28 13:59:11 +09:00
William Kemper
39b8cc348a fix grouping for isActive - socket.isBound is almost always true and should not override 'isOpen' 2014-01-17 07:14:00 +01:00
Trustin Lee
237ba27499 Better exception message 2014-01-13 23:32:49 +09:00
Norman Maurer
13d65d7ccf [#2104] Make sure we only act on the SelectionKey if it is valid 2014-01-09 18:27:56 +01:00
Trustin Lee
751943ed00 Fix a potential NPE due to the race between a connection attempt and its cancellation
- should fix #2086
2014-01-09 19:24:44 +09:00
Norman Maurer
0bbc3facec [#2086] Fix race which could produce NPE in AbstractNioUnsafe.finishConnect 2014-01-09 08:22:34 +01:00
milenkovicm
393f7b2306 ChannelOutboundBuffer returns total pending write size
total pending write size may be used to optimize write batching
2014-01-07 06:52:07 +01:00
Veebs
dd8f4bc0c4 Fix typo 2014-01-03 11:15:14 +01:00
Norman Maurer
fc2e6916d9 Fix regression which was introduced by 89a7cb8e71
Related to [#2060]
2013-12-21 21:39:51 +01:00
Trustin Lee
bab227213e Increase the default maxMessagesPerRead of AbstractNioByteChannel to 16
- Related: #2079
2013-12-21 20:08:42 +09:00
Trustin Lee
1fcd19a28f Fix a bug where adaptive recvbuf size prediction doesn't work correctly when maxMessagesPerRead is > 1 2013-12-21 19:57:11 +09:00
Norman Maurer
b889d3f559 [#2079] Stop reading once the NIO byte Channel was complete drained 2013-12-21 10:38:07 +01:00
Trustin Lee
89a7cb8e71 More graceful registration failure
- Fixes #2060
- Ensure to return a future/promise implementation that does not fail with 'not registered to an event loop' error for registration operations
- If there is no usable event loop available, GlobalEventExecutor.INSTANCE is used as a fallback.
2013-12-21 18:08:58 +09:00
Trustin Lee
ceaebd37ed Rename flushAndWrite() to writeAndFlush()
- Fixes: #2066
- Fixed inspection warnings
2013-12-16 15:02:13 +09:00
Trustin Lee
82b6e75b96 Rename flushAndWrite() to writeAndFlush()
- Related: #2066
2013-12-16 14:58:40 +09:00
Norman Maurer
e136227ee6 [#2065] Fix NPE in AbstractOioByteChannel during write to the socket 2013-12-15 11:41:04 +01:00
Trustin Lee
4116de8360 Fix NoSuchElementException raised by ChannelInitializer
.. again.
2013-12-07 11:04:40 +09:00
Trustin Lee
02703e8fc1 Revert "Fix NoSuchElementException raised by ChannelInitializer"
This reverts commit 3c453f5dba.
2013-12-07 11:04:33 +09:00
Trustin Lee
51428004b3 Fix NoSuchElementException raised by ChannelInitializer 2013-12-07 00:39:21 +09:00
Norman Maurer
7ec70d0210 Merge package private interfaces into public ones. Related to [#1989] and [#1991] 2013-11-25 10:37:34 +01:00
Trustin Lee
fd776274c9 Additional fix for potential race condition which occurs when a user cancels a connection attempt
- Fixes #1986
2013-11-18 17:00:43 +09:00
Trustin Lee
54d3c99469 Fix an unexpected IllegalStateException from a selector loop when a user cancels a connection attempt
- Fixes #1986
2013-11-18 16:33:21 +09:00
Trustin Lee
ec10409314 Saner toString() implementation for EmbeddedSocketAddress 2013-11-08 18:04:40 +09:00
Norman Maurer
7dddbbb2bd Fix possible leak when a write is rejected 2013-11-07 10:24:15 +01:00
Norman Maurer
77054d7ecb Fix regression which lead to leak buffers when nothing could be read from the Channel.
This was introduced as part of #1812, but fortunatualy was not part of any release.
2013-11-07 07:12:19 +01:00
Trustin Lee
d2032254b7 Enable AUTO_CLOSE opton by default for backward compatibility / Deprecare AUTO_CLOSE option because it's gone in 5.0.
- Related #1952
2013-11-05 17:40:23 +09:00
Trustin Lee
c7b66545b4 Add AUTO_CLOSE option
- Fixes #1952
- If AUTO_CLOSE is turned on, Netty will close the channel immediately and automatically on write failure.  The default is false.
2013-11-05 17:24:36 +09:00
Trustin Lee
54db9ec725 Use StringUtil.simpleClassName(..) instead of Class.getSimpleName() where necessary
- Class.getSimpleName() doesn't render anonymous classes very well
- + some minor cleanup
2013-11-04 19:46:15 +09:00
Norman Maurer
e9967e55ad [#1940] Add javadoc to explain how the FileChannel is closed when using DefaultFileRegion 2013-11-02 15:59:33 +01:00
Trustin Lee
e1baa3f9b4 Simplify 2013-11-02 20:03:41 +09:00
Trustin Lee
72c78ebe75 Add an important notice about future migration issue in SimpleChannelInboundHandler.
- Related: #1590
2013-11-02 20:03:15 +09:00
Norman Maurer
b53fa5dd70 [#1812] All to have NioMessageUnsafe.read() inlined 2013-10-26 17:44:25 +02:00
Trustin Lee
8986245b47 Deprecate UniqueName and its subtypes' constructors / Add valueOf() for easier future migration. 2013-10-25 20:53:47 +09:00
Norman Maurer
544d68b396 [#1812] Allow for inline for most common cases when use NioByteUnsafe.read() 2013-10-25 13:32:21 +02:00
Norman Maurer
e4358ae6b8 [#1947] Handle RejectExecutionException graceful for outbound operations 2013-10-25 07:51:17 +02:00
Norman Maurer
9fd8bf329d More efficient handling of incomplete writes.
The problem with the old way was that we always set the OP_WRITE when the buffer could not be written
until the write-spin-count was reached. This means that in some cases the channel was still be writable
but we just was not able to write out the data quick enough. For this cases we should better break out the
write loop and schedule a write to be picked up later in the EventLoop, when other tasks was executed.
The OP_WRITE will only be set if a write actual returned 0 which means there is no more room for writing data
and this we need to wait for the os to notify us.
2013-10-17 20:23:47 +09:00
Norman Maurer
53fcff2eab [#1920] Fix IndexOutOfBoundsException when using PooledByteBufAllocator with SCTP and NIO Datagram channels 2013-10-16 09:53:26 +02:00
Norman Maurer
df442b9b6a #1924] Only log RejectExecutorException when call invokeLater(...) 2013-10-15 15:22:46 +02:00
Norman Maurer
068c75a025 [#1924] Correctly fail promise when EventExecutor was shutdown in between deregister 2013-10-15 14:01:59 +02:00
Trustin Lee
c9b7f1f1b5 Ensure the selector implementation can be instrumented before attempting instrumentation
- Fixes #1908
2013-10-11 12:08:51 +09:00
Trustin Lee
d7f9b1ee76 Fixes the problem where the promise of the outbound operation that causes a channel closure is notified after channelInactive()
- Fixes #1897
2013-10-08 12:24:16 +09:00
Norman Maurer
c0936fc8e7 [#1890] Correctly expand ByteBuffer array in all cases
The problem was that we did not handle the case correctly when doubling the array was not enough. We need to keep doubling until everything fits in.
2013-10-06 15:29:35 +02:00
Bill Gallagher
013ac44d3a [#1832] - Channel writability change notifications sometimes fail to fire 2013-09-30 20:01:39 +02:00
Norman Maurer
b4fa8af079 Cache underlying ByteBuffers and count in ChannelOutboundBuffer.Entry to reduce object creation and so GC pressure
Beside this it also helps to reduce CPU usage as nioBufferCount() is quite expensive when used on CompositeByteBuf which are
nested and contains a lot of components
2013-09-26 20:37:39 +02:00
Norman Maurer
ae904a1f56 Introduce a new ChannelOption called DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION. Related to [#1830]
This ChannelOption allows to tell the DatagramChannel implementation to be active as soon as they are registrated to their EventLoop. This can be used to make it possible to write to a not bound DatagramChannel.
The ChannelOption is marked as @deprecated as I'm looking for a better solution in master which breaks default behaviour with 4.0 branch.
2013-09-24 11:46:49 +02:00
Sasha Zverev
a2624a833e Slip in DefaultOioSocketChannelConfig (setAllowHalfClosure used to ignore argument) 2013-09-21 20:13:52 +02:00
Norman Maurer
f034f90fb3 [#1836] Add comment to explain why read is triggered 2013-09-17 06:58:47 +02:00
Norman Maurer
357677d8fa [#1830] Add testcase for write to not bound DatagramChannel impls and revert change in OIO as it breaks things as the udnerlying socket lazy binds 2013-09-12 09:27:43 +02:00
Norman Maurer
f4f04a08c2 Make DatagramChannel impls .isActive() return true when the underlying Channel is open. This also fixes [#1830] 2013-09-11 20:37:21 +02:00
Norman Maurer
7d9388a3cc Allow to only register a Channel via AbstractBootstrap and bind/connect it later. Related to [#1829] 2013-09-11 20:14:53 +02:00
Norman Maurer
af499b5fb4 Mark ChannelHandler.exceptionCaught(...) as deprecated in preparation to move to ChannelInboundHandler. Related to [#1808] 2013-09-08 20:11:51 +02:00
Trustin Lee
ad0c456209 Ensure operationProgressed is invoked even on completion
- Fixes #1809
2013-09-05 18:37:14 +09:00
Norman Maurer
92cec8d2ac Split up the nioBuffers() method to allow for inline. Related to #1812
This move less common method patterns to extra methods and so make the nioBuffers() method with most common pattern (backed by one ByteBuffer) small enough for inlining.
2013-09-05 09:22:13 +02:00
Norman Maurer
c97971b53a [#1805] Fix example in javadocs of SimpleChannelInboundHandler 2013-09-03 20:30:56 +02:00
Norman Maurer
25c226a835 Make sure only direct ByteBuffer are passed to the underlying jdk Channel.
This is needed because of otherwise the JDK itself will do an extra ByteBuffer copy with it's own pool implementation. Even worth it will be done
multiple times if the ByteBuffer is always only partial written. With this change the copy is done inside of netty using it's own allocator and
only be done one time in all cases.
2013-09-02 20:17:53 +02:00
Norman Maurer
4a5c840271 @Deprecated ChannelOutboundHandler.deregister(...) 2013-09-01 12:54:29 +02:00
Norman Maurer
b8866aef33 No need to check instanceof everytime to find the next inbound / outbound context 2013-08-30 06:31:58 +02:00
Norman Maurer
32deb2c22b [#1785] Fix incorrect javadocs 2013-08-27 06:55:14 +02:00
Norman Maurer
5e9b199296 @deprecated all methods which are related to deregister as it will be removed in 4.1.0.Final 2013-08-26 11:36:56 +02:00
Norman Maurer
80d30c3dd8 Small code improvements 2013-08-26 07:52:47 +02:00
Norman Maurer
77d4222db5 [#1777] Use correct Thread when close per channel 2013-08-25 21:22:53 +02:00
Norman Maurer
f76c01c3aa [#1782] Fix IndexOutOfBoundException with direct buffer and gathering writes 2013-08-24 18:16:05 +02:00
Trustin Lee
7aefd0cbdb Make AbstractBootstrap public
.. to work around the issue with JDK reflection described here:

  http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4283544

Fixes #1780
2013-08-24 17:20:53 +09:00
Norman Maurer
206dc2a391 [#1772] Make sure ChannelOutboundBuffer.recycle() does also reset unflushed, flushed and tail.
This fix a IndexOutOfBoundsException which as triggered if recycle() did cut down the buffer[] to the initial size.
2013-08-23 09:01:16 +02:00
Norman Maurer
9fd35d09a2 [#1770] Fix NPE which was thrown if connection timeout was disabled and the connect did not finish directly when using NIO 2013-08-22 12:38:56 +02:00
bgallagher
6a2f340ec0 trim buffers before recycling 2013-08-21 20:28:54 +02:00
bgallagher
fb619f2394 fix writability callback 2013-08-21 16:39:50 +02:00
Norman Maurer
217b8e255c [#1763] Fill ChannelOutboundBuffer.nioBuffers with null on close to allow the content to be GC'ed 2013-08-20 21:15:05 +02:00
Trustin Lee
caf91b9c06 Fix IllegalStateException triggered while shutting down ThreadPerChannelEventLoopGroup
- Fix #1718
- Add the test case contributed by @mkw
2013-08-20 14:37:57 +09:00
bgallagher
a383988cdb add struct to replace parallel arrays consolidate flushed & unflushed buffers 2013-08-18 19:19:57 +02:00
bgallagher
06e250e493 remove unused initialCapacity 2013-08-17 14:10:33 +02:00
bgallagher
9f88552f12 remove some dead code 2013-08-10 20:46:48 +02:00
Norman Maurer
280afda013 [#1715] Remove extra call socket.configureBlocking(false) 2013-08-10 20:33:19 +02:00
bgallagher
59c2fd8813 [#1723] invoke close in eventloop 2013-08-10 08:19:16 +02:00
Norman Maurer
9d8c4ded50 Move method in correct scope 2013-08-09 13:30:04 +02:00
Norman Maurer
4d0621855a Remove unused package private method and so remove some complexity 2013-08-09 11:44:41 +02:00
Norman Maurer
b54937ab50 [#1711] Allow to use ChannelOption for set / get MessageSizeEstimator 2013-08-08 20:37:35 +02:00
Norman Maurer
f40a3f34b1 [#1692] Allow to set WRITE_BUFFER_HIGH_WATER_MARK and WRITE_BUFFER_LOW_WATER_MARK via ChannelOption 2013-08-08 20:30:01 +02:00
Norman Maurer
fc6213604d Make sure ChannelOutboundBuffer not throw NPE during increment/decrement pending writes 2013-08-08 13:42:25 +02:00
Norman Maurer
b934b6009c Share some code, related to [#1707]] 2013-08-07 20:28:33 +02:00
Norman Maurer
5ef30b6d8b [#1707] More efficient implementation of ChannelHandlerContext.writeAndFlush(..) 2013-08-07 20:15:10 +02:00
Norman Maurer
5b6e762bf4 Allow to have the Channel GC'ed ASAP 2013-08-07 10:32:03 +02:00
Norman Maurer
48a7a21541 Correctly update Channel.isWritable() when the write happens from outside the EventLoop in a fast fashion. Fixes [#1697]
Introduce a new interface called MessageSizeEstimator. This can be specific per Channel (via ChannelConfig). The MessageSizeEstimator will be used to estimate for a message that should be written. The default implementation handles ByteBuf, ByteBufHolder and FileRegion. A user is free to plug-in his/her own implementation for different behaviour.
2013-08-07 10:10:43 +02:00
Norman Maurer
de44917e62 Use recyclable write task to reduce GC pressure 2013-08-05 14:59:58 +02:00
Trustin Lee
17b91f416d Remove an irrelevant comment
.. because firedChannelActive is gone long ago
2013-08-05 16:50:25 +09:00
Norman Maurer
a06295fe0a Correctly fix problem in ByteToMessageDecoder and ReplayingDecoder which could let to have a released buffer passed to the decode methods.
This fixes #1664 and revert also the original commit which was meant to fix it 3b1881b523 . The problem with the original commit was that it could delay handlerRemove(..) calls and so mess up the order or forward bytes to late.
2013-08-01 09:54:07 +02:00
Trustin Lee
81de2275e4 Remove unnecessary traversal of pipeline which occurs when a Channel is closed
- Remove unnecessary ascending traversal of pipeline in DefaultChannelHandlerContext.freeInbound()
- Move DefaultChannelHandlerContext.teardownAll() to DefaultChannelPipeline
2013-07-31 20:45:37 +09:00
Trustin Lee
3b1881b523 Make sure ChannelHandler.handlerRemoved() is invoked while handler methods are not running
- Fixes #1664
2013-07-31 20:35:51 +09:00
Norman Maurer
3049f5ddc4 Fix checkstyle 2013-07-31 12:21:50 +02:00
Trustin Lee
c79a3cdefe Fix a bug in NioSocketChannel.doWrite() where flush() triggered from a ChannelFutureListener is ignored
- Fixes #1679
2013-07-31 19:13:45 +09:00
Norman Maurer
ca29f1a37d [#1683] Mark unused ChannelOption @deprecated, to prepare for removal in 4.1.0.Final 2013-07-31 10:50:39 +02:00
Trustin Lee
e81368af06 Simplify handler invocations in DefaultChannelHandlerContext
- Sometimes we delegated executor.inEventLoop() to the next context and sometimes we did not.  Now we always check inEventLoop() before delegating.
2013-07-31 16:34:32 +09:00
Norman Maurer
e09aea5902 Rename methods of EmbeddedChannel and mark old ones as @deprecated 2013-07-31 16:04:08 +09:00
Jeff Pinner
3922c518cd Clean up AbstractUnsafe#bind and AbstractUnsafe#disconnect. 2013-07-29 06:54:42 +02:00
Jeff Pinner
bf2430d255 Change AbstractChannel#doRegister return type from Runnable to void. 2013-07-27 20:22:02 +02:00
Jeff Pinner
ca59c1201e Change AbstractChannel#doDeregister return type from Runnable to void. 2013-07-26 22:21:41 +02:00
Norman Maurer
15279b2525 [#1654] Notify close future after the close was complete 2013-07-26 14:21:11 +02:00
Norman Maurer
cffbba94ee [#1654] Remove AbstractChannel.doPreClose() and notify close future on register failure. Based on patch of @jpinner 2013-07-26 14:10:31 +02:00
Norman Maurer
5f363e8ade Revert "remove AbstractChannel#doPreClose"
This reverts commit 241f856cc7.
2013-07-26 11:23:11 +02:00
Jeff Pinner
241f856cc7 remove AbstractChannel#doPreClose 2013-07-26 10:12:01 +02:00
Norman Maurer
fabefba791 [#1650] Make it possible to override isSharable() to simplify things for clojure users 2013-07-25 20:24:27 +02:00
Norman Maurer
6ff87cc20d Small optimitation to limit volatile reads 2013-07-25 09:28:54 +02:00
Trustin Lee
5e4169802f Fix potential reentrance issue in ChannelOutboundBuffer 2013-07-24 11:26:03 +09:00
Norman Maurer
0b17586731 [#1623] Fix javadocs for ChannelGroup 2013-07-23 09:03:42 +02:00
Trustin Lee
7903697c36 Remove Arrays.fill(..., null)
.. because we can just set each element to null while looping
2013-07-23 15:09:14 +09:00
Trustin Lee
a89b17fa94 Merge ChannelOutboundBuffer.failUnflushed() and recycle() into a single method and make sure it is run later on reentrance
- Previously, failUnflushed() did not run when inFail is true, which made unflushed writes are not released on reentrance.   This has been fixed by this commit.
- Also, AbstractUnsafe.outboundBuffer is set to null as early as possible to remove the chance of any write attempts made after the closure.
2013-07-23 14:34:10 +09:00
Trustin Lee
d4aa5b53d6 Simplify the validation logic proposed in 25f96b1644 2013-07-23 13:48:22 +09:00
kerr
ada07cb9e0 Fix types in javadocs 2013-07-22 19:14:36 +02:00
Norman Maurer
25f96b1644 [#1606] Reduce overhead during writes because of ChannelPromise validation 2013-07-22 11:28:02 +02:00
Norman Maurer
81612f8e9b [#1624] Fix resource leak when writing to a closed / not-open channel 2013-07-22 10:59:06 +02:00
Norman Maurer
0f6cc0cc7b [#1630] Fix re-entrance bug in ChannelOutboundBuffer.remove(...) 2013-07-22 10:44:33 +02:00
tsingxu
125070958d Fix up ChannelPipeline javadocs by add lost "don't " 2013-07-22 07:14:42 +02:00
Norman Maurer
7f86550ef8 [#1619] Fix bug in ChannelOutboundBuffer which could lead to invalid write order when fireChannelWritabilityChanged() write another message 2013-07-20 10:03:53 +02:00
Norman Maurer
60529ac3ee Fix checkstyle 2013-07-20 08:09:08 +02:00
Jeff Pinner
6c9c151d66 minor documentation cleanup 2013-07-20 08:01:14 +02:00
Norman Maurer
4d69848aec Fix broken javadocs 2013-07-19 07:40:12 +02:00
Trustin Lee
19c92ceb59 Separate 'progress total' and 'pending number of bytes'
- Reverted the recent changes in AbstractChannel.calculateMessageSize()
2013-07-19 14:09:08 +09:00
Trustin Lee
762adfcb69 Update HttpStaticFileServer example / Fix bugs related with progress notification
- Fix a bug in DefaultProgressivePromise.tryProgress() where the notification is dropped
 - Fix a bug in AbstractChannel.calculateMessageSize() where FileRegion is not counted
 - HttpStaticFileServer example now uses zero copy file transfer if possible.
2013-07-19 13:21:32 +09:00
Trustin Lee
f96a8e5951 Implement ProgressivePromise notification in NIO byte channels and ChunkedWriteHandler
- Refine the contract of GenericProgressiveFutureListener.
- Negative 'total' now means 'unknown', which is useful for ChunkedWriteHandler.
2013-07-19 12:53:23 +09:00
Trustin Lee
0653efcd75 Even better promise validation messages 2013-07-19 09:38:25 +09:00
Trustin Lee
d5e202d755 Better promise validation messages 2013-07-19 09:37:56 +09:00
Trustin Lee
faf8b76b5a Fix a potential bug where AbstractUnsafe.flush0() fails to clear the inFlush0 flag
- Fixes #1609
2013-07-19 08:56:17 +09:00
Trustin Lee
8178322c5c A little bit of Javadoc for ChannelOutboundBuffer 2013-07-19 01:17:00 +09:00
Trustin Lee
fef838f197 Make sure channelInactive() and channelDeregistered() are triggered even if outboundBuffer.recycle() fails 2013-07-19 01:09:19 +09:00
Trustin Lee
8828d5327a Move inFlush0 and outboundBuffer in AbstractChannel to AbstractUnsafe
.. because they are accessed by AbstractUnsafe much more often.
2013-07-18 23:33:39 +09:00
Trustin Lee
5e5df6bd09 Fix NPE 2013-07-18 23:29:13 +09:00
Trustin Lee
4cd7e62555 Make ChannelOutboundBuffer recycled 2013-07-18 23:26:45 +09:00
Trustin Lee
46ea0d4e7b Implement gathering writes in NioSocketChannel
- Add some support methods in ChannelOutputBuffer
2013-07-18 23:14:39 +09:00
Trustin Lee
4f0a952241 Checkstyle 2013-07-18 21:01:01 +09:00
Trustin Lee
bcef796dc7 Rewrite ChannelOutboundBuffer
- Merge MessageList into ChannelOutboundBuffer
- Make ChannelOutboundBuffer a queue-like data structure so that it is nearly impossible to leak a message
- Make ChannelOutboundBuffer public so that AbstractChannel can expose it to its subclasses.
- TODO: Re-enable gathering write in NioSocketChannel
2013-07-18 20:59:14 +09:00
Trustin Lee
568166d554 Cleanup 2013-07-18 10:29:34 +09:00
Trustin Lee
e28594952b Make the cleanup logic in ChannelOutboundBuffer more robust
- Fixes #1601
2013-07-18 10:23:26 +09:00
Trustin Lee
9c8d980a74 Fix a bug where a ChannelFutureListener can allow Unsafe.close() and Unsafe.flush() to overlap and reenter from flush() to close().
- Fixes #1600
2013-07-18 10:14:55 +09:00
Trustin Lee
88cbdb50d2 Fail unflushed writes with ClosedChannelException
... instead of cryptic exception message.
2013-07-17 21:25:51 +09:00
Trustin Lee
cc9b9567b9 Make sure all write attempts made after a channel is closed are marked as failure 2013-07-17 21:14:07 +09:00
Trustin Lee
a8d67b0282 Fix data structure corruption and resource leak in ChannelOutboundBuffer 2013-07-17 21:02:56 +09:00
Trustin Lee
dcf7896172 Do not close ServerChannel on IOException while accepting an incoming connection
.. so that we can recover from 'too many open files'

- Fixes #1578
2013-07-16 18:39:29 +09:00
Norman Maurer
2de491aa7f Use UnpooledByteBufAllocator as default 2013-07-15 10:44:33 +02:00
Norman Maurer
d5f052f39c Rename ChannelGroupMatcher to ChannelMatcher 2013-07-15 10:42:36 +02:00
Norman Maurer
9dfad35423 Fix checkstyle 2013-07-14 18:32:10 +02:00
Norman Maurer
75997545ed Fix checkstyle 2013-07-14 18:13:47 +02:00
Norman Maurer
c20c852602 More javadoc fixes 2013-07-14 18:04:33 +02:00
Norman Maurer
43d22f6d23 Remove unused class which was package private anyway 2013-07-14 17:54:07 +02:00
Norman Maurer
a07abee55f Add and correct javadocs 2013-07-13 19:42:02 +02:00
Norman Maurer
2af7db361b [#1573] Fix NPE which could be triggered one failed promises that trigger a close89 2013-07-12 22:57:03 +02:00
Norman Maurer
2871079c4a [#1557] Make the contract of Channel.Unsafe.flush() more clear
* Remove boolean parameter from Channel.Unsafe.flush() method
* Move NIO related things to AbstractNioChannel.NioUnsafe
2013-07-12 19:45:31 +02:00
Trustin Lee
660729bd56 Kill the cruft 2013-07-12 20:41:29 +09:00
Trustin Lee
456994607b || -> && 2013-07-12 20:32:49 +09:00
Trustin Lee
99716993f6 Add a boolean parameter to Channel.Unsafe.flush() so that SelectionKey state check can be bypassed. 2013-07-12 20:14:50 +09:00
Trustin Lee
e10e9d38c4 Fix embarassing compilation error :-/ 2013-07-12 20:12:18 +09:00
Trustin Lee
85a2ba3752 Remove dead code
- Fixed #1557
2013-07-12 20:10:39 +09:00
Trustin Lee
6d1220b55e Reduce garbage in AbstractUnsafe.flush0() 2013-07-12 20:04:01 +09:00
Trustin Lee
529d904d29 Fix a bug where ChannelOutboundBuffer.addFlush() is called multiple times 2013-07-12 20:01:38 +09:00
Trustin Lee
e2fcb06d9a Remove unnecessary try-catch block in AbstractUnsafe.flush() 2013-07-12 20:00:30 +09:00
Norman Maurer
43f12569aa Cache flush(..) tasks which are used when executing with different EventExecutor to lower GC pressure 2013-07-12 11:57:33 +02:00
Norman Maurer
aa64c13bb8 Cleanup 2013-07-12 11:48:26 +02:00
Norman Maurer
d23c3b3382 Introduce ChannelGroupMatcher which can be used to only apply operations of a ChannelGroup on matching Channels.
This is often useful if you for example use a ChannelGroup to hold all connected Channels and want to broadcast a message too all of them
except one Channel.
2013-07-11 10:58:53 +02:00
Norman Maurer
12ea35fd5f Add missing javadocs 2013-07-11 10:26:10 +02:00
Jeff Pinner
224f05e626 Use correct permission mode for java files 2013-07-10 21:58:12 +02:00
Trustin Lee
b7a7c33fe3 Fix a bug in ChannelOutboundBuffer.addFlush()
It should not advance the tail if no write() was issued so far.
2013-07-11 01:05:26 +09:00
Norman Maurer
b57d9f307f Allow per-write promises and disallow promises on flush()
- write() now accepts a ChannelPromise and returns ChannelFuture as most
  users expected.  It makes the user's life much easier because it is
  now much easier to get notified when a specific message has been
  written.
- flush() does not create a ChannelPromise nor returns ChannelFuture.
  It is now similar to what read() looks like.
2013-07-11 00:49:48 +09:00
Norman Maurer
dd763698dc Adjust ChannelGroup to behave the same like a Channel in terms of write and flush 2013-07-10 08:27:11 +02:00
Trustin Lee
7bedd8f28e Simplify the exception handling of ChannelOutboundHandler.write()
DefaultChannelHandlerContext does not trigger exceptionCaught() immediately when ChannelOutboundHandler.write() raises an exception.  It just records the exception until flush() is triggered.  On invokeFlush(), if there's any exception recorded, DefaultChannelHandlerContext will fail the promise without calling ChannelOutboundHandler.flush().  If more than one exception were raised, only the first exception is used as the cause of the failure and the others will be logged at warn level.
2013-07-10 00:36:47 +09:00
Trustin Lee
26e9d70457 Remove channelReadSuspended / Rename messageReceived(Last) to channelRead(Complete)
- Remove channelReadSuspended because it's actually same with messageReceivedLast
- Rename messageReceived to channelRead
- Rename messageReceivedLast to channelReadComplete

We renamed messageReceivedLast to channelReadComplete because it
reflects what it really is for.  Also, we renamed messageReceived to
channelRead for consistency in method names.
2013-07-09 23:58:51 +09:00
Trustin Lee
cbd8817905 Remove MessageList from public API and change ChannelInbound/OutboundHandler accordingly
I must admit MesageList was pain in the ass.  Instead of forcing a
handler always loop over the list of messages, this commit splits
messageReceived(ctx, list) into two event handlers:

- messageReceived(ctx, msg)
- mmessageReceivedLast(ctx)

When Netty reads one or more messages, messageReceived(ctx, msg) event
is triggered for each message.  Once the current read operation is
finished, messageReceivedLast() is triggered to tell the handler that
the last messageReceived() was the last message in the current batch.

Similarly, for outbound, write(ctx, list) has been split into two:

- write(ctx, msg)
- flush(ctx, promise)

Instead of writing a list of message with a promise, a user is now
supposed to call write(msg) multiple times and then call flush() to
actually flush the buffered messages.

Please note that write() doesn't have a promise with it.  You must call
flush() to get notified on completion. (or you can use writeAndFlush())

Other changes:

- Because MessageList is completely hidden, codec framework uses
  List<Object> instead of MessageList as an output parameter.
2013-07-09 23:51:48 +09:00
Trustin Lee
7396f9f2b2 Remove Channel.id completely / Use 64-bit hashCode internally to reduce the chance of collision in compareTo() 2013-07-09 14:49:06 +09:00
Norman Maurer
9c1b31d20a [#1535] Remove Channel.id() and so fix the possible leakage of the previous used Channel id map
The user can still use Channel.hashCode() for logging. It's just not 100% unique but should be good enough for most cases
2013-07-08 14:07:18 +02:00
Norman Maurer
39b57b889c [#1539] Fix bug in DefaultChannelGroup.close() which was blocking the close() call on ServerChannel 2013-07-08 13:36:39 +02:00
Trustin Lee
a52ac692a9 Faster MessageList iteration in NioSocketChannel.doWrite() 2013-07-07 15:15:52 +09:00
Trustin Lee
2b2f8db5d2 Use ThreadLocalRandom where possible 2013-07-07 12:37:36 +09:00
Norman Maurer
086ae3536c [#1533] Introduce ByteBufHolder.duplicate() and make use of it in DefaultChannelGroup.write(...) 2013-07-06 21:17:51 +02:00
Trustin Lee
b7e6a86c1e Add MessageList.first() and last() for convenience.
- Fixes #1530
2013-07-05 14:07:51 +09:00
Trustin Lee
0b9235f072 Simplify ByteBufProcessor and MessageListProcessor and Add internal component accessors to CompositeByteBuf
- Fixes #1528

It's not really easy to provide a general-purpose abstraction for fast-yet-safe iteration. Instead of making forEachByte() less optimal, let's make it do what it does really well, and allow a user to implement potentially unsafe-yet-fast loop using unsafe operations.
2013-07-05 14:00:46 +09:00
Norman Maurer
2bda1b530a [#1523] Fix bug which lead to have SelectedKeys handled two times and so caused a NPE on heavy load 2013-07-04 16:15:33 +02:00
Norman Maurer
08b75e594c [#1519] VoidChannelPromise don't fire CancellationException anymore which was incorrect 2013-07-04 09:32:38 +02:00
Norman Maurer
cea873286e [#1517] Only fire the exception throught the pipeline if the channel is registered when using VoidChannelPromise 2013-07-04 09:20:24 +02:00
Trustin Lee
998b408db3 Fix NPE in OioByteStreamChannel
- Do not assign null to 'is' and 'os' but assign an alternative stream implementation
2013-07-04 12:04:28 +09:00
Norman Maurer
7ec12d327f Remove deprecated ByteBufUtil.release(..) and ByteBufUtil.retain(..) methods and its usage. Also fix a problem where an object would have been released two times.
* The problem with the release(..) calls here was that it would have called release on an unsupported message and then throw an exception. This exception will trigger ChannelOutboundBuffer.fail(..), which will also try to release the message again.
* Also use the same exception type for unsupported messages as in other channel impls.
2013-07-03 10:00:13 +02:00
Trustin Lee
956c0f8b90 Better explanation of reentrance issue of ChannelOutboundBuffer 2013-07-02 17:22:56 +09:00
Norman Maurer
5437835832 [#1501] Fix NPE correctly which could accour if ChannelOutboundBuffer.fail(..) triggered another call to ChannelOutboundBuffer.fail(...) 2013-07-02 09:58:41 +02:00
Norman Maurer
8dfbcbda29 [#1501] Fix NPE which could accour if ChannelOutboundBuffer.fail(..) triggered another call to ChannelOutboundBuffer.fail(...) 2013-07-02 09:32:34 +02:00
Trustin Lee
efd9c94775 Use higher maxMessagesPerRead as default for ServerChannels
- Fixes #1493
2013-07-02 10:20:15 +09:00
Trustin Lee
26b56d3add Fix a bug in MessageList.add(T[])
- where it uses incorrect source index while iteration
2013-07-02 10:11:17 +09:00
Trustin Lee
720de2e6cc Add missing sanity check for DefaultChannelHandlerContext.write(...) 2013-07-02 09:36:01 +09:00
Trustin Lee
4b11aff08f Less confusing log messages for system properties
- Fixes #1502
2013-07-02 09:23:29 +09:00
Norman Maurer
5d88c423df [#1500] Remove @deprecated methods 2013-07-01 08:53:02 +02:00
Norman Maurer
617ab6321b [#1489] Correctly handle channelReadSuspended and channelWritabilityChanged in CombinedChannelDuplexHandler 2013-06-30 17:18:33 +02:00
Trustin Lee
ea963c25c9 Improve Javadoc of ChannelPipeline
- Fixes #1226
2013-06-28 22:09:00 +09:00
Trustin Lee
5f1aa6afde Remove potentially misleading exception message
.. because the MessageList itself is not read-only.
2013-06-28 21:25:15 +09:00
Trustin Lee
591dce565a checkExclusive() -> checkIndex() 2013-06-28 21:17:18 +09:00
Trustin Lee
d4665f1703 Fix test failures 2013-06-28 21:14:23 +09:00
Trustin Lee
1e0146da3e Optimize MessageList.add(MessageList, int, int) 2013-06-28 20:53:57 +09:00
Trustin Lee
7cf88a1a3c Add MessageList.array() / Rewrite MessageList.add(T[], int, int)
- MessageList.array() should give better performance + concise code
- MessageList.add(T[], int, int) iterated over the source array 3 times at worst case. This commit reduces that to 1 time.
2013-06-28 20:47:19 +09:00
Trustin Lee
0dcf352f4c Vastly simplified ByteBufProcessor and MessageListProcessor
- Related: #1378
- They now accept only one argument.
- A user who wants to use a buffer for more complex use cases, he or she can always access the buffer directly via memoryAddress() and array()
2013-06-28 20:29:00 +09:00
Trustin Lee
52691488ee Update Javadoc of ByteBufProcessor and MessageListProcessor
- in response to @shacharo's suggestion
2013-06-27 19:01:01 +09:00
Trustin Lee
4dd9b6ef2e Add ByteBufProcessor and ByteBuf.forEach(...)
- Fixes #1378
- Needs to provide optimized forEach implementations though.
2013-06-27 13:55:42 +09:00
Trustin Lee
734ec51ac9 Allow specifying 0 as the default number of threads when instantiating an EventLoopGroup
- Fixes #1426
- We already allow a user instantiate an EventLoopGroup with the default number of threads via the default constructor, so I think it's OK although it's not always optimal.
2013-06-27 10:39:39 +09:00
Trustin Lee
bc483724f4 Improve the documentation of MessageList
- Fixes #1459
2013-06-25 18:27:29 +09:00
Trustin Lee
1f27c3b390 Make NioByteUnsafe.read() respect ChannelConfig.maxMessagesPerRead and adjust the default from 16 to 1
- Fixes #1486
- Decreased the default from 16 to 1 because unnecessary extra read on req-res protocols results in lower throughput due to extra syscalls.
2013-06-25 18:08:39 +09:00
Trustin Lee
a1632e7d15 Add ChannelConfig.maxMessagesPerRead and ChannelOption.MAX_MESSAGES_PER_READ
- Fixes #1486
- Make sure AbstractNioMessageChannel.NioMessageUnsafe.read() only up to maxMessagesPerRead
2013-06-25 17:49:28 +09:00
Trustin Lee
c77f03d886 Fix AdaptiveRecvByteBufAllocator.getSizeTableIndex() 2013-06-25 11:07:15 +09:00
Norman Maurer
c9d01b2fb5 [#1461] Correctly handle DefaultChannelGroup.write(..) of ByteBuf and ByteBufHolder 2013-06-25 11:07:14 +09:00
Trustin Lee
cfb3b977a1 Fix the catastrophic failure caused by AdaptiveRecvByteBufAllocator.getSizeTableIndex() 2013-06-25 11:07:14 +09:00
Trustin Lee
a2f232720b Make AdaptiveRecvByteBufAllocator's lookup table simpler / Optimize buffer size normalization
- No need to have fine-grained lookup table because the buffer pool has
  much more coarse capacities available
- No need to use a loop to normalize a buffer capacity
2013-06-25 11:07:14 +09:00
Trustin Lee
a969613540 Merge ChannelInboundConsumingHandler into SimpleChannelInboundHandler
- SimpleChannelInboundHandler now has a constructor parameter to let a
  user decide to enable automatic message release. (the default is to
  enable), which makes ChannelInboundConsumingHandler of less value.
2013-06-25 11:07:14 +09:00
Norman Maurer
bfc9c6d80d Add ChannelInboundConsumingHandler
..which is useful when the handler is placed at the last position of the
pipeline because it releases the received messages automatically.
2013-06-25 11:07:14 +09:00
Tony Rice
6c5c119f8c Fix incorrect parameter validation in DefaultFileRegion 2013-06-25 11:07:14 +09:00
Norman Maurer
cce74efded [#1448] Don't print failure if VoidChannelPromise is used 2013-06-16 14:25:02 +02:00
Norman Maurer
6a9f965f9b Introduce new utility class calles ReferenceCountUtil and move utility methods from ByteBufUtil to it.
The ones in ByteBufUtil were marked as @deprecated
2013-06-14 07:07:33 +02:00
Norman Maurer
4bf5003f76 Don't release messages before throw UnsupportedOperationException, as the caller method will take care 2013-06-14 06:41:27 +02:00
Trustin Lee
fe40d4b67f Make sure writing to a closed channel does not trigger an UnsupportedOperationException
- Fixes #1442
2013-06-14 11:15:46 +09:00
Trustin Lee
25c51279cf Revert "[#1442] Make sure closing the channel will not cause an UnsupportedOperationException"
This reverts commit a1a86b9de4 because the
semantic of ctx.isRemoved() is confusing to a user - why is
ctx.isRemoved() false when handlerRemoved() is invoked? A better
solution would be check if the connection is inactive and mark the
promise as failure before attempting to write anything.
2013-06-14 10:47:31 +09:00
Trustin Lee
a0c082497a Remove unused exception classes 2013-06-14 10:21:41 +09:00
Norman Maurer
8edee3272a More javadoc fixes 2013-06-13 20:56:17 +02:00
Norman Maurer
dc070a00b2 Deprecate IncompleteFlushException as its not used anymore 2013-06-13 20:50:21 +02:00
Norman Maurer
9100256a56 Javadocs cleanup 2013-06-13 20:49:05 +02:00
Norman Maurer
0e16b22aa1 Deprecate NoSuchBufferException as it's not used anymore 2013-06-13 20:48:54 +02:00
Norman Maurer
a1a86b9de4 [#1442] Make sure closing the channel will not cause an UnsupportedOperationException 2013-06-13 18:10:56 +02:00
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
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
2040b07849 Free the cleared buffer as early as possible / Better naming 2013-05-16 19:41:02 +09:00
Trustin Lee
dc13b68632 Make sure ChannelHandler.handlerRemoved() is always invoked
- Fixes #1366: No elegant way to free non-in/outbound buffers held by a handler
- handlerRemoved() is now also invoked when a channel is deregistered, as well as when a handler is removed from a pipeline.
- A little bit of clean-up for readability
- Fix a bug in forwardBufferContentAndRemove() where the handler buffers are not freed (mainly because we were relying on channel.isRegistered() to determine if the handler has been removed from inside the handler.
- ChunkedWriteHandler.handlerRemoved() is unnecessary anymore because ChannelPipeline now always forwards the content of the buffer.
2013-05-16 19:32:39 +09:00
Trustin Lee
670d3f53a8 Make uninitialization code in DefaultChannel easier to understand
.. by fixing bad / outdated method names
2013-05-16 16:18:01 +09:00
Norman Maurer
18bda09d6c Allow to recover from exception triggered by accept() more easily
This is done by stop accept() new sockets for 1 seconds
Beside this this commit also makes sure accept() exceptions of OioServerSocketChannel trigger
the fireExceptionCaught(...). The same is true fo the AioServerSocketChannel.
2013-05-08 17:21:14 +02:00
Norman Maurer
e48bc9c086 [#1344] Fix race condition in DefaultChannelPromise / DefaultChannelProgressivePromise which could lead to listeners that are not notified 2013-05-08 10:14:28 +02:00
Norman Maurer
7b854072d4 [#1327] Fix javadoc diagram for new api 2013-05-02 13:22:31 +02:00
Trustin Lee
1e0c83db23 Introduce AddressedEnvelope message type for generic representation of an addressed message
- Fixes #1282 (not perfectly, but to the extent it's possible with the current API)
- Add AddressedEnvelope and DefaultAddressedEnvelope
- Make DatagramPacket extend DefaultAddressedEnvelope<ByteBuf, InetSocketAddress>
- Rename ByteBufHolder.data() to content() so that a message can implement both AddressedEnvelope and ByteBufHolder (DatagramPacket does) without introducing two getter methods for the content
- Datagram channel implementations now understand ByteBuf and ByteBufHolder as a message with unspecified remote address.
2013-05-01 17:04:43 +09:00
Trustin Lee
23d0178494 Introduce EventExecutor.shutdownGracefully() that deprecates shutdown()
shutdownGracefully() provides two optional parameters that give more
control over when an executor has to be shut down.

- Related issue: #1307
- Add shutdownGracefully(..) and isShuttingDown()
- Deprecate shutdown() / shutdownNow()
- Replace lastAccessTime with lastExecutionTime and update it after task
  execution for accurate quiet period check
  - runAllTasks() and runShutdownTasks() update it automatically.
  - Add updateLastExecutionTime() so that subclasses can update it
- Add a constructor parameter that tells not to add an unncessary wakeup
  task in execute() if addTask() wakes up the executor thread
  automatically.  Previously, execute() always called wakeup() after
  addTask(), which often caused an extra dummy task in the task queue.
- Use shutdownGracefully() wherever possible / Deprecation javadoc
- Reduce the running time of SingleThreadEventLoopTest from 40s to 15s
  using custom graceful shutdown parameters

- Other changes made along with this commit:
  - takeTask() does not throw InterruptedException anymore.
    - Returns null on interruption or wakeup
  - Make sure runShutdownTasks() return true even if an exception was
    raised while running the shutdown tasks
  - Remove unnecessary isShutdown() checks
  - Consistent use of SingleThreadEventExecutor.nanoTime()

Replace isWakeupOverridden with a constructor parameter
2013-05-01 10:52:38 +09:00
Trustin Lee
6646db171e Use tryFailure() to notify registration failure to avoid IllegalStateException
.. which is raised when the registration promise has been failed already due to an internal error in the pipeline.

- Fixes #1319
2013-04-30 18:30:17 +09:00
Norman Maurer
61327b5871 Simplify a bit 2013-04-30 07:17:07 +02:00
Trustin Lee
8bb6d5b303 Rename Unsafe.directOutboundContext to headContext 2013-04-26 10:23:01 +09:00
Trustin Lee
7884574c7b Remove freeInboundBuffer() and freeOutboundBuffer() which has no value
- Fixes #1308

freeInboundBuffer() and freeOutboundBuffer() were introduced in the early days of the new API when we did not have reference counting mechanism in the buffer. A user did not want Netty to free the handler buffers had to override these methods.

However, now that we have reference counting mechanism built into the buffer, a user who wants to retain the buffers beyond handler's life cycle can simply return the buffer whose reference count is greater than 1 in newInbound/OutboundBuffer().
2013-04-25 09:15:55 +09:00
Trustin Lee
1b3d7f5325 Make sure handlerAdded() is called before forwarding the buffer content of the removed handler
- Added a test case that reproduces the problem in ReplayingDecoderTest
- Call newHandler.handlerAdded() *before* oldHandler.handlerRemoved() to ensure newHandlerAdded() is called before forwarding the buffer content of the old handler in replace0().
2013-04-24 19:25:43 +09:00
Trustin Lee
99b999760a Move multiplicity check to the early stage
.. no need to do it late
2013-04-24 19:02:34 +09:00
Trustin Lee
6282b31bc0 Format 2013-04-24 18:57:14 +09:00
Trustin Lee
7c5dc363fb Rename methods to catch up the recent changes in handler life cycle listener methods / Ensure to call handlerRemoved() even if ctx.forwardContentAndRemove() failed 2013-04-24 18:55:51 +09:00
Trustin Lee
c72b5341a3 ChannelHandler.handlerRemoved() must be invoked *after* the handler has been removed completely and its buffers should be inaccessible. 2013-04-24 18:46:35 +09:00
Trustin Lee
a68d39fcf2 Fix an infinite exception storm triggered by DefaultChannelHandlerContext.invokeInboundBufferUpdated()
- it has to break from the infinite loop when an exception is raised by handler
2013-04-24 18:39:34 +09:00
Trustin Lee
b5989e2449 Reduce exception instantiation overhead in SslHandler / Reduce unnecessary empty array creation
- Added EmptyArrays as an internal utility class
2013-04-24 09:32:53 +09:00
Trustin Lee
d292fdafdd Make sure to close the accept channel which couldn't be initialized or added to the message buffer 2013-04-23 22:42:47 +09:00
Trustin Lee
cc0ad9f1cc Fix hanging SocketBufReleaseTest / Make sure AioServerSocketChannel closes the accepted channel when the server socket is being shut down 2013-04-23 22:38:28 +09:00
Trustin Lee
f03b2cde62 Fix intermittent infinite loop in AbstractOioByteChannel.doRead()
- OioByteStreamChannel.doReadBytes() did not expand the capacity of the inbound buffer properly.
2013-04-23 22:12:07 +09:00
Trustin Lee
f149cf5220 Reduce code duplication 2013-04-23 13:42:00 +09:00
Trustin Lee
5d5c60bdd3 Fix a bug where fireInboundBufferUpdated() and flush() swallow the event too early
- Fixes #1292
- Replace DefaultChannelPipeline.inbound/outboundShutdown flag with per-context flags
- Update the flags in free() / freeInbound() / freeOutbound() for clarity
2013-04-23 13:35:32 +09:00
Trustin Lee
8e2e22c270 Change the thread model slightly for new/freeInbound/OutboundBuffer() for future improvement
- Related: #1283
- Make ReplayingDecoder work with the modified thread model
2013-04-23 13:06:27 +09:00
Trustin Lee
d85757a008 Fix memory leak in DefaultChannelHandlerContext
.. where freeInbound() and freeOutbound() are not called for all contexts

- Fixes #1298
2013-04-22 22:18:10 +09:00
Trustin Lee
e80fb65c36 Clean up the pipeline implementation / Ensure Embedded*Channel does not run pending tasks immediately
- Replace ugly 'prev != null' check with explicit event scheduling
- Fix an incorrect flag operation in freeHandlerBuffersAfterRemoval()
- Fix a bug in AbstractEmbeddedChannel.doRegister where it makes pending tasks immediately, where the pending tasks actually triggers inbound events
- Remove unnecessary suppression of inboundBufferUpdated() event in DefaultChannelPipeline, which potentially hides an event ordering bug. Unfortunately, I don't remember why I added it in cca35454d2.
2013-04-22 19:41:00 +09:00
Norman Maurer
9c4bfa44d9 [#1294] Make sure ByteBuf is released once written to channel 2013-04-22 11:04:56 +02:00
Trustin Lee
f979c17b67 Revert "Fix #1075: DefaultChannelHandlerContext.fireChannelSuspended and fireInboundBufferUpdated do not work correctly if handlers with EventExecutor are added or removed from pipeline."
This reverts commit 273948055a, which is
incorrect.

- Related: #1075
2013-04-22 16:59:43 +09:00
Trustin Lee
c01d37ad05 Merge forwardBufferContent and setRemoved() 2013-04-22 14:47:17 +09:00
Norman Maurer
9b89c303cc Return correct type on retain(..) 2013-04-21 13:41:34 +02:00
Norman Maurer
ca5554dfe7 [#1236] Fix problem where adding a new ChannelHandler could block the eventloop
This change also introduce a few other changes which was needed:
 * ChannelHandler.beforeAdd(...) and ChannelHandler.beforeRemove(...) were removed
 * ChannelHandler.afterAdd(...) -> handlerAdded(...)
 * ChannelHandler.afterRemoved(...) -> handlerRemoved(...)
 * SslHandler.handshake() -> SslHandler.hanshakeFuture() as the handshake is triggered automatically after
   the Channel becomes active
2013-04-19 07:00:50 +02:00
Norman Maurer
58bfd6bf3b [#1284] Fix bug which can cause in infinity-loop triggered by a handler removal 2013-04-18 22:15:50 +02:00
Trustin Lee
7ee571968c Use progress + total instead of delta
.. because there is sometimes a task whose total is only a rough
estimation
2013-04-15 20:11:02 +09:00
Trustin Lee
e69033a4c3 Replace TransferFuture(Listener) with (Channel)ProgressiveFuture(Listener)
- Now works without the transport package
- Renamed TransferFuture to ProgressiveFuture and ChannelProgressiveFuture / same for promises
- ProgressiveFutureListener now extends GenericProgressiveFutureListener and GenericFutureListener (add/removeTransferListener*() were removed)
- Renamed DefaultEventListeners to DefaultFutureListeners and only accept GenericFutureListeners
- Various clean-up
2013-04-15 15:26:20 +09:00
Trustin Lee
391c011764 Renames and typos 2013-04-15 11:03:59 +09:00
kerr
713b200adf [#1244] Support ChannelTransferPromise for sendFile 2013-04-14 21:22:03 +02:00
Norman Maurer
d8387fa4c3 [#858] Merge ChannelPipeline.replaceAndForward into replace and removeAndForward into remove 2013-04-13 18:19:33 +02:00
Trustin Lee
4a792151b0 Rewrite bridge implementation in DefaultChannelHandlerContext
This commit splits bridge into two parts.  One is NextBridgeFeeder,
which provides ByteBuf and MessageBuf that are local to the context
whose next*Buffer() has been invoked on.  The other is a thread-safe
queue that stores the data fed by NextBridgeFeeder.feed().

By splitting the bridge into the two parts, the data pushed by a handler
is not lost anymore when the next handler who provided the next buffer
is removed from the pipeline.

- Fixes #1272
2013-04-12 17:38:04 +09:00
Norman Maurer
725156f082 [#1242] Fix infinity-loop which was triggered when a write failed and AioSocketChannel was used 2013-04-10 15:39:58 +02:00
Norman Maurer
4746e74124 [#1247] Add javadocs which tell the limitation of the type detection as there is nothing we can do about 2013-04-10 11:27:54 +02:00
Norman Maurer
0efebd5a82 Allow to get an Iterator over all of the EventExecutor an EventExecutorGroup contains. Beside this allow to get basic stats for the EventExecutor like pendingTasks and executorCount 2013-04-09 15:45:18 +09:00
Norman Maurer
067a2af700 Fix a few typos 2013-04-08 21:23:53 +02:00
Norman Maurer
2a162eb140 Rename method to better reflect usage 2013-04-08 08:06:46 +02:00
Norman Maurer
8632d9011e [#1239] Fix possible NPE while fail flush futures during close 2013-04-05 19:23:49 +02:00
Norman Maurer
4505e7f1b3 Make sure OP_WRITE is correctly cleared when using FileRegion and other NioTasks 2013-04-04 08:38:58 +02:00
Norman Maurer
af4b71a00e Remove special handling of Object[] in codec framework (a.k.a unfolding)
- Fixes #1229
- Primarily written by @normanmaurer and revised by @trustin

This commit removes the notion of unfolding from the codec framework
completely.  Unfolding was introduced in Netty 3.x to work around the
shortcoming of the codec framework where encode() and decode() did not
allow generating multiple messages.

Such a shortcoming can be fixed by changing the signature of encode()
and decode() instead of introducing an obscure workaround like
unfolding.  Therefore, we changed the signature of them in 4.0.

The change is simple, but backward-incompatible.  encode() and decode()
do not return anything.  Instead, the codec framework will pass a
MessageBuf<Object> so encode() and decode() can add the generated
messages into the MessageBuf.
2013-04-03 21:44:54 +09:00
Trustin Lee
117ad8acd7 Add MultithreadEventLoopGroup.DEFAULT_EVENT_LOOP_THREADS / Add DefaultThreadFactory
- Allow overriding the default thread factory when a user specified no thread factory
2013-04-03 17:49:30 +09:00
Trustin Lee
312a35dfed Remove MultithreadEventExecutorGroup.DEFAULT_POOL_SIZE
- We should never define a default nThread for MultithreadEventExecutorGroup because we don't know what a user do with it.
2013-04-03 17:15:25 +09:00
Trustin Lee
b7797917ab Deprecate Bootstrap.shutdown() and use EventLoopGroup.shutdown() wherever possible
There are still some tests that use Bootstrap.shutdown() though.  They need non-trivial refactoring, which will come soon.
2013-04-03 16:15:33 +09:00
Andrew Cox
3f8a830963 Fix DefaultChannelPipeline.first() so that it returns null when only the sentinel handlers remain (this is how DefaultChannelPipeline.last() works already) 2013-04-03 06:55:55 +02:00
Trustin Lee
0f3dc0409a Log various properties at startup time for easier diagnosis 2013-04-03 11:44:30 +09:00
Norman Maurer
bcb0b83b44 Use unfoldAndAdd(..) for now 2013-04-02 13:58:15 +02:00
George Cao
436380c41e Fix Javadoc issues. Replace Upstream with Inbound and Downstream with Outbound. 2013-04-02 15:13:39 +09:00
Norman Maurer
96bf71e814 Let EventExecutorGroup extend ScheduledExecutorService as it shares quite some semantic 2013-04-01 13:56:46 +02:00
Adam Vandenberg
8e23ab6886 Fix typo in BufType javadoc 2013-03-29 21:47:55 +09:00
Trustin Lee
19ffdd5c29 Revamp the selector auto rebuild checker
- Count the number of select() calls made to wait until reaching at the expected dead line, and rebuild selectors if too many select() calls were made.
2013-03-22 14:33:47 +09:00
Trustin Lee
69e5a0eb9c Log prematurly returning select() at DEBUG level and increase the minimum required consecutive premature returns to log 2013-03-22 12:59:47 +09:00
Trustin Lee
d525295d20 Revert NioEventLoop.hasTasks() which is not really true 2013-03-22 12:46:31 +09:00
Trustin Lee
34853e7ba0 Selector auto-rebuilder tweaks 2013-03-22 12:37:11 +09:00
Trustin Lee
f6e0df125a Allow disabling automatic selector rebuilding by specifing non-positive threshold 2013-03-22 11:50:53 +09:00
Trustin Lee
1ab2813405 Enable automatic selector rebuilding by default
- Fixes #1192
- Log at WARN level for easier diagnosis
2013-03-22 11:48:41 +09:00
Trustin Lee
fa02ffddae Remove TaskScheduler and ImmediateEventExecutor that requires TaskScheduler
- Related issue: #817
2013-03-22 09:06:08 +09:00
Trustin Lee
4097dee49d Make SingleThreadEventExecutor independent from TaskScheduler
- Related issue: #817
2013-03-22 09:00:38 +09:00
Trustin Lee
8fb80e9179 Fix a dead lock in ServerBootstrap as described in #1175
- Reduce code duplication between bootstrap implementations
2013-03-21 21:34:13 +09:00
Trustin Lee
9b208028ef Use clearer term when data is discarded by pipeline 2013-03-21 20:22:25 +09:00
Trustin Lee
a8723412dd Fix checkstyle 2013-03-21 19:51:11 +09:00
Norman Maurer
f858a2fe62 Fix multiple calls to fireChannelActive() when using AIO 2013-03-21 11:49:58 +01:00
Trustin Lee
4fa7e85493 Make sure ChannelFuture of Bootstrap.bind() and connect() notify with the right cause when registration fails
- Related: #1175
2013-03-21 19:41:38 +09:00
Norman Maurer
b6dd5938ab No need to do any deadlock check here 2013-03-21 11:24:26 +01:00
Trustin Lee
c08919d0a0 Fix the dead lock described in #1175
- Similar to @normanmaurer's fix in that this commit also makes Bootstrap.init(Channel) asynchronous, but it is simpler and less invasive.
- Also made sure a connection attempt failure in the local transport does not trigger an exceptionCaught event
2013-03-21 19:19:14 +09:00
Trustin Lee
bd8d53eaed Fix checkstyle 2013-03-21 19:02:34 +09:00
Trustin Lee
2aa0bf73dc Add a unit test that reproduces the dead lock described in #1175
- The offending test case is annotated with `@Ignore`
- Also fixed a bug where channel initialization failure swallows the original cause of initialization failure
2013-03-21 18:43:03 +09:00
Trustin Lee
a980638190 Ensure the best effort is made even if future listeners could not be notified / Handle registration failure in a robust manner
- Related: #1187
2013-03-21 17:48:10 +09:00
Trustin Lee
8b722d29a7 Add constructor parameters that do not perform type parameter auto-detection for the languages without type parameters
- Fixes #1177
- Add TypeParameterMatcher.get(parameterType)
- Add alternative constructors
2013-03-21 16:11:47 +09:00
Norman Maurer
2b014ce82a [#1183] Fix BlockingOperationException in ChannelGroup.close().awaitUninterruptibly() 2013-03-20 18:28:55 +01:00
Norman Maurer
ce87b627be Let EventExecutor return our Future to allow the user to work also with FutureListener here. Also add a special ScheduledFuture that extends our Future for this purpose. 2013-03-19 10:45:42 +01:00
Michael Nitschinger
5a88227856 Transport: Clarifying the role of AbstractBootstrap#bind()
This small changeset clarifies the role of AbstractBootstrap#bind(),
especially when not used in a ServerBoostrap context.
2013-03-18 17:58:46 +09:00
Trustin Lee
f4c18c6e74 Fix a bug where NioEventLoop.processSelectedKeys() enters an infinite loop when too many connections are closed at once
- Fixes #1171
2013-03-18 15:01:19 +09:00
Jeff Pinner
7498e0f913 make deregister protected in ThreadPerChannelEventLoop 2013-03-17 20:11:33 +01:00
Trustin Lee
70a51bcd8d Fix memory leak in AbstractEmbeddedChannel
- Allow a transport implementation to perform an arbitrary task when a channel has been deregistered completely
2013-03-14 15:51:33 +09:00
Trustin Lee
9c96791176 Move the methods that's only used by DefaultChannelPipeline to DefaultChannelPipeline 2013-03-14 15:01:35 +09:00
Trustin Lee
d55567e21b Remove DefaultChannelHandlerContext.needsLazyBufInit which is used only by the head handler 2013-03-14 14:35:56 +09:00
Trustin Lee
f1ecb4ab1a Remove ChannelHandlerContext.types() which is barely useful / Remove ChannelHandlerType together 2013-03-14 14:14:04 +09:00
Trustin Lee
9feb27d58c Specify timeout on Selector.select() 2013-03-14 08:54:33 +09:00
Trustin Lee
644d5abbda Add an empty line 2013-03-14 06:54:57 +09:00
Trustin Lee
8dcb1387e3 Add I/O ratio parameter to NioEventLoop
- Add SingleThreadEventExecutor.runAllTasks(timeout)
- Add NioEventLoop.ioRatio property
- Merge SelectorUtil into NioEventLoop
2013-03-14 06:49:08 +09:00
Norman Maurer
fe66f33f42 Fix issue where the bytes/messages are forwarded to the wrong handler 2013-03-12 08:37:27 +01:00
Norman Maurer
17ebbdec20 Let ChannelGroupFuture extends ChannelFuture and ChannelGroupFutureListener GenericFutureListener 2013-03-12 08:35:39 +01:00
Norman Maurer
f2a35273e6 Fix checkstype 2013-03-12 08:35:24 +01:00
Trustin Lee
397830d238 Allow SingleOutboundMessageHandler.beginFlush() to reject the flush request by returning false / Replace PartialFlushException with IncompleteFlushException which is more correct. 2013-03-12 15:20:46 +09:00
Trustin Lee
83cdbeca1d Add ThreadPerChannelEventLoopGroup and ThreadPerChannelEventLoop to enable a user to write a new thread-per-channel transport easily
- Fixes #1124
2013-03-12 14:50:38 +09:00
Norman Maurer
2406a9f8b8 Use LinkedHashSet 2013-03-11 06:38:39 +01:00
Norman Maurer
806e9b1f8c Make sure we handle outbound messages of type ByteBuf special 2013-03-11 08:59:00 +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
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
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
16f4de7adb Use the original stack trace when translating SocketTimeoutException to ConnectTimeoutException 2013-03-08 08:40:28 +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