Skip to content

Commit 4fa8a8c

Browse files
committed
NIFI-14506 Replaced deprecated Netty classes
1 parent 36d5392 commit 4fa8a8c

File tree

4 files changed

+11
-6
lines changed
  • nifi-extension-bundles
  • nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/client/async/nio

4 files changed

+11
-6
lines changed

nifi-extension-bundles/nifi-extension-utils/nifi-event-transport/src/main/java/org/apache/nifi/event/transport/netty/EventLoopGroupFactory.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
package org.apache.nifi.event.transport.netty;
1818

1919
import io.netty.channel.EventLoopGroup;
20-
import io.netty.channel.nio.NioEventLoopGroup;
20+
import io.netty.channel.MultiThreadIoEventLoopGroup;
21+
import io.netty.channel.nio.NioIoHandler;
2122
import io.netty.util.concurrent.DefaultThreadFactory;
2223

2324
import java.util.Objects;
@@ -54,7 +55,7 @@ public void setWorkerThreads(final int workerThreads) {
5455
}
5556

5657
protected EventLoopGroup getEventLoopGroup() {
57-
return new NioEventLoopGroup(workerThreads, getThreadFactory());
58+
return new MultiThreadIoEventLoopGroup(workerThreads, getThreadFactory(), NioIoHandler.newFactory());
5859
}
5960

6061
private ThreadFactory getThreadFactory() {

nifi-extension-bundles/nifi-extension-utils/nifi-event-transport/src/main/java/org/apache/nifi/event/transport/netty/NettyEventServerFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public EventServer getEventServer() {
191191
private void setChannelOptions(final AbstractBootstrap<?, ?> bootstrap) {
192192
if (socketReceiveBuffer != null) {
193193
bootstrap.option(ChannelOption.SO_RCVBUF, socketReceiveBuffer);
194-
bootstrap.option(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(socketReceiveBuffer));
194+
bootstrap.option(ChannelOption.RECVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(socketReceiveBuffer));
195195
}
196196
if (socketKeepAlive != null) {
197197
bootstrap.option(ChannelOption.SO_KEEPALIVE, socketKeepAlive);

nifi-extension-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-client-service/src/main/java/org/apache/nifi/distributed/cache/client/CacheClient.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import io.netty.channel.EventLoopGroup;
2121
import io.netty.channel.nio.NioEventLoopGroup;
2222
import io.netty.channel.pool.ChannelPool;
23+
import io.netty.channel.MultiThreadIoEventLoopGroup;
24+
import io.netty.channel.nio.NioIoHandler;
2325
import io.netty.util.concurrent.DefaultThreadFactory;
2426
import org.apache.nifi.distributed.cache.client.adapter.InboundAdapter;
2527
import org.apache.nifi.distributed.cache.client.adapter.OutboundAdapter;
@@ -60,7 +62,8 @@ protected CacheClient(final String hostname,
6062
final VersionNegotiatorFactory factory,
6163
final String identifier) {
6264
final String poolName = String.format("%s[%s]", getClass().getSimpleName(), identifier);
63-
this.eventLoopGroup = new NioEventLoopGroup(new DefaultThreadFactory(poolName, DAEMON_THREAD_ENABLED));
65+
this.eventLoopGroup = new MultiThreadIoEventLoopGroup(new DefaultThreadFactory(poolName, DAEMON_THREAD_ENABLED), NioIoHandler.newFactory());
66+
//this.eventLoopGroup = new NioEventLoopGroup(new DefaultThreadFactory(poolName, DAEMON_THREAD_ENABLED));
6467
this.channelPool = new CacheClientChannelPoolFactory().createChannelPool(
6568
hostname, port, timeoutMillis, sslContextProvider, factory, eventLoopGroup);
6669
}

nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/queue/clustered/client/async/nio/TestPeerChannel.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626
import io.netty.channel.ChannelPipeline;
2727
import io.netty.channel.EventLoopGroup;
2828
import io.netty.channel.SimpleChannelInboundHandler;
29-
import io.netty.channel.nio.NioEventLoopGroup;
3029
import io.netty.channel.socket.nio.NioServerSocketChannel;
3130
import io.netty.handler.ssl.SslHandler;
31+
import io.netty.channel.MultiThreadIoEventLoopGroup;
32+
import io.netty.channel.nio.NioIoHandler;
3233
import org.apache.nifi.security.cert.builder.StandardCertificateBuilder;
3334
import org.apache.nifi.security.ssl.EphemeralKeyStoreBuilder;
3435
import org.apache.nifi.security.ssl.StandardSslContextBuilder;
@@ -174,7 +175,7 @@ private int read(final PeerChannel peerChannel) throws IOException {
174175
}
175176

176177
private void processChannel(final String enabledProtocol, final Consumer<PeerChannel> channelConsumer) throws IOException {
177-
final EventLoopGroup group = new NioEventLoopGroup(GROUP_THREADS);
178+
final EventLoopGroup group = new MultiThreadIoEventLoopGroup(GROUP_THREADS, NioIoHandler.newFactory());
178179

179180
try (final SocketChannel socketChannel = SocketChannel.open()) {
180181
final Socket socket = socketChannel.socket();

0 commit comments

Comments
 (0)