|
@@ -22,7 +22,10 @@ import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_BLOCKREPORT_INTERVAL_MSEC
|
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_BLOCKREPORT_INTERVAL_MSEC_KEY;
|
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_DATANODE_BALANCE_MAX_NUM_CONCURRENT_MOVES_KEY;
|
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_DATANODE_BALANCE_MAX_NUM_CONCURRENT_MOVES_DEFAULT;
|
|
|
+import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_DATANODE_MAX_RECEIVER_THREADS_DEFAULT;
|
|
|
+import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_DATANODE_MAX_RECEIVER_THREADS_KEY;
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
+import static org.junit.Assert.assertNull;
|
|
|
import static org.junit.Assert.assertTrue;
|
|
|
import static org.junit.Assert.fail;
|
|
|
|
|
@@ -365,4 +368,42 @@ public class TestDataNodeReconfiguration {
|
|
|
.getConf().get(DFS_BLOCKREPORT_INTERVAL_MSEC_KEY));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testDataXceiverReconfiguration()
|
|
|
+ throws ReconfigurationException {
|
|
|
+ for (int i = 0; i < NUM_DATA_NODE; i++) {
|
|
|
+ DataNode dn = cluster.getDataNodes().get(i);
|
|
|
+
|
|
|
+ // Try invalid values.
|
|
|
+ try {
|
|
|
+ dn.reconfigureProperty(DFS_DATANODE_MAX_RECEIVER_THREADS_KEY, "text");
|
|
|
+ fail("ReconfigurationException expected");
|
|
|
+ } catch (ReconfigurationException expected) {
|
|
|
+ assertTrue("expecting NumberFormatException",
|
|
|
+ expected.getCause() instanceof NumberFormatException);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ dn.reconfigureProperty(DFS_DATANODE_MAX_RECEIVER_THREADS_KEY, String.valueOf(-1));
|
|
|
+ fail("ReconfigurationException expected");
|
|
|
+ } catch (ReconfigurationException expected) {
|
|
|
+ assertTrue("expecting IllegalArgumentException",
|
|
|
+ expected.getCause() instanceof IllegalArgumentException);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Change properties and verify change.
|
|
|
+ dn.reconfigureProperty(DFS_DATANODE_MAX_RECEIVER_THREADS_KEY, String.valueOf(123));
|
|
|
+ assertEquals(String.format("%s has wrong value", DFS_DATANODE_MAX_RECEIVER_THREADS_KEY),
|
|
|
+ 123, dn.getXferServer().getMaxXceiverCount());
|
|
|
+
|
|
|
+ // Revert to default.
|
|
|
+ dn.reconfigureProperty(DFS_DATANODE_MAX_RECEIVER_THREADS_KEY, null);
|
|
|
+ assertEquals(String.format("%s has wrong value", DFS_DATANODE_MAX_RECEIVER_THREADS_KEY),
|
|
|
+ DFS_DATANODE_MAX_RECEIVER_THREADS_DEFAULT, dn.getXferServer().getMaxXceiverCount());
|
|
|
+
|
|
|
+ assertNull(String.format("expect %s is not configured",
|
|
|
+ DFS_DATANODE_MAX_RECEIVER_THREADS_KEY),
|
|
|
+ dn.getConf().get(DFS_DATANODE_MAX_RECEIVER_THREADS_KEY));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|