Commit Graph

165 Commits

Author SHA1 Message Date
Trustin Lee
bc5e8b6be1 Do not create an iterator unnecessarily 2012-05-25 06:30:30 -07:00
Trustin Lee
59f11ed64f Optimize AbstractChannel and related classes
- AbstractChannel.doRead() is split into two versions so that the
  implementation doesn't have to validate the buffer type.
- Optimized ChannelBufferHolder a little bit
- Reduced GC related with flush future notification
  - Added FlushCheckpoint and DefaultChannelFuture implements it
    opportunistically
-
2012-05-25 06:16:25 -07:00
Trustin Lee
25599018f2 Tiny bit of optimization in event loop 2012-05-24 21:04:12 -07:00
Trustin Lee
02144f70e1 Genericize ChannelInitializer 2012-05-24 15:12:14 -07:00
Trustin Lee
4a3c54b0fa Add UDP_RECEIVE_PACKET_SIZE option for datagram transport 2012-05-24 10:37:51 -07:00
Trustin Lee
c7c923cab3 Ported the QOTM example to the new API
- Fixed bugs in the NIO datagram transports
  - DefaultNioDatagramChannelConfig did not initialize on Java 6
2012-05-24 09:32:14 -07:00
Trustin Lee
c6f3b5762e Implement NIO datagram transport with the new API
- AbstractChannel now handles flushing a message buffer
- Cleaned up DatagramChannel interface
- Removed ProtocolFamily because a user can create an NIO
  DatagramChannel and specify it as a constructor parameter
- UniqueName and UniqueKey constructors became public so that
  I don't need to create a subclass every time.
2012-05-24 08:57:10 -07:00
Trustin Lee
cd11786994 Fix typo in the comment 2012-05-24 08:51:46 -07:00
Trustin Lee
21a3d3fe02 Add more constructor to NioSocketChannel 2012-05-23 23:28:15 -07:00
Trustin Lee
a2d57144b4 Fix compilation errors 2012-05-23 11:47:37 -07:00
Trustin Lee
c883b61503 Ported codec-http to the new API
- Added ChannelBufferHolders.catchAllBuffer()
- Relaxed UnsupportedMessageTypeException constructor signature
- EmbeddedChannel now uses the catchAllBuffer
- ChanelInboundMessageHandlerAdapter.messageReceive() throws Exception
- Added ChannelInboundStreamHandlerAdapter
2012-05-23 11:42:10 -07:00
Trustin Lee
7ecad7a8ac Add ChannelInboundMessageHandlerAdapter 2012-05-23 09:47:38 -07:00
Trustin Lee
baa3388859 Make the default constructor of CombinedChannelHandler protected 2012-05-20 20:57:00 +09:00
Trustin Lee
83f1b5fa35 Implement spinning in SelectorUtil.select()
- this seems to improve performance when the number of connections is
  very small
2012-05-20 16:29:31 +09:00
Trustin Lee
cab983244d Tidy up AbstractChannel.read() 2012-05-20 15:03:28 +09:00
Trustin Lee
3a8c10cc5a Do not call expandReadBuffer too often 2012-05-20 14:30:26 +09:00
Trustin Lee
af37ec4f23 Ported the HTTP snoop example to the new API
- Replaced pipeline factories with initializers
- Ported essential parts related with HTTP to the new API
- Replaced ChannelHandlerAdapter.combine() with CombinedChannelHandler
- Fixed a bug where ReplayingDecoder does not notify the next handler
- Fixed a bug where ReplayingDecoder calls wrong callDecode() method
- Added a destination buffer as an argument to AbstractChannel.doRead()
  for easier implementation
- Fixed a bug where NioSocketChannel did not try to increase the inbound
  buffer size (moved the logic to AbstractChannel)
2012-05-20 14:19:11 +09:00
Trustin Lee
e846505ceb Add combined codec classes and related utility method 2012-05-20 12:53:22 +09:00
Trustin Lee
dbd973d825 Introduce UniqueName, UniqueKey, and Signal
- UniqueKey removes the duplication between ChannelOption and
  AttributeKey
