This is an automated email from the ASF dual-hosted git repository.

bbende pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/master by this push:
     new ae8a794  NIFI-6031: allow OS level socket keep alive checking
ae8a794 is described below

commit ae8a794ff04ce28c9cfee887981635577645e0f1
Author: Endre Zoltan Kovacs <[email protected]>
AuthorDate: Thu Feb 14 17:48:49 2019 +0100

    NIFI-6031: allow OS level socket keep alive checking
    
    This closes #3307.
    
    Signed-off-by: Bryan Bende <[email protected]>
---
 .../nifi/processor/util/listen/dispatcher/SocketChannelDispatcher.java  | 1 +
 .../apache/nifi/record/listen/SocketChannelRecordReaderDispatcher.java  | 2 ++
 2 files changed, 3 insertions(+)

diff --git 
a/nifi-nar-bundles/nifi-extension-utils/nifi-processor-utils/src/main/java/org/apache/nifi/processor/util/listen/dispatcher/SocketChannelDispatcher.java
 
b/nifi-nar-bundles/nifi-extension-utils/nifi-processor-utils/src/main/java/org/apache/nifi/processor/util/listen/dispatcher/SocketChannelDispatcher.java
index b07fbb9..9f73b28 100644
--- 
a/nifi-nar-bundles/nifi-extension-utils/nifi-processor-utils/src/main/java/org/apache/nifi/processor/util/listen/dispatcher/SocketChannelDispatcher.java
+++ 
b/nifi-nar-bundles/nifi-extension-utils/nifi-processor-utils/src/main/java/org/apache/nifi/processor/util/listen/dispatcher/SocketChannelDispatcher.java
@@ -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();
diff --git 
a/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/main/java/org/apache/nifi/record/listen/SocketChannelRecordReaderDispatcher.java
 
b/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/main/java/org/apache/nifi/record/listen/SocketChannelRecordReaderDispatcher.java
index a72b0d8..2e6ecc2 100644
--- 
a/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/main/java/org/apache/nifi/record/listen/SocketChannelRecordReaderDispatcher.java
+++ 
b/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/main/java/org/apache/nifi/record/listen/SocketChannelRecordReaderDispatcher.java
@@ -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);

Reply via email to