Commit Graph

1145 Commits

Author SHA1 Message Date
Norman Maurer
12898a2ef4 Modify ChunkedInput to not return a chunk. It now read the chunk and directly transfer it. This helps to safe a copy on most cases 2012-06-10 20:31:14 +02:00
Trustin Lee
574d84e98e Remove ChannelBufferHolder / Add more handler interfaces for type safety
- ChannelInboundHandler and ChannelOutboundHandler does not have a type
  parameter anymore.  
- User should implement ChannelInboundMessageHandler or
  ChannelOutboundMessageHandler.
2012-06-10 12:22:32 +09:00
Trustin Lee
a849d11877 ChannelBuffers -> ByteBufs / Add MessageBuf & ChannelBuf
- Add MessageBuf which replaces java.util.Queue
- Add ChannelBuf which is common type of ByteBuf and ChannelBuf
- ChannelBuffers was renamed to ByteBufs
- Add MessageBufs
- All these changes are going to replace ChannelBufferHolder.
2012-06-10 11:31:39 +09:00
Trustin Lee
5164d91255 Rename ChannelBuffer to ByteBuf as discussed before
- ChannelBuffer gives a perception that it's a buffer of a
  channel, but channel's buffer is now a byte buffer or a message
  buffer.  Therefore letting it be as is is going to be confusing.
2012-06-10 11:08:43 +09:00
Trustin Lee
87f52aa604 Ensure that a user implements flush() or inboundBufferUpdated()
- Also prohibited a user from overriding
  ChannelInbound(Byte|Message)HandlerAdapter.  If a user wants to do
  that, he or she should extend ChannelInboundHandlerAdapter instead.
2012-06-10 10:48:11 +09:00
Trustin Lee
b6d5593e6a Do not wrap IOException with IOException 2012-06-10 04:30:56 +09:00
Trustin Lee
e376888d48 Replace 'Stream' with 'Byte'
- In computing, 'stream' means both byte stream and message stream,
  which is confusing.
- Also, we were already mixing stream and byte in some places and
  it's better use the terms consistently.
  (e.g. inboundByteBuffer & inbound stream)
2012-06-09 21:05:59 +09:00
Trustin Lee
468a3228a4 Fit every line into 120 columns 2012-06-08 19:28:12 +09:00
Trustin Lee
50fafdc3d3 Rewrite SslHandler / Reduce the chance of OIO-OIO dead lock
- SslHandler always begins handshake unless startTls is true
  - Removed issueHandshake property
  - If a user wants to start handshake later, he/she has to add 
    SslHandler later.
- Removed enableRenegotiation property
  - JDK upgrade fixes the security vulnerability - no need to complicate
    our code
- Some property name changes
  - getSSLEngineInboundCloseFuture() -> sslCloseFuture() 
- Updated securechat example
- Added timeout for handshake and close_notify for better security
  - However, it's currently hard-coded.  Will make it a property later.
2012-06-08 01:22:35 +09:00
Trustin Lee
4a23c2a6eb Fix checkstyle errors 2012-06-07 22:01:59 +09:00
Trustin Lee
994038975a Port HttpContentEncoder/Decoder to use EmbeddedStreamChannel / Cleanup
- Removed unused constructor parameter in AbstractChannel
- Re-enabled GZIP encoding in HTTP snoop example
2012-06-07 21:06:56 +09:00
Trustin Lee
8701e24b9a Add back Channel(Inbound|Outbound)(Message|Stream)HandlerAdapter
- they are useful when creating an anonymous class
- Also added back CombinedChannelHandler with extra constraints
2012-06-07 17:49:45 +09:00
Trustin Lee
aab71ccd8a Remove Channel(Inbound|Outbound)HandlerAdapter which does nothing
- Thanks to the recent refactoring, Channel(Inbound|Outbound)Handler-
  Adapter ended up having empty body.  No need to keep.
2012-06-07 17:25:15 +09:00
Trustin Lee
ea0c9cfe79 Post-overhaul fixes / Split LoggingHandler into three
- LoggingHandler now only logs state and operations
- StreamLoggingHandler and MessageLoggingHandler log the buffer content
- Added ChannelOperationHandlerAdapter
  - Used by WriteTimeoutHandler
2012-06-07 16:56:21 +09:00
Trustin Lee
5e93d206ff Overhaul - Split ChannelHandler & Merge ChannelHandlerContext
- Extracted some handler methods from ChannelInboundHandler into
  ChannelStateHandler
- Extracted some handler methods from ChannelOutboundHandler into
  ChannelOperationHandler