- UniqueName provides common name collision check for AttributeKey,
  ChannelOption, and Signal.
- Replaced ReplayError with Signal
2012-05-18 14:30:42 +09:00
Trustin Lee
2c99fda7b5 Remove unnecessary field 2012-05-16 23:07:19 +09:00
Trustin Lee
d3a3b329f3 Fix a compilation error 2012-05-16 23:05:58 +09:00
Trustin Lee
3669e31e14 Fix a compilation error in DefaultChannelPipeline 2012-05-16 23:03:11 +09:00
Trustin Lee
92a688e5b2 Retrofit the codec framework with the new API (in progress)
- Replaced FrameDecoder and OneToOne(Encoder|Decoder) with:
  - (Stream|Message)To(String|Message)(Encoder|Decoder)
- Moved the classes in 'codec.frame' up to 'codec'
- Fixed some bugs found while running unit tests
2012-05-16 23:02:06 +09:00
Trustin Lee
894ececbb7 Convert DOS line ending to UNIX line ending 2012-05-15 17:14:02 +09:00
Trustin Lee
dd2e36e5d9 Remove unused or unmaintainable internal classes 2012-05-15 17:10:54 +09:00
Trustin Lee
957c04e597 Fix boundary check in DefaultChannelPipeline.addFirst(..)
- Thanks @normanmaurer
2012-05-15 14:49:23 +09:00
Trustin Lee
6eb540ca40 Add more convenient methods to ChannelPipeline
.. to simplify pipeline construction as shown in the echo example
2012-05-15 14:08:42 +09:00
Trustin Lee
d01d1d0843 Rename (Server)ChannelBuilder to (Server)ChannelBootstrap
- It does not build a new Channel but just helps bootstrapping it.
- Added shutdown() method for simpler deinitialization
- ServerChannelBootstrap has shorter method names for the parent channel
2012-05-15 13:45:25 +09:00
Trustin Lee
f00fadb9fd Simplify the construction of multi-threaded selector event loop
- Hide InternalLogger from users
2012-05-15 13:11:47 +09:00
Trustin Lee
311f17f6ef Replace Bootstrap with ChannelBuilder and ServerChannelBuilder
- Added ChannelInitializer which is supposed to be used with the
  builders
- Echo examples use ChannelBuilder and ServerChannelBuilder now
- Replace ChannelFuture.rethrowIfFailed() with sync*()
- Bug fixes
2012-05-14 23:57:23 +09:00
Trustin Lee
05f955ee10 Clean up echo example / Fix a bug where closeFuture is not notified 2012-05-14 14:17:40 +09:00
Trustin Lee
6a0040a14e Fix compilation errors 2012-05-13 18:45:57 +09:00
Trustin Lee
3642879d98 Move up write spinning from SelectorEventLoop to AbstractChannel 2012-05-13 05:09:05 +09:00
Trustin Lee
6d14fac99c Revive Channel.closeFuture
- ChannelPipeline now rejects an unsafe ChannelFuture, so there's no
  need to hide/remove closeFuture.
2012-05-13 01:37:16 +09:00
Trustin Lee
175acb7899 Prevent unsafe ChannelFutures from being passed to a pipeline 2012-05-13 01:35:43 +09:00
Trustin Lee
08137e2c49 Implement flush-future properly / Make channel options type-safe
- AbstractChannel keeps the expected number of written bytes so that
  the ChannelFuture of a flush() operation is notified on right timing.
  - Added ChannelBufferHolder.size() to make this possible
- Added AbstractChannel.isCompatible() so that only compatible EventLoop
  is accepted by a channel on registration
- Added ChannelOption to make channel options type-safe
- Moved writeSpinCount property to ChannelConfig and removed Nio*Config
- Miscellaneous cleanup

