Commit Graph

978 Commits

Author SHA1 Message Date
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
2640832a38 Fix checkstyle 2013-04-21 12:52:42 +02:00
Trustin Lee
5846693577 Typo 2013-04-21 07:45:37 +09:00
Trustin Lee
475039532c Split dynamic pipeline manipulation test into a new class / Replace PrefixThreadFactory with DefaultThreadFactory / Port the latest tests from the branch 'out-of-order' written by @normanmaurer 2013-04-21 07:44:37 +09: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
Andrei Pozolotin
a3e760a003 fix #1234 - duplicate package-info.java errors in eclipse requires release of netty-build v 19 and netty-parent update. 2013-04-05 05:38:05 +09: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
Prajwal Tuladhar
05850da863 enable checkstyle for test source directory and fix checkstyle errors 2013-03-30 13:18:57 +01:00
Adam Vandenberg
8e23ab6886 Fix typo in BufType javadoc 2013-03-29 21:47:55 +09:00
Norman Maurer
59012390f6 Fix version numbering 2013-03-25 08:01:11 +01:00
Norman Maurer
7d7b676eeb [maven-release-plugin] prepare for next development iteration 2013-03-22 15:20:35 +01:00
Norman Maurer
60fc7dac4d [maven-release-plugin] prepare release netty-4.0.0.CR1 2013-03-22 15:20:11 +01: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
2a87950784 [maven-release-plugin] prepare for next development iteration 2013-03-16 18:41:36 +09:00
Trustin Lee
adfb29330b [maven-release-plugin] prepare release netty-4.0.0.Beta3 2013-03-16 18:40:59 +09:00
ursa
835a40fa25 Port test for handler's life-cycle processing into master branch. 2013-03-14 11:10:02 +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