NIFI-6031: allow OS level socket keep alive checking

This closes #3307.

Signed-off-by: Bryan Bende <bbende@apache.org>
This commit is contained in:
Endre Zoltan Kovacs 2019-02-14 17:48:49 +01:00 committed by Bryan Bende
parent 8a197e5a96
commit ae8a794ff0
No known key found for this signature in database
GPG Key ID: A0DDA9ED50711C39
2 changed files with 3 additions and 0 deletions

View File

@ -146,6 +146,7 @@ public class SocketChannelDispatcher<E extends Event<SocketChannel>> implements
// Handle new connections coming in
final ServerSocketChannel channel = (ServerSocketChannel) key.channel();
final SocketChannel socketChannel = channel.accept();
socketChannel.setOption(StandardSocketOptions.SO_KEEPALIVE, true);
// Check for available connections
if (currentConnections.incrementAndGet() > maxConnections){
currentConnections.decrementAndGet();

View File

@ -25,6 +25,7 @@ import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import java.io.Closeable;
import java.net.SocketAddress;
import java.net.StandardSocketOptions;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.concurrent.BlockingQueue;
@ -79,6 +80,7 @@ public class SocketChannelRecordReaderDispatcher implements Runnable, Closeable
continue;
}
socketChannel.setOption(StandardSocketOptions.SO_KEEPALIVE, true);
final SocketAddress remoteSocketAddress = socketChannel.getRemoteAddress();
socketChannel.socket().setSoTimeout(socketReadTimeout);
socketChannel.socket().setReceiveBufferSize(receiveBufferSize);