- Moved exceptionCaught and userEventTriggered are now in
  ChannelHandler
  
- Channel(Inbound|Outbound)HandlerContext is merged into
  ChannelHandlerContext
- ChannelHandlerContext adds direct access methods for inboud and
  outbound buffers
  - The use of ChannelBufferHolder is minimal now.
    - Before: inbound().byteBuffer()
    - After: inboundByteBuffer()
    - Simpler and better performance
    
- Bypass buffer types were removed because it just does not work at all
  with the thread model.
  - All handlers that uses a bypass buffer are broken.  Will fix soon.

- CombinedHandlerAdapter does not make sense anymore either because
  there are four handler interfaces to consider and often the two
  handlers will implement the same handler interface such as
  ChannelStateHandler.  Thinking of better ways to provide this feature
2012-06-07 14:52:33 +09:00
Trustin Lee
b1a156d3f2 Fix a build failure due to a dependency problem / Fix checkstyle errors 2012-06-07 09:15:53 +09:00
Trustin Lee
a9cc75dd3e Port SSL echo test
- Remove britspaces
2012-06-06 23:18:37 +09:00
norman
a4b2d70264 Remove some more synchronization stuff which is not needed anymore 2012-06-06 08:24:44 +02:00
norman
a56ea06e58 Only parse packet length once per packet. See #382 2012-06-06 08:20:30 +02:00
norman
f759d30538 Fix starttls support. Now SslHandler should be fully functional again 2012-06-06 08:06:12 +02:00
norman
2aea5291bd Port SslHandler to the new API. Everything except of starttls works 2012-06-06 07:52:28 +02:00
norman
35ba150db0 Fix BlockingReadHandler 2012-06-05 14:18:09 +02:00
norman
12069d3bf4 Eliminate most of the synchonization stuff in ChunkedWriteHandler as its not needed anymore with the new thread-model 2012-06-05 14:13:56 +02:00
Trustin Lee
1eced1e9e3 Update license headers 2012-06-04 13:31:44 -07:00
norman
1ed87601b8 Add a testcase to prove that we have no bug in ChunkedWriteHandler when notify futures 2012-06-04 15:14:44 +02:00
Trustin Lee
c6600b3bfd codec module is only used by tests
Thanks @normanmaurer
2012-06-03 02:25:16 -07:00
Trustin Lee
45f19d02ff Remove the codecs and handlers that can't make it on time for 4.0.0.A1
- Removed ones are: IP filer and HTTP multipart codec
  - Needs closer code review and polishing
  - Sorry. I'll add them back in the next alpha releases
  - SSL handler and ChunkedWriteHandler also need more work, but
    I really want to make them part of the first alpha because they
    are used pretty often by users.
2012-06-02 01:38:10 -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
14e68aca57 Fix a Javadoc error 2012-06-01 23:18:46 -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
754cd99843 Port ChunkedWriteHandler 2012-06-01 00:36:12 -07:00
Trustin Lee
7be188f8c0 Ported BlockingReadHandler 2012-05-31 16:44:51 -07:00
Trustin Lee
9bb5b34887 Remove BufferedWriteHandler
- All writes in Netty 4 are buffered by default and a user can call
  flush() to flush it.
2012-05-31 15:55:11 -07:00
Trustin Lee
2aa466640e Ported Read/WriteTimeoutHandler with simplification
- The default behavior is now to close the channel on timeout.  A user
  can override this behavior, but I would just use IdleStateHandler or
  use eventLoop's timer facility directly for finer control.
2012-05-31 15:53:38 -07:00
Trustin Lee
5f24f176bb Port ReadTimeoutHandler 2012-05-31 15:04:25 -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
Norman Maurer
5852d82ad6 Only send event upstream once the Ssl handshake was completed successfull. See #358
Conflicts:

	handler/src/main/java/io/netty/handler/ssl/SslHandler.java
2012-05-30 19:25:29 -07:00
Norman Maurer
e2bdc2234d Cleanup 2012-05-30 19:21:21 -07:00
Norman Maurer
e2a7462d70 Fix syntax. See #342 2012-05-30 19:14:10 -07:00
Jeff Pinner
2f71c001b4 Make SslBufferPool an interface 2012-05-30 19:13:52 -07:00
norman
7007e2fbaf Make all methods of SslBufferPool public so a subclass can be placed in another package. See #336 2012-05-30 19:12:26 -07:00
norman
1226cdacfb Use the correct ChannelBufferFactory when creating new ChannelBuffers. See #335
Conflicts:

	handler/src/main/java/io/netty/handler/ssl/SslHandler.java
