mirror of https://github.com/apache/nifi.git
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:
parent
8a197e5a96
commit
ae8a794ff0
|
@ -146,6 +146,7 @@ public class SocketChannelDispatcher<E extends Event<SocketChannel>> implements
|
||||||
// Handle new connections coming in
|
// Handle new connections coming in
|
||||||
final ServerSocketChannel channel = (ServerSocketChannel) key.channel();
|
final ServerSocketChannel channel = (ServerSocketChannel) key.channel();
|
||||||
final SocketChannel socketChannel = channel.accept();
|
final SocketChannel socketChannel = channel.accept();
|
||||||
|
socketChannel.setOption(StandardSocketOptions.SO_KEEPALIVE, true);
|
||||||
// Check for available connections
|
// Check for available connections
|
||||||
if (currentConnections.incrementAndGet() > maxConnections){
|
if (currentConnections.incrementAndGet() > maxConnections){
|
||||||
currentConnections.decrementAndGet();
|
currentConnections.decrementAndGet();
|
||||||
|
|
|
@ -25,6 +25,7 @@ import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.SSLEngine;
|
import javax.net.ssl.SSLEngine;
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
|
import java.net.StandardSocketOptions;
|
||||||
import java.nio.channels.ServerSocketChannel;
|
import java.nio.channels.ServerSocketChannel;
|
||||||
import java.nio.channels.SocketChannel;
|
import java.nio.channels.SocketChannel;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
|
@ -79,6 +80,7 @@ public class SocketChannelRecordReaderDispatcher implements Runnable, Closeable
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
socketChannel.setOption(StandardSocketOptions.SO_KEEPALIVE, true);
|
||||||
final SocketAddress remoteSocketAddress = socketChannel.getRemoteAddress();
|
final SocketAddress remoteSocketAddress = socketChannel.getRemoteAddress();
|
||||||
socketChannel.socket().setSoTimeout(socketReadTimeout);
|
socketChannel.socket().setSoTimeout(socketReadTimeout);
|
||||||
socketChannel.socket().setReceiveBufferSize(receiveBufferSize);
|
socketChannel.socket().setReceiveBufferSize(receiveBufferSize);
|
||||||
|
|
Loading…
Reference in New Issue