|
@@ -30,7 +30,6 @@ import org.slf4j.LoggerFactory;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.net.Socket;
|
|
import java.net.Socket;
|
|
|
|
|
|
-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.junit.Assert.assertTrue;
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
|
|
@@ -42,15 +41,16 @@ public class TestDFSClientSocketSize {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * The setting of socket send buffer size in
|
|
|
|
- * {@link java.net.Socket#setSendBufferSize(int)} is only a hint. Actual
|
|
|
|
- * value may differ. We just sanity check that it is somewhere close.
|
|
|
|
|
|
+ * Test that the send buffer size default value is 0, in which case the socket
|
|
|
|
+ * will use a TCP auto-tuned value.
|
|
*/
|
|
*/
|
|
@Test
|
|
@Test
|
|
public void testDefaultSendBufferSize() throws IOException {
|
|
public void testDefaultSendBufferSize() throws IOException {
|
|
- assertTrue("Send buffer size should be somewhere near default.",
|
|
|
|
- getSendBufferSize(new Configuration()) >=
|
|
|
|
- DFS_CLIENT_SOCKET_SEND_BUFFER_SIZE_DEFAULT / 2);
|
|
|
|
|
|
+ final int sendBufferSize = getSendBufferSize(new Configuration());
|
|
|
|
+ LOG.info("If not specified, the auto tuned send buffer size is: {}",
|
|
|
|
+ sendBufferSize);
|
|
|
|
+ assertTrue("Send buffer size should be non-negative value which is " +
|
|
|
|
+ "determined by system (kernel).", sendBufferSize > 0);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -73,6 +73,10 @@ public class TestDFSClientSocketSize {
|
|
sendBufferSize1 > sendBufferSize2);
|
|
sendBufferSize1 > sendBufferSize2);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Test that if the send buffer size is 0, the socket will use a TCP
|
|
|
|
+ * auto-tuned value.
|
|
|
|
+ */
|
|
@Test
|
|
@Test
|
|
public void testAutoTuningSendBufferSize() throws IOException {
|
|
public void testAutoTuningSendBufferSize() throws IOException {
|
|
final Configuration conf = new Configuration();
|
|
final Configuration conf = new Configuration();
|
|
@@ -80,7 +84,7 @@ public class TestDFSClientSocketSize {
|
|
final int sendBufferSize = getSendBufferSize(conf);
|
|
final int sendBufferSize = getSendBufferSize(conf);
|
|
LOG.info("The auto tuned send buffer size is: {}", sendBufferSize);
|
|
LOG.info("The auto tuned send buffer size is: {}", sendBufferSize);
|
|
assertTrue("Send buffer size should be non-negative value which is " +
|
|
assertTrue("Send buffer size should be non-negative value which is " +
|
|
- "determined by system (kernel).", sendBufferSize > 0);
|
|
|
|
|
|
+ "determined by system (kernel).", sendBufferSize > 0);
|
|
}
|
|
}
|
|
|
|
|
|
private int getSendBufferSize(Configuration conf) throws IOException {
|
|
private int getSendBufferSize(Configuration conf) throws IOException {
|