2012-05-30 19:12:11 -07:00
norman
ed357181c0 Make sure SslHandler also works if SslBufferPool use non heap ByteBuffers. See #329
Conflicts:

	handler/src/main/java/io/netty/handler/ssl/SslHandler.java
2012-05-30 19:11:23 -07:00
Trustin Lee
117626e034 Add ChunkedWriteHandlerTest from branch 3 2012-05-30 18:50:33 -07:00
Trustin Lee
57d3d0cbb5 Update ChunkedWriteHandler to the latest revision at branch 3 2012-05-30 18:47:55 -07:00
norman
7b434e225f Make sure we fire the event from the io-thread. See #306 2012-05-30 18:45:57 -07:00
norman
31e643b32d Refactor ChunkedWriteHandler to remove synchronization which can have bad side effects like deadlocks. See #297 and #301
Conflicts:

	handler/src/main/java/io/netty/handler/stream/ChunkedWriteHandler.java
2012-05-30 18:45:28 -07:00
norman
280c65a28e Refactor ChunkedWriteHandler to remove synchronization which can have bad side effects like deadlocks. See #297 and #301
Conflicts:

	handler/src/main/java/io/netty/handler/stream/ChunkedWriteHandler.java
2012-05-30 18:43:52 -07:00
norman
f8f703e679 Add @Override annotations 2012-05-30 18:41:43 -07:00
norman
c705379adb Notify ChannelFuture's of queued writes if the SslHandler gets remove d from the ChannelPipeline. See #306 2012-05-30 18:41:32 -07:00
norman
c0bb070876 Fail all queued writes if the ChunkedWriteHandler is removed from the ChannelPipeline. See #304 2012-05-30 18:41:13 -07:00
norman
d308fa8fe1 Fail all pending writes on channelClosed(..). See #305 2012-05-30 18:40:59 -07:00
Norman Maurer
d1e6328102 Allow to register ChannelFutureListener's that get notified once the inbound of the SSLEngine is closed. See #137 2012-05-30 18:40:43 -07:00
Trustin Lee
f428853b35 Remove IpV4Subnet.main()
- Should run as a test case
2012-05-30 15:41:39 -07:00
Trustin Lee
54047c69cf Remove IpSubnet.main()
- Should be run as a test case
2012-05-30 15:40:51 -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
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
528b5c4328 Removed the modules that are not part of 4.0.0.Alpha1
- Will add them back before Beta1 is out
2012-05-27 19:28:28 -07: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
f00fadb9fd Simplify the construction of multi-threaded selector event loop
- Hide InternalLogger from users
2012-05-15 13:11:47 +09:00
Trustin Lee
7a5f4721b9 Optimize LoggingHandler using lookup tables 2012-05-12 08:31:13 +09:00
Trustin Lee
d02bc1c0d3 Log outbound buffer
- Use uppercase names for outbound events
2012-05-11 00:46:51 +09:00
Trustin Lee
d5b52077fe Remove hexdump option in LoggingHandler and dump always
- Allow a user override the log message instead
- Prettier hex dump
2012-05-11 00:39:44 +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
368156f5d0 Another round of the new API design
- Channel now creates a ChannelPipeline by itself

  I find no reason to allow a user to use one's own pipeline
  implementation since I saw nobody does except for the cases where a
  user wants to add a user attribute to a channel, which is now covered
  by AttributeMap.

- Removed ChannelEvent and its subtypes because they are replaced by
  direct method invocation.
