Commit Graph

878 Commits

Author SHA1 Message Date
Trustin Lee
307e6c47d8 Make hasUnsafe() return true only when all necessary low level operations are available for reliable direct buffer access 2013-03-05 17:25:54 +09:00
Trustin Lee
7e17f71b30 Make PlatformDependent work with the platforms without unaligned access support 2013-03-05 14:27:52 +09:00
Trustin Lee
d4d01ba52c Optimize SlicedByteBuf a little bit 2013-02-27 15:19:25 -08:00
Trustin Lee
49aa907bd0 [maven-release-plugin] prepare for next development iteration 2013-02-26 16:55:07 -08:00
Trustin Lee
5026c2f359 [maven-release-plugin] prepare release netty-4.0.0.Beta2 2013-02-26 16:54:53 -08:00
Trustin Lee
a9a8d5d8c2 Clean-up 2013-02-21 14:17:04 -08:00
Norman Maurer
74738fbd08 [#1061] Add workaround to not use PooledUnsafeDirectByteBuf when running on latest OpenJDK6 because of missing Unsafe method 2013-02-19 12:21:08 +01:00
Norman Maurer
4ed5b07e4e [#1060] Fix bug in CompositeByteBuf which let the buffer expand in a incorrect way and so result in corrupted data 2013-02-19 09:43:31 +01:00
Norman Maurer
1c6ed9b2ce Add javadocs 2013-02-17 20:12:48 +01:00
Trustin Lee
d68a04a879 [maven-release-plugin] prepare for next development iteration 2013-02-14 12:56:24 -08:00
Trustin Lee
59e638f8f5 [maven-release-plugin] prepare release netty-4.0.0.Beta1 2013-02-14 12:56:15 -08:00
Trustin Lee
1011227b88 Remove apiviz tags - we are focusing on user guide instead and putting diagrams there 2013-02-14 12:09:16 -08:00
Norman Maurer
7c002504a1 [#1051] Increment by the correct value 2013-02-14 14:28:47 +01:00
Norman Maurer
5370573400 Change ReferenceCounted.retain* to return itself and so allow method chaining 2013-02-14 07:39:44 +01:00
Trustin Lee
a1540a49d3 More safety in DefaultMessageBuf 2013-02-13 14:58:21 -08:00
Norman Maurer
a8216e7ce0 Fix possible NPE 2013-02-13 09:52:07 +01:00
Trustin Lee
4aacf50758 Prettify APIviz diagrams / Remove an empty package 2013-02-11 18:33:15 +09:00
Trustin Lee
aca0d5fa68 Make CompositeyteBuf and MessageBuf call release() on its elements when it is deallocated 2013-02-11 17:19:53 +09:00
Trustin Lee
bf0bfe9a69 Fix inspector warnings 2013-02-11 16:52:43 +09:00
Trustin Lee
0e341c9d72 Fix covariant return types in ChannelConfig interfaces for method chaining
- Does it really worth doing this? I'm tempted to remove support for method chaining for ChannelConfig.
2013-02-11 15:08:51 +09:00
Trustin Lee
4f6d05365a Fix a race condition in reference counter implementation / Reference count never goes below 0 2013-02-10 14:22:14 +09:00
Trustin Lee
b9996908b1 Implement reference counting
- Related: #1029
- Replace Freeable with ReferenceCounted
- Add AbstractReferenceCounted
- Add AbstractReferenceCountedByteBuf
- Add AbstractDerivedByteBuf
- Add EmptyByteBuf
2013-02-10 13:10:09 +09:00
Trustin Lee
43af599d52 Faster memory copy between direct buffer and byte array (part 2) 2013-02-09 02:09:37 +09:00
Trustin Lee
9a676bc7d5 Faster memory copy between direct buffer and byte array 2013-02-09 01:55:01 +09:00
Trustin Lee
affd514b8c Rename ByteBufUtil to BufUtil and move ChannelHandlerUtil.freeMessage() there / Remove ChannelHandlerUtil 2013-02-08 23:23:26 +09:00
Trustin Lee
44ea0a116f Replace ChannelHandlerUtil.unfoldAndAdd() with MessageBuf.unfoldAndAdd() / Remove unused methods in ChannelHandlerUtil 2013-02-08 23:07:20 +09:00
Trustin Lee
d4742bbe16 Clean up abstract ChannelHandler impls / Remove ChannelHandlerContext.hasNext*()
- Rename ChannelHandlerAdapter to ChannelDuplexHandler
- Add ChannelHandlerAdapter that implements only ChannelHandler
- Rename CombinedChannelHandler to CombinedChannelDuplexHandler and
  improve runtime validation
- Remove ChannelInbound/OutboundHandlerAdapter which are not useful
- Make ChannelOutboundByteHandlerAdapter similar to
  ChannelInboundByteHandlerAdapter
- Make the tail and head handler of DefaultChannelPipeline accept both
  bytes and messages.  ChannelHandlerContext.hasNext*() were removed
  because they always return true now.
- Removed various unnecessary null checks.
- Correct method/field names:
  inboundBufferSuspended -> channelReadSuspended
2013-02-07 23:47:45 +09:00
Trustin Lee
7eed272e57 Add FilteredMessageBuf 2013-02-07 23:37:04 +09:00
Norman Maurer
fd75615d7a [#870] Convert all modules into osgi bundles 2013-02-06 07:57:11 +01:00
Trustin Lee
2ec932798f Replace .readable() and .writable() to .isReadable() and .isWritable() 2013-01-31 18:24:33 +01:00
Trustin Lee
42c65cca3a Make MessageBuf bounded
- Move common methods from ByteBuf to Buf
- Rename ensureWritableBytes() to ensureWritable()
- Rename readable() to isReadable()
- Rename writable() to isWritable()
- Add isReadable(int) and isWritable(int)
- Add AbstractMessageBuf
- Rewrite DefaultMessageBuf and QueueBackedMessageBuf
  - based on Josh Bloch's public domain ArrayDeque impl
2013-01-31 18:11:06 +01:00
Norman Maurer
ee9f30a2b9 *ChannelBuffer* -> *ByteBuf* and ChannelBuffersTest -> UnpooledTest 2013-01-21 21:02:25 +01:00
Courtney Robinson
7b6cbdbb1e [#964] ByteBuf.readLine() must return null when no more data is available in ByteBuf 2013-01-21 20:56:00 +01:00
Trustin Lee
ba8c8171fa Fix leaks in buffer tests 2013-01-18 13:49:17 +09:00
Trustin Lee
b5c87b0f9c Fix failing tests 2013-01-18 13:34:00 +09:00
Trustin Lee
d0afe6cad0 Consistent exception messages 2013-01-18 13:10:54 +09:00
Trustin Lee
ad15155f04 Ensure cascaded derivation of a buffer does not result in an infinitely nested buffer. 2013-01-17 13:55:48 +09:00
Trustin Lee
d806e3bf81 SwappedByteBuf.unwrap() should return null
Fixes #945.  For swapped wrapped buffers, it should not return null.
2013-01-17 12:05:43 +09:00
Trustin Lee
34820511ff Second HTTP overhaul
- Rename message types for clarity
  - HttpMessage -> FullHttpMessage
  - HttpHeader -> HttpMessage
  - HttpRequest -> FullHttpRequest
  - HttpResponse -> FulllHttpResponse
  - HttpRequestHeader -> HttpRequest
  - HttpResponseHeader -> HttpResponse
- HttpContent now extends ByteBufHolder; no more content() method
- Make HttpHeaders abstract, make its header access methods public, and
  add DefaultHttpHeaders
- Header accessor methods in HttpMessage and LastHttpContent are
  replaced with HttpMessage.headers() and
  LastHttpContent.trailingHeaders(). Both methods return HttpHeaders.
- Remove setters wherever possible and remove 'get' prefix
- Instead of calling setContent(), a user can either specify the content
  when constructing a message or write content into the buffer.
  (e.g. m.content().writeBytes(...))
- Overall cleanup & fixes
2013-01-16 23:46:02 +09:00
Trustin Lee
337f5bbb8e Automatic diagnosis of resource leaks
Now that we are going to use buffer pooling by default, it is obvious
that a user will forget to call .free() and report memory leak. In this
case, we should have a tool to determine if it is a bug in our allocator
implementation or in the user's code.

This pull request adds a system property flag called
'io.netty.resourceLeakDetection'. If set, when a user forgets to call
.free(), the ResourceLeakDetector will detect it and log a message with
detailed stack trace to tell where the leaked buffer has been allocated.

Because obtaining stack trace is an expensive operation, I used sampling
technique. Allocation is recorded only for every 113th allocation. I
chose 113 because it's a prime number.

In production, a user might not want to enable this option due to
potential performance impact. If a user does not specify the
'-Dio.netty.resourceLeakDetection' option leak detection is disabled.

Even if the leak detection is enabled, the overhead should be less than
5% because only ~1% of allocations are monitored.

I also replaced SharedResourceMisuseDetector with ResourceLeakDetector.
2013-01-15 14:15:27 +09:00
Trustin Lee
04bae9bceb Use sun.misc.Unsafe to access a direct ByteBuffer
- Add PooledUnsafeDirectByteBuf, a variant of PooledDirectByteBuf, which
  accesses its underlying direct ByteBuffer using sun.misc.Unsafe.
- To decouple Netty from sun.misc.*, sun.misc.Unsafe is accessed via
  PlatformDependent.
- This change solely introduces about 8+% improvement in direct memory
  access according to the tests conducted as described in #918
2013-01-11 16:25:12 +09:00
Norman Maurer
e564157381 Fix one checkstyle and one compile error caused by the last commit 2013-01-11 07:45:22 +01:00
Norman Maurer
75b2dd592a Merge branch 'master' of github.com:netty/netty 2013-01-11 07:33:54 +01:00
Trustin Lee
64ae8b6a37 Replace and merge DetectionUtil and DirectByteBufUtil into PlatformDependent and PlatformDependent0
PlatformDependent delegates the operations requires sun.misc.* to PlatformDependent0 to avoid runtime errors due to missing sun.misc.* classes.
2013-01-11 14:03:27 +09:00
Trustin Lee
896bbb67b6 Use sun.misc.Unsafe to access a direct buffer if possible 2013-01-10 21:30:11 +01:00
Norman Maurer
5b5b39a606 [#916] Only access Cleaner if it is really present to prevent errors on android 2013-01-10 20:03:54 +01:00
Trustin Lee
5bd8b41a58 Use Number.reverseBytes() instead of custom impl 2013-01-10 18:47:21 +09:00
Trustin Lee
340da3e97b Fix infinite recursion 2013-01-10 18:43:20 +09:00
Trustin Lee
eb337ff5a7 Fix various inspection warnings 2013-01-10 15:23:58 +09:00
Trustin Lee
8f7fba2d39 Optimize AbstractByteBuf.adjustMarkers() 2013-01-04 23:51:11 +09:00
Norman Maurer
364b7d1430 Make sure the Unpooled.EMTPY_BUFFER can not be freed and the capacity can not be changed 2013-01-03 22:49:25 +01:00
Norman Maurer
37a3f2e3b8 [#887] [#866] [#883] Add unified interface for Message oriented protocols and also use direct buffers for them 2013-01-03 18:15:53 +01:00
Norman Maurer
8a7bc2c606 Add a lot of javadocs to make usage more clear 2012-12-21 22:22:40 +01:00
Trustin Lee
67da6e4bf9 Remove the notion of ByteBufAllocator.bufferMaxCapacity()
- Allocate the unpooled memory if the requested capacity is greater then the chunkSize
- Fixes #834
2012-12-19 17:35:32 +09:00
Trustin Lee
0e017db89a Return the new buffer's capacity is same with the requested capacity
- Rename capacity variables to reqCapacity or normCapacity to distinguish if its the request capacity or the normalized capacity
- Do not reallocate on ByteBuf.capacity(int) if reallocation is unnecessary; just update the index range.
- Revert the workaround in DefaultChannelHandlerContext
2012-12-19 16:50:05 +09:00
Trustin Lee
a8f5efdb26 Add proper boundary / freeness check on ByteBuf impls
- Fixes #827
2012-12-17 18:27:30 +09:00
Trustin Lee
ca93b624ff Add IllegalBufferAccessException and checks on MessageBuf impls
- Related: #827
2012-12-17 18:03:31 +09:00
Trustin Lee
def12a171c Rename ChannelBuf to Buf and ChannelBufType to BufType
- Fixes #825
2012-12-17 17:43:45 +09:00
Trustin Lee
03e68482bb Remove ChannelBuf/ByteBuf.Unsafe
- Fixes #826
Unsafe.isFreed(), free(), suspend/resumeIntermediaryAllocations() are not that dangerous. internalNioBuffer() and internalNioBuffers() are dangerous but it seems like nobody is using it even inside Netty. Removing those two methods also removes the necessity to keep Unsafe interface at all.
2012-12-17 17:41:21 +09:00
Trustin Lee
33134b1343 Ensure PooledByteBuf.init() is not called with null memory 2012-12-17 16:02:21 +09:00
Trustin Lee
5ffb495746 Do not allow suspendIntermediaryDeallocations() after free() 2012-12-14 18:39:00 +09:00
Trustin Lee
5a4a59406b Merge ByteBuf.hasNioBuffer() and hasNioBuffers()
- Fixes #797
2012-12-14 12:20:33 +09:00
Trustin Lee
8e1a6c6cf5 Add ByteBuf.maxWritableBytes()
- Fixes #806
2012-12-14 11:49:01 +09:00
Trustin Lee
ad10518fca Fix the incorrect snapshot version number 2012-12-13 22:49:31 +09:00
Trustin Lee
b47fc77522 Add PooledByteBufAllocator + microbenchmark module
This pull request introduces the new default ByteBufAllocator implementation based on jemalloc, with a some differences:

* Minimum possible buffer capacity is 16 (jemalloc: 2)
* Uses binary heap with random branching (jemalloc: red-black tree)
* No thread-local cache yet (jemalloc has thread-local cache)
* Default page size is 8 KiB (jemalloc: 4 KiB)
* Default chunk size is 16 MiB (jemalloc: 2 MiB)
* Cannot allocate a buffer bigger than the chunk size (jemalloc: possible) because we don't have control over memory layout in Java. A user can work around this issue by creating a composite buffer, but it's not always a feasible option. Although 16 MiB is a pretty big default, a user's handler might need to deal with the bounded buffers when the user wants to deal with a large message.

Also, to ensure the new allocator performs good enough, I wrote a microbenchmark for it and made it a dedicated Maven module. It uses Google's Caliper framework to run and publish the test result (example)

Miscellaneous changes:

* Made some ByteBuf implementations public so that those who implements a new allocator can make use of them.
* Added ByteBufAllocator.compositeBuffer() and its variants.
* ByteBufAllocator.ioBuffer() creates a buffer with 0 capacity.
2012-12-13 22:35:06 +09:00
Trustin Lee
51e6519b67 Replace UnsafeByteBuf with ByteBuf.unsafe() again
* UnsafeByteBuf is gone. I added ByteBuf.unsafe() back.
* To avoid extra instantiation, all ByteBuf implementations implement the ByteBuf.Unsafe interface.
* To hide this implementation detail, all ByteBuf implementations are package-private.
* AbstractByteBuf and SwappedByteBuf are public and they do not implement ByteBuf.Unsafe because they don't need to.
* unwrap() is not an unsafe operation anymore.
* ChannelBuf also has unsafe() and Unsafe. ByteBuf.Unsafe extends ChannelBuf.unsafe(). ChannelBuf.unsafe() provides free() operation so that a user does not need to down-cast the buffer in freeInbound/OutboundBuffer().
2012-12-05 19:28:56 +09:00
Norman Maurer
85c570505b [maven-release-plugin] prepare for next development iteration 2012-12-03 20:34:05 +01:00
Norman Maurer
17d77ed160 [maven-release-plugin] prepare release netty-4.0.0.Alpha8 2012-12-03 20:33:49 +01:00
Trustin Lee
33c0c89fef Remove unnecessary empty lines 2012-12-03 19:58:13 +09:00
Trustin Lee
e45ab1d182 Fix a checkstyle error 2012-12-02 22:03:11 +09:00
Trustin Lee
5f9090a7f0 Fix invalid memory access in AIO writes
To perform writes in AioSocketChannel, we get a ByteBuffer view of the
outbound buffer and specify it as a parameter when we call
AsynchronousSocketChannel.write().

In most cases, the write() operation is finished immediately.  However,
sometimes, it is scheduled for later execution.  In such a case, there's
a chance for a user's handler to append more data to the outbound
buffer.

When more data is appended to the outbound buffer, the outbound buffer
can expand its capacity by itself.  Changing the capacity of a buffer is
basically made of the following steps:

1. Allocate a larger new internal memory region.
2. Copy the current content of the buffer to the new memory region.
3. Rewire the buffer so that it refers to the new region.
4. Deallocate the old memory region.

Because the old memory region is deallocated at the step 4, the write
operation scheduled later will access the deallocated region, leading
all sort of data corruption or even segfaults.

To prevent this situation, I added suspendIntermediaryDeallocations()
and resumeIntermediaryDeallocations() to UnsafeByteBuf.

AioSocketChannel.doFlushByteBuf() now calls suspendIntermediaryDealloc()
to defer the deallocation of the old memory regions until the completion
handler is notified.
2012-12-02 21:50:33 +09:00
Trustin Lee
bfe2a96505 Fix AssertionError from AsyncSocketChannel.beginRead()
An AssertionError is triggered by a ByteBuf when beginRead() attempts to
access the buffer which has been freed already.  This commit ensures the
buffer is not freed before performing an I/O operation.

To determine if the buffer has been freed, UnsafeByteBuf.isFreed() has
been added.
2012-12-02 20:17:53 +09:00
Trustin Lee
6208c62888 Fix inspector warnings introduced by recent mergences 2012-11-30 23:01:57 +09:00
Trustin Lee
81e2db10fa ByteBufAllocator API w/ ByteBuf perf improvements
This commit introduces a new API for ByteBuf allocation which fixes
issue #643 along with refactoring of ByteBuf for simplicity and better
performance. (see #62)

A user can configure the ByteBufAllocator of a Channel via
ChannelOption.ALLOCATOR or ChannelConfig.get/setAllocator().  The
default allocator is currently UnpooledByteBufAllocator.HEAP_BY_DEFAULT.

To allocate a buffer, do not use Unpooled anymore. do the following:

  ctx.alloc().buffer(...); // allocator chooses the buffer type.
  ctx.alloc().heapBuffer(...);
  ctx.alloc().directBuffer(...);

To deallocate a buffer, use the unsafe free() operation:

  ((UnsafeByteBuf) buf).free();

The following is the list of the relevant changes:

- Add ChannelInboundHandler.freeInboundBuffer() and
  ChannelOutboundHandler.freeOutboundBuffer() to let a user free the
  buffer he or she allocated. ChannelHandler adapter classes implement
  is already, so most users won't need to call free() by themselves.
  freeIn/OutboundBuffer() methods are invoked when a Channel is closed
  and deregistered.

- All ByteBuf by contract must implement UnsafeByteBuf. To access an
  unsafe operation: ((UnsafeByteBuf) buf).internalNioBuffer()

- Replace WrappedByteBuf and ByteBuf.Unsafe with UnsafeByteBuf to
  simplify overall class hierarchy and to avoid unnecesary instantiation
  of Unsafe instances on an unsafe operation.

- Remove buffer reference counting which is confusing

- Instantiate SwappedByteBuf lazily to avoid instantiation cost

- Rename ChannelFutureFactory to ChannelPropertyAccess and move common
  methods between Channel and ChannelHandlerContext there. Also made it
  package-private to hide it from a user.

- Remove unused unsafe operations such as newBuffer()

- Add DetectionUtil.canFreeDirectBuffer() so that an allocator decides
  which buffer type to use safely
2012-11-22 15:10:59 +09:00
dantran
4107b08f29 Only generate OSGi manifest only at all-in-on sub module to reduce the complexity to the build 2012-11-19 06:27:18 +01:00
dantran
105f952f5d Clean up maven-bungle-plugin warnings 2012-11-12 11:42:42 +01:00
dantran
e236f5b77d [#154] [#727] Use maven-plugin-plugin to generate OSGi manifest 2012-11-12 09:15:36 +01:00
Trustin Lee
6f2840193a Fix inspection warnings related with JUnit usage 2012-11-12 12:45:06 +09:00
Trustin Lee
aedf8790c3 Fix various Javadoc issues / Do not use argN parameter names 2012-11-12 12:26:19 +09:00
Trustin Lee
ea4a0e3535 Prefer {@code ...} to <code>...</code> / Fix deprecation warnings 2012-11-12 11:51:23 +09:00
Trustin Lee
b195190b2a Remove an unused import 2012-11-12 11:26:29 +09:00
Trustin Lee
4dce19b814 Replace a variable with a constant wherever possible 2012-11-12 09:43:14 +09:00
Trustin Lee
aa7cd691df Remove redundant 'else' branches. 2012-11-12 09:31:40 +09:00
Trustin Lee
b4f796c5e3 Use 'x' over "x" wherever possible / String.equals("") -> isEmpty() 2012-11-10 08:03:52 +09:00
Trustin Lee
4e0f455e69 Remove methods overridden but identical with the super implementation / Make constructors of abstract classes protected rather than non-sense public
AbstractWrappedByteBuf.capacity(int) should raise a UnsupportedOperationException rather than ReadOnlyBufferException.
2012-11-10 07:10:30 +09:00
Trustin Lee
58ba0de659 Remove unnecessarily qualified static access 2012-11-10 01:32:21 +09:00
Trustin Lee
2ab38d8685 Remove pointless bitwise expressions 2012-11-09 17:26:11 +09:00
Norman Maurer
313f777491 [maven-release-plugin] prepare for next development iteration 2012-11-05 23:08:39 +01:00
Norman Maurer
57da8222a4 [maven-release-plugin] prepare release netty-4.0.0.Alpha7 2012-11-05 23:08:28 +01:00
Norman Maurer
d293e6c389 [#707] Hopefully now the correct fix for it which also takes the index into account when consolidate 2012-11-04 21:21:26 +01:00
Veebs
36ac52a4bd Port http multipart package. See #709 2012-11-04 13:59:50 +01:00
Norman Maurer
4e3258973f [#707] Fix IndexOutOfBoundsException which could accour when the buffer is consolitated in the middle of an operation 2012-11-03 20:00:48 +01:00
Norman Maurer
122051ba44 Only a few javadocs 2012-10-28 20:45:00 +01:00
Norman Maurer
87cc67306f [maven-release-plugin] prepare for next development iteration 2012-10-28 18:41:25 +01:00
Norman Maurer
7315490fca [maven-release-plugin] prepare release netty-4.0.0.Alpha6 2012-10-28 18:41:17 +01:00
Norman Maurer
afc687436a Revert "[maven-release-plugin] prepare release netty-4.0.0.Alpha6"
This reverts commit 95de4db0f1.
2012-10-28 18:36:15 +01:00
Norman Maurer
16eb4ec713 Revert "[maven-release-plugin] prepare for next development iteration"
This reverts commit e3e0776c20.
2012-10-28 18:35:47 +01:00
Norman Maurer
e3e0776c20 [maven-release-plugin] prepare for next development iteration 2012-10-28 13:06:07 +01:00
Norman Maurer
95de4db0f1 [maven-release-plugin] prepare release netty-4.0.0.Alpha6 2012-10-28 13:05:59 +01:00
Norman Maurer
cbcabaf29b Add support for method chaining to ByteBuf 2012-10-18 08:57:23 +02:00
Trustin Lee
820af50b63 [maven-release-plugin] prepare for next development iteration 2012-09-28 17:57:40 +09:00
Trustin Lee
595e1067c7 [maven-release-plugin] prepare release netty-4.0.0.Alpha5 2012-09-28 17:57:04 +09:00
Norman Maurer
b8ae8be96a Fix IndexOutOfBoundException when using CompositeChannelBuffer and the readerIndex is at the last position and an empty array is passed to read to. See #474 2012-09-22 21:23:58 +02:00
norman
3295145e88 [maven-release-plugin] prepare for next development iteration 2012-09-13 10:40:52 +02:00
norman
42685759de [maven-release-plugin] prepare release netty-4.0.0.Alpha4 2012-09-13 10:40:44 +02:00
Trustin Lee
f2538a996d [maven-release-plugin] prepare for next development iteration 2012-08-30 16:47:52 +09:00
Trustin Lee
628c5598b3 [maven-release-plugin] prepare release netty-4.0.0.Alpha3 2012-08-30 16:46:58 +09:00
Norman Maurer
5dbb799a92 Merge pull request #554 from jfallows/composite-buffer
Prevent Unpooled.EMPTY_BUFFER from being stored in the composite buffer ...
2012-08-23 22:26:03 -07:00
Trustin Lee
73720c422d [maven-release-plugin] prepare for next development iteration 2012-08-21 15:41:04 +09:00
Trustin Lee
68bef8cb99 [maven-release-plugin] prepare release netty-4.0.0.Alpha2 2012-08-21 15:40:45 +09:00
Trustin Lee
0a43350c66 [maven-release-plugin] prepare for next development iteration 2012-08-21 14:41:45 +09:00
Trustin Lee
56211fee59 [maven-release-plugin] prepare release netty-4.0.0.Alpha2 2012-08-21 14:39:59 +09:00
Trustin Lee
a0e34fd93a [maven-release-plugin] prepare for next development iteration 2012-08-21 14:13:38 +09:00
Trustin Lee
72ccf65093 [maven-release-plugin] prepare release netty-4.0.0.Alpha2 2012-08-21 14:13:17 +09:00
John Fallows
83c21d70ee Prevent Unpooled.EMPTY_BUFFER from being stored in the composite buffer due to a zero length slice, which causes reference counting problems on subsequent discardReadBytes. 2012-08-19 22:59:49 -07:00
Trustin Lee
df0aee22cb [#540] Add a variant of ByteBuf.ensureWritableBytes() which does not throw an exception 2012-08-20 12:52:38 +09:00
Trustin Lee
aa8a761fe2 Better exception message
.. as advised by @jpinner
2012-08-20 12:30:38 +09:00
Trustin Lee
505e767a09 [#529] ByteBuf.ensureWritableBytes() can trigger IllegalArgumentException
- Remove redundant boundary check in ensureWritableBytes()
- Ensure calculateNewCapacity() never returns the value that exceeds
  maxCapacity
2012-08-17 22:08:36 +09:00
John Fallows
06fd869711 Add support for AIO scattering reads and gathering writes.
o Add ByteBuf.hasNioBuffers() method
 o Promote CompositeByteBuf.nioBuffers() methods to ByteBuf
 o Use ByteBuf.nioBuffers() methods from AioSocketChannel
2012-08-12 17:29:07 -07:00
Trustin Lee
501746aeff Fix an infinite loop in DefaultCompositeByteBuf.setBytes() 2012-08-08 17:42:58 +09:00
Trustin Lee
a2aadef4da Add ByteBuf.Unsafe.discardSomeReadBytes() to reduce discardReadBytes() 2012-08-08 17:34:00 +09:00
norman
f7e0366bae Add nioBuffers() and nioBuffers(..) method which will be used to support gathering writes for the AIO transport. See #492 2012-08-07 15:39:46 +02:00
Trustin Lee
728306b64f Add CompositeByteBuf.consolidate()
- also added test cases that test automatic / full / ranged
  consolidation
2012-08-05 18:32:30 +09:00
Trustin Lee
26e64eb305 Fix IOOBE after buffer truncation / Add CompositeByteBuf.addComponents()
- plus some bug fixes while running unit tests
2012-07-20 13:18:17 +09:00
Trustin Lee
8d813b127c Replace free() with reference counting / Fix SlicedByteBuf.unsafe()
- based on @normanmaurer's feed back
- Added Unpooled.compositeBuffer(int)
2012-07-20 12:33:17 +09:00
Trustin Lee
5a613f379e Make ByteBuf dynamic / Introduce an interface for composite buffers
- Replace ByteBufferBackedByteBuf with DirectByteBuf
- Make DirectByteBuf and HeapByteBuf dynamic
- Remove DynamicByteBuf
- Replace Unpooled.dynamicBuffer() with Unpooled.buffer() and
  directBuffer()
- Remove ByteBufFactory (will be replaced with ByteBufPool later)
- Add ByteBuf.Unsafe (might change in the future)
2012-07-19 20:25:47 +09:00
Trustin Lee
d801459cb8 [maven-release-plugin] prepare for next development iteration 2012-07-10 23:11:33 +09:00
Trustin Lee
527f2f6c6e [maven-release-plugin] prepare release netty-4.0.0.Alpha1 2012-07-10 23:10:48 +09:00
Trustin Lee
917ed5173e Fix a bug where discardReadBytes() doesn't adjust markers
.. if buffer is empty
2012-07-10 14:23:31 +09:00
Cruz Julian Bishop
b9d16663d9 Fixes javadoc from #414 / #415 (@trustin) 2012-06-30 20:30:56 +10:00
Norman Maurer
27b83a480b Fix checkstyle 2012-06-29 12:49:58 +02:00
Norman Maurer
07095a41f4 Rename method and make it more clear thats an expert method. See #414 #415 2012-06-29 12:28:08 +02:00
Cruz Julian Bishop
c52cb0ea21 Assuming that @trustin will want this changed :) 2012-06-29 19:27:41 +10:00
Cruz Julian Bishop
c55e10c12a Fix a bug where a potential overflow occurs 2012-06-29 13:38:53 +10:00
Cruz Julian Bishop
b11d4fa37a Two tentative last asserts in the test 2012-06-29 13:37:41 +10:00
Cruz Julian Bishop
557f1c85df Little bit more testing 2012-06-29 13:35:14 +10:00
Cruz Julian Bishop
3d9be81377 Provide a basic test for getBufferFor() 2012-06-29 13:31:02 +10:00
Cruz Julian Bishop
e2989719e1 Comply with line width a bit more 2012-06-28 19:34:52 +10:00
Cruz Julian Bishop
a504aa1159 Documentation and checkstyle fixes from @fredericBregier
This is part of #414
2012-06-28 19:33:54 +10:00
Cruz Julian Bishop
42f3a6750a Add documentation and changes to ComposityByteBuf.getBufferFor(index)
Thanks to @kimchy and @fredericBregier
This is part of #414
2012-06-28 19:01:16 +10:00
Cruz Julian Bishop
49f0e32428 Actually throw the correct Exception type. Whoops!
This should be done, now.
2012-06-28 10:31:49 +10:00
Cruz Julian Bishop
332a35f9ed Simplify the process of getting the component 2012-06-28 10:29:11 +10:00
Cruz Julian Bishop
cb8c9767f6 Adds a method to get the buffer for a specific index in CompositeByteBuf
This fixes #414
2012-06-28 10:24:18 +10:00
Trustin Lee
1be9bbf62c Add CompositeByteBuf.numComponents() 2012-06-24 22:14:17 +09:00
Trustin Lee
8b7af2ca3b Generate Javadoc with APIviz 2012-06-13 12:11:11 +09:00
Trustin Lee
3b562c917d Move ChannelBufferType to netty-buffers and rename it to ChannelBufType
- Also add ChannelBuf.type()
2012-06-12 17:05:28 +09:00
Trustin Lee
ecd0ae5406 Prefer MessageBuf over Queue where possible
- Also replaced thread safe queues with non-thread-safe ones where
  possible
- Unpooled.wrappedBuffer(Queue<T>) does not wrap MessageBuf anymore
2012-06-12 17:02:00 +09:00
Trustin Lee
6211e53e86 Code clean-up based on IntelliJ code analysis 2012-06-11 22:54:28 +09:00
Trustin Lee
40a7659784 Move utility methods in Unpooled to ByteBufUtil 2012-06-11 20:41:19 +09:00
Trustin Lee
754392aaa9 Add ByteBuf.order(ByteOrder) method to simplify little endian access
- Removed all methods that requires ByteOrder as a parameter
  from Unpooled (formerly ByteBufs/ChannelBuffers)
  - Instead, a user calls order(ByteOrder) to get a little endian
    version of the user's buffer
  - This gives less overwhelming number of methods in Unpooled.
2012-06-11 20:24:44 +09:00
Trustin Lee
876847fd20 Merge MessageBufs and ByteBufs into Unpooled
- e.g. Unpooled.messageBuffer()
- It will make much more sense once we introduce pooling:
  - i.e. Pooled.buffer()
2012-06-11 17:02:29 +09: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
468a3228a4 Fit every line into 120 columns 2012-06-08 19:28:12 +09:00
Trustin Lee
c2e65016fd Fixed some checkstyle errors 2012-06-04 13:43:02 -07:00
Trustin Lee
1eced1e9e3 Update license headers 2012-06-04 13:31:44 -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
77274ae743 Automated code clean-up 2012-05-31 12:03:01 -07:00
Trustin Lee
c8fa42beaf Rename wrapPrimitive() to copyPrimitive() / Add tests / Tidy up (#167)
- Add ChannelBuffers.copyShort(short...)
2012-05-31 11:13:01 -07:00
Trustin Lee
429535e6c8 More primitive wrapper methods (#167)
- ChannelBuffers.wrap(Float|Double)(...)
- Handle the case where there is only one value.
2012-05-31 10:51:27 -07:00
Trustin Lee
c32df371ab Fix compilation errors 2012-05-31 01:55:30 -07:00
norman
7fb64e2046 A small optimization for the fix of #360 2012-05-30 23:06:06 -07:00
Sun Ning
f2df20ddff fix #360, add check for empty buffer; also add unit test for this scenario 2012-05-30 23:05:43 -07:00
Cruz Julian Bishop
f6f246cac0 Added messages to all IndexOutOfBoundsExceptions
I need to implement this to help myself finish more future pull requests which, so far, are plagued by these exceptions with no information available.
2012-05-30 19:25:45 -07:00
norman
a8d63a4ad7 Make sure CompositeChanneBuffer does not throw a UnsupportedOperationException if discardReadBytes() discard the whole content of the buffer. See #325 2012-05-30 19:09:41 -07:00
Trustin Lee
57d3d0cbb5 Update ChunkedWriteHandler to the latest revision at branch 3 2012-05-30 18:47:55 -07:00
Trustin Lee
b5d715343a Fail if DynamicChannelBuffer attempts to exceed the max capacity (#258)
- Contributed by @normanmaurer
2012-05-30 15:51:24 -07:00
Trustin Lee
e2d69120bb Ported OIO socket/datagram transport to the new API 2012-05-25 13:58:56 -07:00
Trustin Lee
02cb7adf03 Reduce GC in ChannelBuffer bulk operations
- Pre-create an NIO ByteBuffer for reuse instead of creating a new one
  every time
2012-05-25 06:10:10 -07: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
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
Trustin Lee
fd0b0a4e2b Code cleanup 2012-03-30 12:48:28 +09:00
Trustin Lee
c28137b0b2 Improve ChannelBufferInputStream documentation 2012-03-26 18:10:16 +09:00
Norman Maurer
2b9df060dd Add support to wrap primitives via ChannelBuffers.wrap*(..) easily. See
#167
2012-02-26 20:51:53 +01: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
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