diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DataStreamer.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DataStreamer.java index 7cb89c5941..c249338b82 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DataStreamer.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DataStreamer.java @@ -131,6 +131,7 @@ static Socket createSocketForPipeline(final DatanodeInfo first, NetUtils.connect(sock, isa, client.getRandomLocalInterfaceAddr(), conf.getSocketTimeout()); sock.setSoTimeout(timeout); + sock.setKeepAlive(true); if (conf.getSocketSendBufferSize() > 0) { sock.setSendBufferSize(conf.getSocketSendBufferSize()); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index ae0fdc49fe..c11b48ff65 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -1761,6 +1761,9 @@ Release 2.8.0 - UNRELEASED HDFS-9535. Newly completed blocks in IBR should not be considered under-replicated too quickly. (Mingliang Liu via jing9) + HDFS-8894. Set SO_KEEPALIVE on DN server sockets. + (Kanaka Kumar Avvaru via wang) + OPTIMIZATIONS HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataXceiver.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataXceiver.java index fe9d4c5d27..29dea69ddf 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataXceiver.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataXceiver.java @@ -710,6 +710,7 @@ public void writeBlock(final ExtendedBlock block, (HdfsConstants.WRITE_TIMEOUT_EXTENSION * targets.length); NetUtils.connect(mirrorSock, mirrorTarget, timeoutValue); mirrorSock.setSoTimeout(timeoutValue); + mirrorSock.setKeepAlive(true); if (dnConf.getTransferSocketSendBufferSize() > 0) { mirrorSock.setSendBufferSize( dnConf.getTransferSocketSendBufferSize()); @@ -1127,7 +1128,8 @@ public void replaceBlock(final ExtendedBlock block, proxySock = datanode.newSocket(); NetUtils.connect(proxySock, proxyAddr, dnConf.socketTimeout); proxySock.setSoTimeout(dnConf.socketTimeout); - + proxySock.setKeepAlive(true); + OutputStream unbufProxyOut = NetUtils.getOutputStream(proxySock, dnConf.socketWriteTimeout); InputStream unbufProxyIn = NetUtils.getInputStream(proxySock);