Commit Graph

253 Commits

Author SHA1 Message Date
Trustin Lee
d19b575c31 Fix an incorrect modulo operation 2013-03-14 13:17:07 +09:00
Trustin Lee
4323fea5fb Fix a bug where TypeParameterMatcher does not detect the case where the type parameter is derived from an outer class
- Fixes #1153
2013-03-14 07:22:44 +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
Trustin Lee
cef81f1bff Revert e66fc219ff 2013-03-12 16:44:25 +09:00
Norman Maurer
17ebbdec20 Let ChannelGroupFuture extends ChannelFuture and ChannelGroupFutureListener GenericFutureListener 2013-03-12 08:35:39 +01:00
Trustin Lee
ed825de4bf Fix a bug where TypeParameterMatcher raises ClassCastException when an instance with raw type parameter is given 2013-03-09 09:19:34 +09:00
Trustin Lee
4f2e347625 More concise exception message 2013-03-09 08:48:22 +09:00
Norman Maurer
8d7f1e2820 Add stacktrace to the IllegalStateException which is thrown if a Promise was notified before 2013-03-08 15:11:29 +01:00
Trustin Lee
12f1d96914 Relaxed memory access constraint of ReferenceCounted.refCnt() for potentially better performance / More precise reference counting for MessageBuf 2013-03-08 10:32:20 +09:00
Trustin Lee
41ab17b9bf Fix inspection warnings in HashedWheelTimer 2013-03-08 08:45:17 +09:00
Prajwal Tuladhar
e66fc219ff port fix from Akka for HashedWheelTimer
Ported from commits:

* cb4e3536b0
* 7e590f3071
2013-03-08 08:25:37 +09:00
Norman Maurer
88cc8c1739 [#1065] Provide Future/Promise without channel reference 2013-03-07 07:21:37 +01:00
Trustin Lee
c5f606e632 Warn in case of incomplete low-level API 2013-03-05 18:06:01 +09:00
Trustin Lee
8d88acb4a7 Change ByteBufAllocator.buffer() to allocate a direct buffer only when the platform can handle a direct buffer reliably
- Rename directbyDefault to preferDirect
 - Add a system property 'io.netty.prederDirect' to allow a user from changing the preference on launch-time
 - Merge UnpooledByteBufAllocator.DEFAULT_BY_* to DEFAULT
2013-03-05 17:55:24 +09:00
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
Norman Maurer
faaff91dd0 Fix checkstyle 2013-03-05 07:06:52 +01:00
Trustin Lee
7e17f71b30 Make PlatformDependent work with the platforms without unaligned access support 2013-03-05 14:27:52 +09:00
Trustin Lee
881bd8eea3 Support array types in JavassistTypeParameterMatcherGenerator 2013-02-28 10:37:55 -08:00
Trustin Lee
b712b030fa Fix a bug where TypeParameterMatcher fails when a type parameter is an array
- Fixes #1103
2013-02-28 10:29:03 -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
671f9d48d4 Use ConcurrentHashMapV8 wherever possible
- Fixes #1052
2013-02-26 15:54:51 -08:00
Trustin Lee
f67441354a Move logging classes from internal to internal.logging
.. because internal is crowded
2013-02-26 14:54:25 -08:00
Trustin Lee
32affc8c8b Fix regression in DefaultAttributeMap / Add Attribute.key() / More fine-grained locking 2013-02-21 15:49:51 -08:00
Norman Maurer
6568cbfec4 [#1071] Remove Attribute from map after Attribute.remove() was called 2013-02-21 19:38:23 +01:00
Atsuhiko Yamanaka
8fdf788cbd [#1012] Replace forked jzlib with official jzlib and add a test. 2013-02-20 12:49:05 +01: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
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
Trustin Lee
742db71a52 Fix IllegalAccessError when Javassist is used 2013-02-13 23:56:55 -08:00
Trustin Lee
53c27ef5ae More robust type parameter detection
- Also removed unnecessary constructors which were added due to incomplete type parameter detection logic
2013-02-13 19:02:55 -08:00
Trustin Lee
b4f4b95739 Move io.netty.logging to io.netty.internal / Move Signal out of internal because we use it in Channel*MessageAdapters 2013-02-11 20:08:18 +09:00
Trustin Lee
a2e5cd94be Prettify APIviz / Tighten visibility / Move subclasses to top level / Remove unused UnknownSocksMessage 2013-02-11 19:42:23 +09:00
Trustin Lee
8f895a7e9a More robust type parameter detection
- now handles '<List<Integer>>'
2013-02-10 01:50:49 +09:00
Trustin Lee
cedcee3f42 Reduce the potential contention caused by ResourceLeakDetector sampling 2013-02-09 12:27:38 +09:00
Trustin Lee
4df737864e Revert the previous commit (sorry!) 2013-02-09 12:21:30 +09:00
Trustin Lee
ea6113d7fb Call PhantomReference.clear() from close() 2013-02-09 12:20:10 +09:00
Trustin Lee
09b022e926 Use PhantomReference insteadof WeakReference for resource leak detection 2013-02-09 12:15:25 +09:00
Trustin Lee
3a12a2db46 Fix checkstyle 2013-02-09 02:37:07 +09:00
Trustin Lee
9a676bc7d5 Faster memory copy between direct buffer and byte array 2013-02-09 01:55:01 +09:00
Trustin Lee
9475f9aeea Add a system property that disables Javassist 2013-02-08 22:14:38 +09:00
Trustin Lee
54d44c6ac1 Use byte code generation if Javassist is available. 2013-02-08 21:45:14 +09:00
Norman Maurer
2f12f95d9b Use correct index when try to find the type of the message 2013-02-08 10:40:46 +01:00
Trustin Lee
ff5aec0c78 Replace TypeParameterFinder with TypeParameterMatcher
- We can avoid reflective matching using byte code generation.
 - Better matching performance when message type is Object
2013-02-08 18:28:06 +09:00
Trustin Lee
646cd455ea Fix incorrect exception message 2013-02-08 17:25:16 +09:00
Trustin Lee
1eafffbec5 Use thread-local map instead of ConcurrentHashMap for faster instantiation of handler adapters 2013-02-08 17:24:29 +09:00
Trustin Lee
1640b1fea6 Automatically detect the message types in MessageToMessageCodec 2013-02-08 16:12:32 +09:00
Trustin Lee
71136390f1 Extract type parameter finder code to a utility class 2013-02-08 15:57:23 +09:00
Andrei Pozolotin
f24872c566 [#1010] Add verify module to check osgi bundles 2013-02-06 20:13:07 +01:00
Norman Maurer
fd75615d7a [#870] Convert all modules into osgi bundles 2013-02-06 07:57:11 +01:00
Norman Maurer
2ad1451ce8 Fix semantic of DefaultAttribute impl on setIfAbsent 2013-01-31 11:52:36 +01:00
Trustin Lee
39357f3835 Enable TCP_NODELAY and SCTP_NODELAY by default
- Fixes #939
- Add PlatformDependent.canEnableTcpNoDelayByDefault()
  - Currently returns false on Android. Will change if necessary later.
2013-01-31 12:17:09 +09:00
Trustin Lee
b60e0b6a51 Modernize InternalLogger API and enable logging framework autodetection
- Borrow SLF4J API which is the best of the best
- InternalLoggerFactory now automatically detects the logging framework
  using static class loading. It tries SLF4J, Log4J, and then falls back
  to java.util.logging.
- Remove OsgiLogger because it is very likely that OSGi container
  already provides a bridge for existing logging frameworks
- Remove JBossLogger because the latest JBossLogger implementation seems
  to implement SLF4J binding
- Upgrade SLF4J to 1.7.2
- Remove tests for the untestable logging frameworks
- Remove TestAny
2013-01-19 20:50:52 +09:00
Trustin Lee
24acfe7008 Remove io.netty.monitor as discussed in #922 2013-01-18 11:08:57 +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
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
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
eb337ff5a7 Fix various inspection warnings 2013-01-10 15:23:58 +09:00
Courtney Robinson
3a52cc410a Add some of the metrics mentioned in #718
use single static initialization of available metrics monitor registries

* This changes the original implementation to work in a similar way to
how slf4j selects and loads an implementation.
* Uses a single static instance so intialization is done only once.
* Doesn't throw IllegalStateException if multiple implementations are
found on the classpath. It instead selects and uses the first
implementation returned by iterator()
* Class left as an iterable to keep the API the same

add yammer metrics to examples to allow them to publish metrics

publish the number of threads used in an EventLoopGroup see issue #718

* seems like the better place to put this because it sets the default
thread count if the MultithreadEventLoopGroup uses super(0,...)
* It also happens to be the common parent class amongst all the
MultiThreadedEventLoopGroup implementations
* Count is reported for
io.netty.channel.{*,.local,.socket.aio,.socket.nio}

fix cosmetic issues pointed out in pull request and updated notice.txt

see https://github.com/netty/netty/pull/780

count # of channels registered in single threaded event loop

measure how many times Selector.select return before SELECT_TIME
2013-01-04 11:27:49 +01:00
alexey
738d382fbc Added test cases for NetUtil methods, if we can`t convertAddress we return null 2012-12-29 18:31:53 +01:00
Norman Maurer
0fb0037eab Rename IpAddresses to NetUtil 2012-12-29 18:25:32 +01:00
Norman Maurer
5d13c7d27b Merge IPUtil and NetworkConstants into IpAddresses and also make naming of methods consistent 2012-12-29 18:17:33 +01:00
Norman Maurer
213c1e3d23 Replace sun.net.util.IPAddressUtil usage with own implementation 2012-12-29 18:13:44 +01:00
Trustin Lee
85e1684084 Simpler method naming in Timeout 2012-12-26 13:50:01 +09:00
Trustin Lee
6b9f7065a2 Simpler and more comprehensive method naming in monitor 2012-12-26 13:48:29 +09:00
Norman Maurer
7db47dd0d0 Finish javadocs for common module 2012-12-21 08:16:00 +01:00
Trustin Lee
ad10518fca Fix the incorrect snapshot version number 2012-12-13 22:49:31 +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
818a7b42a3 Fix all Xlint:unchecked warnings 2012-11-30 22:49:51 +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
ec7849ac09 Allow '_' in parameter names although discouraged 2012-11-12 13:39:24 +09:00
Trustin Lee
a05064d3eb Fix more inspection warnings + compilation errors 2012-11-12 13:25:00 +09:00
Trustin Lee
36c8eb02e8 Fix parameter namings + some more 2012-11-12 12:59:37 +09: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
d78f5a4f76 Optimize imports / Remove britspace 2012-11-12 09:51:59 +09:00
Trustin Lee
9746bb2036 Make a member field final wherever possible 2012-11-12 09:43:55 +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
91a61d7f43 Remove unnecessary qualifiers 2012-11-12 09:11:48 +09:00
Trustin Lee
61d872d6e2 Suppress false-positive inspection warnings / 2012-11-12 09:05:16 +09:00
Trustin Lee
a07fb94fe7 Prefer "str".equals(var) to var.equals("str") / Add proper null checks 2012-11-12 08:59:54 +09:00
Trustin Lee
5d45880b9e Fix a failing test
There's practically no way to test if the detected localhost is good if the user's environment is broken.
2012-11-10 08:50:21 +09:00
Trustin Lee
250c2545e6 Fix a compilation error (sorry!) 2012-11-10 08:48:00 +09:00
Trustin Lee
0b30bf613d More robust localhost resolution
Ensure the resolved localhost can be bound and connected actually
2012-11-10 08:45:07 +09:00
Trustin Lee
b4f796c5e3 Use 'x' over "x" wherever possible / String.equals("") -> isEmpty() 2012-11-10 08:03:52 +09:00
Trustin Lee
f77f13faf0 Make classes static wherever possible 2012-11-10 07:32:53 +09:00
Trustin Lee
c77bac44a2 Fix unchecked warnings 2012-11-10 07:29:14 +09:00
Trustin Lee
23883d25ee Remove various unnecessary qualifiers 2012-11-10 07:03:07 +09:00
Trustin Lee
958d04a42b Remove redundant throws clauses / Suppress inspections for some false positives 2012-11-10 06:47:59 +09:00
Trustin Lee
a5a19efb4b Remove unnecessary this, parenthesis, and semicolons 2012-11-10 02:27:33 +09:00