introducing
ChannelOption
2012-05-13 00:40:28 +09:00
Trustin Lee
c57d7dd098 Add EventLoopFactory and make MultithreadEventLoop use it
- based on the feed back from @normanmaurer
2012-05-11 21:47:07 +09:00
Trustin Lee
97c07708a2 Remove unused class 2012-05-11 21:36:47 +09:00
Trustin Lee
1db0cd60c4 Do not attempt to flush when waiting for OP_WRITE 2012-05-11 21:26:54 +09:00
Trustin Lee
4b673c4ebb Fix infinite loop while handling a client socket / Retrofit EchoClient 2012-05-11 21:19:19 +09:00
Trustin Lee
b4610acda1 Implement connect timeout
- Merged ClientChannelConfig back to ChannelConfig
- AbstractChannel handles connect timeout making use of
  EventLoop.schedule()
2012-05-11 20:44:00 +09:00
Trustin Lee
83026f29a4 Make EventLoop a ScheduledExecutorService
- SingleThreadEventLoop now implements ScheduledExecutorService
  - Scheduled tasks are automatically fetched into taskQueue by
    pollTask() and takeTask()
- Removed MapBackedSet because Java 6 provides it
2012-05-11 20:19:57 +09:00
Trustin Lee
a4678a6030 Close all channels when SelectorEventLoop shuts down
- Also removed a FIXME which was fixed already
2012-05-11 11:01:44 +09:00
Trustin Lee
f6d6d1282c Simplify AbstractChannel.toString() 2012-05-11 10:47:45 +09:00
Trustin Lee
2134848111 Ensure the specified future has the correct channel / Cleanup 2012-05-11 09:00:35 +09:00
Trustin Lee
cb718a07c8 Move ChannelFutureFactory.newVoidFuture() to Channel.Unsafe() / Cleanup 2012-05-11 00:57:42 +09:00
Trustin Lee
da9ecadfc0 Introduce bypass buffer and use it in LoggingHandler
- Added ChannelBufferHolders.(inbound|outbound)BypassBuffer()
  - The holder returned by these methods returns the next handler's
    buffer.  When a handler's new(Inbound|Outbound)Buffer returns
    a bypass holder, your inboundBufferUpdated() and flush()
    implementation should check if the buffer is a bypass and should not
    modify the content of the buffer.
- Channel(Inbound|Outbound)?HandlerAdapter is now abstract.
  - A user has to specify the exact inbound/outbound buffer type
  - It's because there's no way to determine the best buffer type
- Implemented LoggingHandler using the new API.
  - It doesn't dump received or sent messages yet.
- Fixed a bug where DefaultUnsafe.close() does not trigger deregister()
- Fixed a bug where NioSocketChannel.isActive() does not return false
  when closed
2012-05-10 23:19:59 +09:00
Trustin Lee
532672deae Fix unnecessary application of Math.abs() 2012-05-10 21:56:10 +09:00
Trustin Lee
b4764f6164 Fix infinity loop and timing issues
- Made sure unnecessary interestOps are not OR'd
- Fixed a bug where DefaultChannelFuture.rethrowIfFailed() returns
  silently if the future is not done yet - there's no ways to tell
  the differences between failure and incompleteness.
2012-05-09 23:42:01 +09:00
Trustin Lee
129a2af86a Initial working version of the echo server example
- Optimized AbstractChannelBuffer.discardReadBytes()
- Split ChannelHandlerInvoker into ChannelInboundInvoker and
  ChannelOutboundInvoker
  - Channel implements ChannelOutboundInvoker
  - ChannelOutboundInvoker.nextOut() is now out()
  - ChannelOutboundHandlerContext.out() is now prevOut()
  - Added the outbound operations without future
    parameter to ChannelOutboundInvoker for user convenience
- All async operations which requires a ChannelFuture as a parameter
  now returns ChannelFuture for user convenience
- Added ChannelFutureFactory.newVoidFuture() to allow a user specify
  a dummy future that is of no use
  - I'm unsure if it is actually a good idea to introduce it. It might
    go away later.
- Made the contract of AbstractChannel.doXXX() much simpler and moved
  all common code up to AbstractChannel.DefaultUnsafe
- Added Channel.isOpen()
- Fixed a bug where MultithreadEventLoop always shut down its child
  event loops on construction
- Maybe more changes I don't remember :-)
2012-05-09 22:09:06 +09:00