kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | f416c4cda74f0ee17933bddedf76f763e4bfd67792f1f2cbd97ebd0d50224a88 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2015-05-08 11:56 +02:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2015-05-14 16:31 +02:00 |
| Parents | 92782d18ab29 |
2 files changed
modified driver-core/CHANGELOG.rst +6 −0
| @@ -1,6 +1,12 @@ | ||
| 1 | 1 | CHANGELOG |
| 2 | 2 | ========= |
| 3 | 3 | |
| 4 | +2.0.10.1: | |
| 5 | +--------- | |
| 6 | + | |
| 7 | +- [improvement] Use Netty's pooled ByteBufAllocator by default (JAVA-756) | |
| 8 | + | |
| 9 | + | |
| 4 | 10 | 2.0.10: |
| 5 | 11 | ------- |
| 6 | 12 |
modified driver-core/src/main/java/com/datastax/driver/core/NettyOptions.java +14 −6
| @@ -21,6 +21,9 @@ | ||
| 21 | 21 | import static java.util.concurrent.TimeUnit.SECONDS; |
| 22 | 22 | |
| 23 | 23 | import io.netty.bootstrap.Bootstrap; |
| 24 | +import io.netty.buffer.ByteBufAllocator; | |
| 25 | +import io.netty.buffer.PooledByteBufAllocator; | |
| 26 | +import io.netty.channel.ChannelOption; | |
| 24 | 27 | import io.netty.channel.EventLoopGroup; |
| 25 | 28 | import io.netty.channel.nio.NioEventLoopGroup; |
| 26 | 29 | import io.netty.channel.socket.SocketChannel; |
| @@ -122,18 +125,25 @@ | ||
| 122 | 125 | * {@link SocketOptions}s. |
| 123 | 126 | * <p> |
| 124 | 127 | * This is a good place to add extra {@link io.netty.channel.ChannelHandler ChannelOption}s to the boostrap; e.g. |
| 125 | - * to replace the default {@link io.netty.buffer.ByteBufAllocator ByteBufAllocator} implementation with a custom one, | |
| 126 | - * do the following: | |
| 128 | + * plug a custom {@link io.netty.buffer.ByteBufAllocator ByteBufAllocator} implementation: | |
| 127 | 129 | * |
| 128 | 130 | * <pre> |
| 129 | 131 | * ByteBufAllocator myCustomByteBufAllocator = ... |
| 130 | - * boostrap.option(ChannelOption.ALLOCATOR, myCustomByteBufAllocator); | |
| 132 | + * | |
| 133 | + * public void afterBootstrapInitialized(Bootstrap bootstrap) { | |
| 134 | + * bootstrap.option(ChannelOption.ALLOCATOR, myCustomByteBufAllocator); | |
| 135 | + * } | |
| 131 | 136 | * </pre> |
| 132 | 137 | * |
| 138 | + * Note that the default implementation of this method configures a pooled {@code ByteBufAllocator} (Netty 4.0 | |
| 139 | + * defaults to unpooled). If you override this method to set unrelated options, make sure you call | |
| 140 | + * {@code super.afterBootstrapInitialized(bootstrap)}. | |
| 141 | + * | |
| 133 | 142 | * @param bootstrap the {@link Bootstrap} being initialized. |
| 134 | 143 | */ |
| 135 | 144 | public void afterBootstrapInitialized(Bootstrap bootstrap) { |
| 136 | - //noop | |
| 145 | + // In Netty 4.1.x, pooled will be the default, so this won't be necessary anymore | |
| 146 | + bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); | |
| 137 | 147 | } |
| 138 | 148 | |
| 139 | 149 | /** |
| @@ -189,6 +199,4 @@ | ||
| 189 | 199 | // it is safe to reduce the quiet period to 0 seconds |
| 190 | 200 | eventLoopGroup.shutdownGracefully(0, 15, SECONDS).syncUninterruptibly(); |
| 191 | 201 | } |
| 192 | - | |
| 193 | - | |
| 194 | 202 | } |