Skip to content

Commit 930ae74

Browse files
authored
Fix Netty deprecation warnings in transport-netty4 module (opensearch-project#20233)
* Fix Netty deprecation warnings in transport-netty4 module Signed-off-by: Sergei Ustimenko <fdesu@proton.me> * Add the CHANGELOG entry and run spotless Signed-off-by: Sergei Ustimenko <fdesu@proton.me> --------- Signed-off-by: Sergei Ustimenko <fdesu@proton.me>
1 parent 668c92a commit 930ae74

File tree

5 files changed

+20
-13
lines changed

5 files changed

+20
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1717
- Fix bug of warm index: FullFileCachedIndexInput was closed error ([#20055](https://github.com/opensearch-project/OpenSearch/pull/20055))
1818
- Fix flaky test ClusterMaxMergesAtOnceIT.testClusterLevelDefaultUpdatesMergePolicy ([#18056](https://github.com/opensearch-project/OpenSearch/issues/18056))
1919
- Fix bug in Assertion framework(Yaml Rest test): numeric comparison fails when comparing Integer vs Long (or Float vs Double) ([#19376](https://github.com/opensearch-project/OpenSearch/pull/19376))
20+
- Fix Netty deprecation warnings in transport-netty4 module ([#20233](https://github.com/opensearch-project/OpenSearch/pull/20233))
2021

2122
### Dependencies
2223
- Bump `com.google.auth:google-auth-library-oauth2-http` from 1.38.0 to 1.41.0 ([#20183](https://github.com/opensearch-project/OpenSearch/pull/20183))

modules/transport-netty4/src/main/java/org/opensearch/http/netty4/Netty4HttpServerTransport.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ public class Netty4HttpServerTransport extends AbstractHttpServerTransport {
139139
*/
140140
private static final ByteSizeValue MTU = new ByteSizeValue(Long.parseLong(System.getProperty("opensearch.net.mtu", "1500")));
141141

142+
/**
143+
* The size of the http content decompressor buffer that is going to be used with the {@link #createDecompressor()}.
144+
*/
145+
private static final int UNLIMITED_DECOMPRESSOR_BUFFER = 0;
146+
142147
private static final String SETTING_KEY_HTTP_NETTY_MAX_COMPOSITE_BUFFER_COMPONENTS = "http.netty.max_composite_buffer_components";
143148

144149
public static Setting<Integer> SETTING_HTTP_NETTY_MAX_COMPOSITE_BUFFER_COMPONENTS = new Setting<>(
@@ -310,8 +315,8 @@ protected void doStart() {
310315
serverBootstrap.childOption(ChannelOption.SO_RCVBUF, Math.toIntExact(tcpReceiveBufferSize.getBytes()));
311316
}
312317

313-
serverBootstrap.option(ChannelOption.RCVBUF_ALLOCATOR, recvByteBufAllocator);
314-
serverBootstrap.childOption(ChannelOption.RCVBUF_ALLOCATOR, recvByteBufAllocator);
318+
serverBootstrap.option(ChannelOption.RECVBUF_ALLOCATOR, recvByteBufAllocator);
319+
serverBootstrap.childOption(ChannelOption.RECVBUF_ALLOCATOR, recvByteBufAllocator);
315320

316321
final boolean reuseAddress = SETTING_HTTP_TCP_REUSE_ADDRESS.get(settings);
317322
serverBootstrap.option(ChannelOption.SO_REUSEADDR, reuseAddress);
@@ -575,7 +580,7 @@ protected ChannelInboundHandlerAdapter createHeaderVerifier() {
575580
* Used in instances to conditionally decompress depending on the outcome from header verification
576581
*/
577582
protected ChannelInboundHandlerAdapter createDecompressor() {
578-
return new HttpContentDecompressor();
583+
return new HttpContentDecompressor(UNLIMITED_DECOMPRESSOR_BUFFER);
579584
}
580585

581586
/**

modules/transport-netty4/src/main/java/org/opensearch/transport/NettyAllocator.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ public class NettyAllocator {
117117
maxOrder = 5;
118118
}
119119
}
120-
int tinyCacheSize = PooledByteBufAllocator.defaultTinyCacheSize();
121120
int smallCacheSize = PooledByteBufAllocator.defaultSmallCacheSize();
122121
int normalCacheSize = PooledByteBufAllocator.defaultNormalCacheSize();
123122
boolean useCacheForAllThreads = PooledByteBufAllocator.defaultUseCacheForAllThreads();
@@ -127,7 +126,6 @@ public class NettyAllocator {
127126
0,
128127
pageSize,
129128
maxOrder,
130-
tinyCacheSize,
131129
smallCacheSize,
132130
normalCacheSize,
133131
useCacheForAllThreads

modules/transport-netty4/src/main/java/org/opensearch/transport/SharedGroupFactory.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
import java.util.concurrent.atomic.AtomicBoolean;
4545

4646
import io.netty.channel.EventLoopGroup;
47-
import io.netty.channel.nio.NioEventLoopGroup;
47+
import io.netty.channel.MultiThreadIoEventLoopGroup;
48+
import io.netty.channel.nio.NioIoHandler;
4849
import io.netty.util.concurrent.Future;
4950

5051
import static org.opensearch.common.util.concurrent.OpenSearchExecutors.daemonThreadFactory;
@@ -89,9 +90,10 @@ public synchronized SharedGroup getHttpGroup() {
8990
return getGenericGroup();
9091
} else {
9192
if (dedicatedHttpGroup == null) {
92-
NioEventLoopGroup eventLoopGroup = new NioEventLoopGroup(
93+
EventLoopGroup eventLoopGroup = new MultiThreadIoEventLoopGroup(
9394
httpWorkerCount,
94-
daemonThreadFactory(settings, HttpServerTransport.HTTP_SERVER_WORKER_THREAD_NAME_PREFIX)
95+
daemonThreadFactory(settings, HttpServerTransport.HTTP_SERVER_WORKER_THREAD_NAME_PREFIX),
96+
NioIoHandler.newFactory()
9597
);
9698
dedicatedHttpGroup = new SharedGroup(new RefCountedGroup(eventLoopGroup));
9799
}
@@ -101,9 +103,10 @@ public synchronized SharedGroup getHttpGroup() {
101103

102104
private SharedGroup getGenericGroup() {
103105
if (genericGroup == null) {
104-
EventLoopGroup eventLoopGroup = new NioEventLoopGroup(
106+
EventLoopGroup eventLoopGroup = new MultiThreadIoEventLoopGroup(
105107
workerCount,
106-
daemonThreadFactory(settings, TcpTransport.TRANSPORT_WORKER_THREAD_NAME_PREFIX)
108+
daemonThreadFactory(settings, TcpTransport.TRANSPORT_WORKER_THREAD_NAME_PREFIX),
109+
NioIoHandler.newFactory()
107110
);
108111
this.genericGroup = new RefCountedGroup(eventLoopGroup);
109112
} else {

modules/transport-netty4/src/main/java/org/opensearch/transport/netty4/Netty4Transport.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ private Bootstrap createClientBootstrap(SharedGroupFactory.SharedGroup sharedGro
218218
bootstrap.option(ChannelOption.SO_RCVBUF, Math.toIntExact(tcpReceiveBufferSize.getBytes()));
219219
}
220220

221-
bootstrap.option(ChannelOption.RCVBUF_ALLOCATOR, recvByteBufAllocator);
221+
bootstrap.option(ChannelOption.RECVBUF_ALLOCATOR, recvByteBufAllocator);
222222

223223
final boolean reuseAddress = TransportSettings.TCP_REUSE_ADDRESS.get(settings);
224224
bootstrap.option(ChannelOption.SO_REUSEADDR, reuseAddress);
@@ -288,8 +288,8 @@ private void createServerBootstrap(ProfileSettings profileSettings, SharedGroupF
288288
serverBootstrap.childOption(ChannelOption.SO_RCVBUF, Math.toIntExact(profileSettings.receiveBufferSize.bytesAsInt()));
289289
}
290290

291-
serverBootstrap.option(ChannelOption.RCVBUF_ALLOCATOR, recvByteBufAllocator);
292-
serverBootstrap.childOption(ChannelOption.RCVBUF_ALLOCATOR, recvByteBufAllocator);
291+
serverBootstrap.option(ChannelOption.RECVBUF_ALLOCATOR, recvByteBufAllocator);
292+
serverBootstrap.childOption(ChannelOption.RECVBUF_ALLOCATOR, recvByteBufAllocator);
293293

294294
serverBootstrap.option(ChannelOption.SO_REUSEADDR, profileSettings.reuseAddress);
295295
serverBootstrap.childOption(ChannelOption.SO_REUSEADDR, profileSettings.reuseAddress);

0 commit comments

Comments
 (0)