|
@@ -18,8 +18,10 @@
|
|
|
|
|
|
package org.apache.hadoop.hdfs.server.datanode;
|
|
|
|
|
|
+import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_BLOCKREPORT_INITIAL_DELAY_KEY;
|
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_BLOCKREPORT_INTERVAL_MSEC_DEFAULT;
|
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_BLOCKREPORT_INTERVAL_MSEC_KEY;
|
|
|
+import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_BLOCKREPORT_SPLIT_THRESHOLD_KEY;
|
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_CACHEREPORT_INTERVAL_MSEC_DEFAULT;
|
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_CACHEREPORT_INTERVAL_MSEC_KEY;
|
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_DATANODE_BALANCE_MAX_NUM_CONCURRENT_MOVES_KEY;
|
|
@@ -303,40 +305,49 @@ public class TestDataNodeReconfiguration {
|
|
|
|
|
|
@Test
|
|
|
public void testBlockReportIntervalReconfiguration()
|
|
|
- throws ReconfigurationException, IOException {
|
|
|
+ throws ReconfigurationException {
|
|
|
int blockReportInterval = 300 * 1000;
|
|
|
+ String[] blockReportParameters = {
|
|
|
+ DFS_BLOCKREPORT_INTERVAL_MSEC_KEY,
|
|
|
+ DFS_BLOCKREPORT_SPLIT_THRESHOLD_KEY,
|
|
|
+ DFS_BLOCKREPORT_INITIAL_DELAY_KEY};
|
|
|
+
|
|
|
for (int i = 0; i < NUM_DATA_NODE; i++) {
|
|
|
DataNode dn = cluster.getDataNodes().get(i);
|
|
|
+ BlockPoolManager blockPoolManager = dn.getBlockPoolManager();
|
|
|
|
|
|
// Try invalid values.
|
|
|
+ for (String blockReportParameter : blockReportParameters) {
|
|
|
+ try {
|
|
|
+ dn.reconfigureProperty(blockReportParameter, "text");
|
|
|
+ fail("ReconfigurationException expected");
|
|
|
+ } catch (ReconfigurationException expected) {
|
|
|
+ assertTrue("expecting NumberFormatException",
|
|
|
+ expected.getCause() instanceof NumberFormatException);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
- dn.reconfigureProperty(
|
|
|
- DFS_BLOCKREPORT_INTERVAL_MSEC_KEY, "text");
|
|
|
+ dn.reconfigureProperty(DFS_BLOCKREPORT_INTERVAL_MSEC_KEY, String.valueOf(-1));
|
|
|
fail("ReconfigurationException expected");
|
|
|
} catch (ReconfigurationException expected) {
|
|
|
- assertTrue("expecting NumberFormatException",
|
|
|
- expected.getCause() instanceof NumberFormatException);
|
|
|
+ assertTrue("expecting IllegalArgumentException",
|
|
|
+ expected.getCause() instanceof IllegalArgumentException);
|
|
|
}
|
|
|
try {
|
|
|
- dn.reconfigureProperty(
|
|
|
- DFS_BLOCKREPORT_INTERVAL_MSEC_KEY,
|
|
|
- String.valueOf(-1));
|
|
|
+ dn.reconfigureProperty(DFS_BLOCKREPORT_SPLIT_THRESHOLD_KEY, String.valueOf(-1));
|
|
|
fail("ReconfigurationException expected");
|
|
|
} catch (ReconfigurationException expected) {
|
|
|
assertTrue("expecting IllegalArgumentException",
|
|
|
expected.getCause() instanceof IllegalArgumentException);
|
|
|
}
|
|
|
+ dn.reconfigureProperty(DFS_BLOCKREPORT_INITIAL_DELAY_KEY, String.valueOf(-1));
|
|
|
+ assertEquals(0, dn.getDnConf().initialBlockReportDelayMs);
|
|
|
|
|
|
- // Change properties.
|
|
|
+ // Change properties and verify the change.
|
|
|
dn.reconfigureProperty(DFS_BLOCKREPORT_INTERVAL_MSEC_KEY,
|
|
|
String.valueOf(blockReportInterval));
|
|
|
-
|
|
|
- // Verify change.
|
|
|
- assertEquals(String.format("%s has wrong value",
|
|
|
- DFS_BLOCKREPORT_INTERVAL_MSEC_KEY),
|
|
|
- blockReportInterval,
|
|
|
- dn.getDnConf().getBlockReportInterval());
|
|
|
- for (BPOfferService bpos : dn.getAllBpOs()) {
|
|
|
+ for (BPOfferService bpos : blockPoolManager.getAllNamenodeThreads()) {
|
|
|
if (bpos != null) {
|
|
|
for (BPServiceActor actor : bpos.getBPServiceActors()) {
|
|
|
assertEquals(String.format("%s has wrong value",
|
|
@@ -347,15 +358,15 @@ public class TestDataNodeReconfiguration {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // Revert to default.
|
|
|
- dn.reconfigureProperty(DFS_BLOCKREPORT_INTERVAL_MSEC_KEY,
|
|
|
- null);
|
|
|
- assertEquals(String.format("%s has wrong value",
|
|
|
- DFS_BLOCKREPORT_INTERVAL_MSEC_KEY),
|
|
|
- DFS_BLOCKREPORT_INTERVAL_MSEC_DEFAULT,
|
|
|
- dn.getDnConf().getBlockReportInterval());
|
|
|
- // Verify default.
|
|
|
- for (BPOfferService bpos : dn.getAllBpOs()) {
|
|
|
+ dn.reconfigureProperty(DFS_BLOCKREPORT_SPLIT_THRESHOLD_KEY, String.valueOf(123));
|
|
|
+ assertEquals(123, dn.getDnConf().blockReportSplitThreshold);
|
|
|
+
|
|
|
+ dn.reconfigureProperty(DFS_BLOCKREPORT_INITIAL_DELAY_KEY, "123");
|
|
|
+ assertEquals(123000, dn.getDnConf().initialBlockReportDelayMs);
|
|
|
+
|
|
|
+ // Revert to default and verify default.
|
|
|
+ dn.reconfigureProperty(DFS_BLOCKREPORT_INTERVAL_MSEC_KEY, null);
|
|
|
+ for (BPOfferService bpos : blockPoolManager.getAllNamenodeThreads()) {
|
|
|
if (bpos != null) {
|
|
|
for (BPServiceActor actor : bpos.getBPServiceActors()) {
|
|
|
assertEquals(String.format("%s has wrong value",
|
|
@@ -365,9 +376,16 @@ public class TestDataNodeReconfiguration {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- assertEquals(String.format("expect %s is not configured",
|
|
|
- DFS_BLOCKREPORT_INTERVAL_MSEC_KEY), null, dn
|
|
|
- .getConf().get(DFS_BLOCKREPORT_INTERVAL_MSEC_KEY));
|
|
|
+ assertNull(String.format("expect %s is not configured", DFS_BLOCKREPORT_INTERVAL_MSEC_KEY),
|
|
|
+ dn.getConf().get(DFS_BLOCKREPORT_INTERVAL_MSEC_KEY));
|
|
|
+
|
|
|
+ dn.reconfigureProperty(DFS_BLOCKREPORT_SPLIT_THRESHOLD_KEY, null);
|
|
|
+ assertNull(String.format("expect %s is not configured", DFS_BLOCKREPORT_SPLIT_THRESHOLD_KEY),
|
|
|
+ dn.getConf().get(DFS_BLOCKREPORT_SPLIT_THRESHOLD_KEY));
|
|
|
+
|
|
|
+ dn.reconfigureProperty(DFS_BLOCKREPORT_INITIAL_DELAY_KEY, null);
|
|
|
+ assertNull(String.format("expect %s is not configured", DFS_BLOCKREPORT_INITIAL_DELAY_KEY),
|
|
|
+ dn.getConf().get(DFS_BLOCKREPORT_INITIAL_DELAY_KEY));
|
|
|
}
|
|
|
}
|
|
|
|