Commit Graph

223 Commits

Author SHA1 Message Date
Trustin Lee
955c89fcf1 Add SocketEchoTest that will simplify a lot of socket testing
- SocketTestCombination generates all possible test combinations of
  socket transports.
- SocketEchoTest iterates over the combinations and runs all tests
  using reflection.
2012-06-03 01:52:39 -07:00
Trustin Lee
3b2c25e8ed Rename (Server)Bootstrap.(child)initializer to (child)handler
- The handler you specify with initializer() is actually simply added
  to the pipeline and that's all.  It's ChannelInitializer which does
  additional work.  For example, a user can specify just a single
  handler with initializer() and it will still work.  This is especially
  common for Bootstrap, so I renamed initializer to handler, which makes
  more sense.
2012-06-03 01:00:16 -07:00
Trustin Lee
19dcb81727 Add comments for easier understanding 2012-06-02 02:43:26 -07:00
Trustin Lee
01a5bd41f0 Add Channel.type() which tells if stream-oriented or message-oriented
- DefaultChannelPipeline uses this information to reject invalid buffer
  access in inbound(Message|Byte)Buffer.  Otherwise, a user can access
  a message buffer when the channel is stream-oriented.
- Because ChannelType cannot be both STREAM and MESSAGE, catch-all
  buffer has been removed to avoid confusion and unexpected behavior
  (it's already causing headache.)
- As a result, codec embedder needs rework.
2012-06-02 01:58:15 -07:00
Trustin Lee
cc4f705029 Replace ChannelBuffer.toByteBuffer() with hasNioBuffer() and nioBuffer()
... just like we do with byte arrays.  toByteBuffer() and
toByteBuffers() had an indeterministic behavior and thus it could not
tell when the returned NIO buffer is shared or not.  nioBuffer() always
returns a view buffer of the Netty buffer.  The only case where
hasNioBuffer() returns false and nioBuffer() fails is the
CompositeChannelBuffer, which is not very commonly used and *slow*.
2012-06-02 01:30:55 -07:00
Trustin Lee
04cf1c8199 Use custom thread factory by default to better recognize the threads
... from their names
2012-06-01 22:57:54 -07:00
Trustin Lee
61e169e53a Remove EventExecutor.parent(), which is of no use 2012-06-01 22:33:53 -07:00
Trustin Lee
4440386494 Little bit of optimization 2012-06-01 18:34:19 -07:00
Trustin Lee
141a05c831 Strict thread model / Allow assign an executor to a handler
- Add EventExecutor and make EventLoop extend it
- Add SingleThreadEventExecutor and MultithreadEventExecutor
- Add EventExecutor's default implementation
- Fixed an API design problem where there is no way to get non-bypass
  buffer of desired type
2012-06-01 17:51:19 -07:00
Trustin Lee
ab5043b3c7 Fixed LocalAddressTest 2012-05-31 21:22:03 -07:00
Trustin Lee
5243d3d0f0 Add @Sharable annotation to ChannelInitializer 2012-05-31 17:05:34 -07:00
Trustin Lee
f2eddda5a4 Call discardReadBytes() on outbound byte buffers when possible
- Also fixed a test failure in codec-http
2012-05-31 16:59:54 -07:00
Trustin Lee
d626561b59 Define a dedicated exception for performing blocking ops in event loop 2012-05-31 16:47:00 -07:00
Trustin Lee
468918227a Remove unnecessary parameter in AttributeKey and ChannelOption
- Removed UniqueKey which does nothing
- The valueType parameter was not needed at all because we do not need
  type information in runtime at all.
2012-05-31 16:03:57 -07:00
Trustin Lee
7ddc93bed8 Ported IdleStateHandler / Forward-ported the UptimeClient example
- Add ChannelHandlerContext.eventLoop() for convenience
- Bootstrap and ServerBootstrap handles channel initialization failure
  better
- More strict checks for missing @Sharable annotation
  - A handler without @Sharable annotation cannot be added more than
    once now.
2012-05-31 14:54:48 -07:00
Trustin Lee
49bda34a5d Fix a bug where ChannelBufferHolder.isEmpty() returns a wrong value
.. when it has a byte buffer
2012-05-31 09:14:39 -07:00
Trustin Lee
0fd824c3bb Fix UnsupportedOperationException 2012-05-31 09:11:07 -07:00
Trustin Lee
2a63acef4d More convenient inbound stream handler / Smarter inbound buffer cleanup
- Added a new convenience method to ChannelInboundstreamHandlerAdapter 
- EchoServerHandler uses the new method
- DefaultChannelPipeline calls inboundByteBuffer.discardReadBytes()
  when it is sure there's no memory copy involved
2012-05-31 09:03:31 -07:00
Trustin Lee
665777e6f9 Add InternetProtocolFamily and use it with NioDatagramChannel 2012-05-31 02:49:39 -07:00
Trustin Lee
7ac89ace4f Finished forward-porting SPDY codec 2012-05-31 01:53:58 -07:00
Trustin Lee
32c982b478 Fix NPE in OioChildEventLoop 2012-05-31 01:19:54 -07:00
Trustin Lee
53f16ce003 Add more convenience methods to Bootstrap and ServerBootstrap 2012-05-30 23:47:15 -07:00
Trustin Lee
67ec4429cc Implement NIO.2 multicast options 2012-05-30 19:03:45 -07:00
Trustin Lee
42abb6df3a QueueFactory cleanup
- Really attempt to create a queue to determine LTQ can be initialized
  in runtime, and cache the result
- Remove unnecessary Class<T> parameter in createQueue()
- Remove unused createQueue(Collection)
2012-05-30 16:19:22 -07:00
Trustin Lee
e3431db547 Use logger instead of System.err 2012-05-30 15:46:38 -07:00
Trustin Lee
e5bcc74cd5 Warn if the last inbound handler forwarded an exceptionCaught() event 2012-05-30 11:48:04 -07:00
Trustin Lee
cca35454d2 Ensure channelInboundBufferUpdated is fired after channelActive 2012-05-30 11:32:39 -07:00
Trustin Lee
47fa2ef2e8 Use LinkedHashSet instead of HashSet to preserve order of execution 2012-05-30 10:17:45 -07:00
Trustin Lee
9f9045c3b4 Add EventLoop implementation for the local transport 2012-05-30 04:33:43 -07:00
Trustin Lee
c17e5b458a Typo 2012-05-30 04:28:01 -07:00
Trustin Lee
4154f42520 Less restriction in shutdown hook modification 2012-05-30 04:27:19 -07:00
Trustin Lee
078a502c5f Add shutdown hooks to SingleThreadEventLoop
- LocalChannel and LocalServerChannel uses it to close themselves on
  shutdown
- LocalEcho example does not call close() anymore because the channels
  are closed automatically on shutdown
2012-05-30 04:23:15 -07:00
Trustin Lee
243f6581c6 Safer shutdown 2012-05-30 04:06:15 -07:00
Trustin Lee
65e224f149 Safer shutdown 2012-05-30 04:05:10 -07:00
Trustin Lee
a53ecbf5f1 Implement the local transport
- Replace the old local example with localecho example
- Channel's outbound buffer is guaranteed to be created on construction
  time.
2012-05-30 03:58:14 -07:00
Trustin Lee
392623749e Fix compilation errors 2012-05-30 02:01:48 -07:00
Trustin Lee
78974e85c5 AbstractUnsafe.out() -> directOutbound()
- to avoid confusion between Channel.outbound()
2012-05-30 00:38:23 -07:00
Trustin Lee
f4c6bcafaf Keep channel's outbound buffer in AbstractChannel
- Replace firstOut() with newOutboundBuffer()
2012-05-30 00:35:53 -07:00
Trustin Lee
a9948d681e Throw NoSuchBufferException instead of returning null
- Exception in this case makes a user less confusing
- To reduce the overhead of filling the stack trace,
  NoSuchBufferException has a public pre-constructed instance.
  - This is necessary because codec framework sometimes need to support
    both type of outbound buffers.
- Fixed a bug where SpdyFrameEncoder did not handle ping messages
- Reduced memory copy in codec embedder (EmbeddedChannel)
2012-05-29 17:25:09 -07:00
Trustin Lee
8237afff64 Ported most examples
- Renamed ChannelBootstrap to Bootstrap
- Renamed ServerChannelBootstrap to ServerBootstrap
- Moved bootstrap classes to io.netty.bootstrap as before
- Moved unfoldAndAdd() to a separate utility class
- Fixed a bug in unfoldAndAdd() where it did not handle ChannelBuffer
  correctly
2012-05-29 16:41:26 -07:00
Trustin Lee
026715e818 Refactor the pipeline API to support stacked codecs
- Previous API did not support the pipeline which contains multiple
  MessageToStreamEncoders because there was no way to find the closest
  outbound byte buffer.  Now you always get the correct buffer even if
  the handler that provides the buffer is placed distantly.
  For example:
  
    Channel -> MsgAEncoder -> MsgBEncoder -> MsgCEncoder
  
  Msg(A|B|C)Encoder will all have access to the channel's outbound
  byte buffer.  Previously, it was simply impossible.

- Improved ChannelBufferHolder.toString()
2012-05-29 12:09:29 -07:00
Trustin Lee
6d39c342b6 Add FIXME 2012-05-28 05:20:32 -07:00
Trustin Lee
e48281471b Limit future notification stack depth / Robost writeCounter management
- Also ported the discard example while testing this commit
2012-05-28 05:05:49 -07:00
Trustin Lee
a2698e65fb Added more convenience methods to bootstraps 2012-05-28 01:23:58 -07:00
Trustin Lee
626c5ef9c9 Remove the classes that are not part of Netty 4.0.0.Alpha1
- Will add them back before Beta1
2012-05-27 19:39:10 -07:00
Trustin Lee
f4a19886d3 Reorder methods / Move buffer expansion logic in OIO 2012-05-27 05:31:18 -07:00
Trustin Lee
7b05f34171 Split AbstractOioChannel into its subtypes
- AbstractOioMessageChannel and AbstractOioStreamChannel
- Replaced 'if' with polymorphism
- Better performance
2012-05-27 05:19:45 -07:00
Trustin Lee
064b3dc9e5 Split AbstractNioChannel into two subtypes
- AbstractNioMessageChannel and AbstractNioStreamChannel
- Better performance
- Replaced 'if' checks with polymorphism
2012-05-27 05:07:23 -07:00
Trustin Lee
7327bb3522 Add SingleThreadEventLoop.runAllTasks()
- Removed duplicated processTaskQueue() in child event loops
- Simplified the cleanup of cancelled keys in NIO transport
2012-05-27 04:43:48 -07:00
Trustin Lee
f29b6ae29a Fix performance issue in OioSocketChannel since previous refactoring 2012-05-26 23:29:23 -07:00