HDFS-9700. DFSClient and DFSOutputStream should set TCP_NODELAY on sockets for DataTransferProtocol (Gary Helmling via iwasakims)
This commit is contained in:
parent
e6a7044b85
commit
372d1302c6
|
@ -1890,6 +1890,7 @@ public class DFSClient implements java.io.Closeable, RemotePeerFactory,
|
||||||
String dnAddr = dn.getXferAddr(getConf().isConnectToDnViaHostname());
|
String dnAddr = dn.getXferAddr(getConf().isConnectToDnViaHostname());
|
||||||
LOG.debug("Connecting to datanode {}", dnAddr);
|
LOG.debug("Connecting to datanode {}", dnAddr);
|
||||||
NetUtils.connect(sock, NetUtils.createSocketAddr(dnAddr), timeout);
|
NetUtils.connect(sock, NetUtils.createSocketAddr(dnAddr), timeout);
|
||||||
|
sock.setTcpNoDelay(dfsClientConf.getDataTransferTcpNoDelay());
|
||||||
sock.setSoTimeout(timeout);
|
sock.setSoTimeout(timeout);
|
||||||
|
|
||||||
OutputStream unbufOut = NetUtils.getOutputStream(sock);
|
OutputStream unbufOut = NetUtils.getOutputStream(sock);
|
||||||
|
|
|
@ -131,6 +131,7 @@ class DataStreamer extends Daemon {
|
||||||
final int timeout = client.getDatanodeReadTimeout(length);
|
final int timeout = client.getDatanodeReadTimeout(length);
|
||||||
NetUtils.connect(sock, isa, client.getRandomLocalInterfaceAddr(),
|
NetUtils.connect(sock, isa, client.getRandomLocalInterfaceAddr(),
|
||||||
conf.getSocketTimeout());
|
conf.getSocketTimeout());
|
||||||
|
sock.setTcpNoDelay(conf.getDataTransferTcpNoDelay());
|
||||||
sock.setSoTimeout(timeout);
|
sock.setSoTimeout(timeout);
|
||||||
sock.setKeepAlive(true);
|
sock.setKeepAlive(true);
|
||||||
if (conf.getSocketSendBufferSize() > 0) {
|
if (conf.getSocketSendBufferSize() > 0) {
|
||||||
|
|
|
@ -160,6 +160,10 @@ public interface HdfsClientConfigKeys {
|
||||||
String DFS_USER_HOME_DIR_PREFIX_KEY = "dfs.user.home.dir.prefix";
|
String DFS_USER_HOME_DIR_PREFIX_KEY = "dfs.user.home.dir.prefix";
|
||||||
String DFS_USER_HOME_DIR_PREFIX_DEFAULT = "/user";
|
String DFS_USER_HOME_DIR_PREFIX_DEFAULT = "/user";
|
||||||
|
|
||||||
|
String DFS_DATA_TRANSFER_CLIENT_TCPNODELAY_KEY =
|
||||||
|
"dfs.data.transfer.client.tcpnodelay";
|
||||||
|
boolean DFS_DATA_TRANSFER_CLIENT_TCPNODELAY_DEFAULT = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These are deprecated config keys to client code.
|
* These are deprecated config keys to client code.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -58,6 +58,8 @@ import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_CLIENT_SOCK
|
||||||
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_CLIENT_SOCKET_CACHE_EXPIRY_MSEC_KEY;
|
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_CLIENT_SOCKET_CACHE_EXPIRY_MSEC_KEY;
|
||||||
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_CLIENT_SOCKET_SEND_BUFFER_SIZE_DEFAULT;
|
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_CLIENT_SOCKET_SEND_BUFFER_SIZE_DEFAULT;
|
||||||
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_CLIENT_SOCKET_SEND_BUFFER_SIZE_KEY;
|
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_CLIENT_SOCKET_SEND_BUFFER_SIZE_KEY;
|
||||||
|
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_DATA_TRANSFER_CLIENT_TCPNODELAY_DEFAULT;
|
||||||
|
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_DATA_TRANSFER_CLIENT_TCPNODELAY_KEY;
|
||||||
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_CLIENT_SOCKET_TIMEOUT_KEY;
|
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_CLIENT_SOCKET_TIMEOUT_KEY;
|
||||||
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_CLIENT_USE_DN_HOSTNAME;
|
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_CLIENT_USE_DN_HOSTNAME;
|
||||||
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_CLIENT_USE_DN_HOSTNAME_DEFAULT;
|
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_CLIENT_USE_DN_HOSTNAME_DEFAULT;
|
||||||
|
@ -135,6 +137,7 @@ public class DfsClientConf {
|
||||||
|
|
||||||
private final int stripedReadThreadpoolSize;
|
private final int stripedReadThreadpoolSize;
|
||||||
|
|
||||||
|
private final boolean dataTransferTcpNoDelay;
|
||||||
|
|
||||||
public DfsClientConf(Configuration conf) {
|
public DfsClientConf(Configuration conf) {
|
||||||
// The hdfsTimeout is currently the same as the ipc timeout
|
// The hdfsTimeout is currently the same as the ipc timeout
|
||||||
|
@ -173,6 +176,9 @@ public class DfsClientConf {
|
||||||
CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_KEY,
|
CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_KEY,
|
||||||
CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT);
|
CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT);
|
||||||
defaultChecksumOpt = getChecksumOptFromConf(conf);
|
defaultChecksumOpt = getChecksumOptFromConf(conf);
|
||||||
|
dataTransferTcpNoDelay = conf.getBoolean(
|
||||||
|
DFS_DATA_TRANSFER_CLIENT_TCPNODELAY_KEY,
|
||||||
|
DFS_DATA_TRANSFER_CLIENT_TCPNODELAY_DEFAULT);
|
||||||
socketTimeout = conf.getInt(DFS_CLIENT_SOCKET_TIMEOUT_KEY,
|
socketTimeout = conf.getInt(DFS_CLIENT_SOCKET_TIMEOUT_KEY,
|
||||||
HdfsConstants.READ_TIMEOUT);
|
HdfsConstants.READ_TIMEOUT);
|
||||||
socketSendBufferSize = conf.getInt(DFS_CLIENT_SOCKET_SEND_BUFFER_SIZE_KEY,
|
socketSendBufferSize = conf.getInt(DFS_CLIENT_SOCKET_SEND_BUFFER_SIZE_KEY,
|
||||||
|
@ -405,6 +411,13 @@ public class DfsClientConf {
|
||||||
return writeByteArrayManagerConf;
|
return writeByteArrayManagerConf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return whether TCP_NODELAY should be set on client sockets
|
||||||
|
*/
|
||||||
|
public boolean getDataTransferTcpNoDelay() {
|
||||||
|
return dataTransferTcpNoDelay;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the socketTimeout
|
* @return the socketTimeout
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1908,6 +1908,9 @@ Release 2.8.0 - UNRELEASED
|
||||||
HDFS-9777. Fix typos in DFSAdmin command line and documentation.
|
HDFS-9777. Fix typos in DFSAdmin command line and documentation.
|
||||||
(Wei-Chiu Chuang via umamahesh)
|
(Wei-Chiu Chuang via umamahesh)
|
||||||
|
|
||||||
|
HDFS-9700. DFSClient and DFSOutputStream should set TCP_NODELAY on sockets
|
||||||
|
for DataTransferProtocol (Gary Helmling via iwasakims)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than
|
HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than
|
||||||
|
|
Loading…
Reference in New Issue