- Replaced ChannelSink with Channel.unsafe()
- Various getter renaming (e.g. Channel.getId() -> Channel.id())
- Added ChannelHandlerInvoker interface
- Implemented AbstractChannel and AbstractServerChannel
- Some other changes I don't remember
2012-05-01 17:19:41 +09:00
Trustin Lee
fd0b0a4e2b Code cleanup 2012-03-30 12:48:28 +09:00
Trustin Lee
a81fa75c59 Fix #239: IdleStateHandler starts two timers
1) ReadTimeoutHandler is also affected by this bug - fixed
2) Reverted IdleStateHandler.beforeAdd() and channelConnected() -
without isAttached() check, timeout can be inaccurate if beforeAdd() is
called long before channelConnected().
2012-03-22 16:03:58 +09:00
Trustin Lee
f8253e031d Fix #239: IdleStateHandler starts two timers
1) Do not rely on ChannelPipeline.isAttached() to ensure initialize() is
called once.
2) Fix a race condition where initialize() can schedule timeouts after
destroy() is called.
2012-03-22 15:56:43 +09:00
Norman Maurer
b09bf5b1fb Tasks added to OrderedMemoryAwareThreadPoolExecutor may be lost in some
cases. See #234
2012-03-15 14:31:01 +01:00
Norman Maurer
3317dd7bff Make sure we don't try to use Channel.setReadable(true) if it was not
set by the threadpool itself. See #215
2012-03-04 19:32:44 +01:00
Norman Maurer
a071759575 Fix formatting 2012-03-02 09:35:16 +01:00
norman
0c46db317a Allow to handle only downstream events via the ExecutionHandler. See
#173
2012-03-02 09:28:43 +01:00
Norman Maurer
d8021fc6a8 Release ChildExecutor after the channel was closed. See #173 2012-03-01 21:36:34 +01:00
Trustin Lee
68f9c7a5f3 Fix #160 - Even more strict majorVersion check in SslHandler 2012-03-01 11:42:01 -08:00
Trustin Lee
4b583325b0 Fix #160 - No response to write if server is using SslHandler and client is not 2012-03-01 11:32:51 -08:00
Trustin Lee
4158152b24 Trigger exceptionCaught event from the middle of the pipline (#210)
.. because the previous handlers have no interest in the exceptions
raised by the next handlers.
2012-02-29 14:02:12 -08:00
Norman Maurer
8579f09c59 Merge pull request #210 from netty/threading_fix
Merge in fix for threading (related to #140 and #187). This also includes the new feature that allow to submit a Runnable that gets executed later in the io thread.
2012-02-29 12:11:46 -08:00
Trustin Lee
8ab9451086 Fix #208 - SslHandler does not use ChannelBufferFactory to create a new buffer
* Also fixed build failure caused by wrong fork mode
2012-02-29 09:19:18 -08:00
Norman Maurer
16fada5c23 Remove bogus constructor. See #173 2012-02-26 11:06:14 +01:00
Norman Maurer
5e43e879f2 Add OrderedDownstreamThreadPoolExecutor which can be used when using the
new feature of ExecutionHandler to also handle downstream events. This
is mainly useful for SEDA like stuff. See #173
2012-02-26 11:00:30 +01:00
Norman Maurer
68066c5e4b Make sure that ChannelDownstreamHandler impl fire exception caughts
later via the io-worker. See #140 and #187
2012-02-25 16:05:41 +01:00
norman
479def20bd Check if logging level is enabled before log. See #192 2012-02-17 10:37:41 +01:00
Norman Maurer
549546f944 Remove the child Executor with the right method so it will also work
when the channel is not the key.See #175
2012-02-03 15:50:36 +01:00
Trustin Lee
b9b2366361 Fix checkstyle violations / Renaming RXTX -> Rxtx 2012-01-15 01:08:00 +09:00
Trustin Lee
d40bd5e7f2 Rename IOStream example / Code cleanup 2012-01-15 00:43:28 +09:00
Trustin Lee
36bba6b29d Reverting the previous commit which makes no sense 2012-01-13 20:49:18 +09:00
Trustin Lee
b9386e7be8 Do not count a ChannelDownstreamEventRunnable
* MATPE is only for upstream events.
2012-01-13 20:48:18 +09:00
Trustin Lee
fde6789f41 Cleanup / Modify MATPE to reject a downstream event 2012-01-13 20:35:46 +09:00
Trustin Lee
958ffa50e3 Make ChannelUp/DownstreamEventRunnable non-final / Move the classes in execution.filter to execution 2012-01-13 18:04:06 +09:00
Trustin Lee
303c1b5f79 Overall cleanup / Add lost old jzlib headers 2012-01-13 17:41:18 +09:00
Trustin Lee
ebfc4513e0 Apply checkstyle to the build
Please note that the build will fail at the moment due to various checkstyle
violations which should be fixed soon
2012-01-11 20:16:14 +09:00
Norman Maurer
7c412848ef Fix NPE which is triggered if the destory method is called
before channelOpen(..). See #143
2012-01-07 19:42:00 +01:00
Trustin Lee
8663716d38 Issue #60: Make the project multi-module
Split the project into the following modules:
* common
* buffer
* codec
* codec-http
* transport
* transport-*
* handler
* example
* testsuite (integration tests that involve 2+ modules)
* all (does nothing yet, but will make it generate netty.jar)

This commit also fixes the compilation errors with transport-sctp on
non-Linux systems.  It will at least compile without complaints.
2011-12-28 19:44:04 +09:00