tomscut commented on code in PR #5068:
URL: https://github.com/apache/hadoop/pull/5068#discussion_r1008774407
##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeReconfigure.java:
##########
@@ -567,6 +571,92 @@ private List<Boolean> validatePeerReport(String
jsonReport) {
return containReport;
}
+ @Test
+ public void testReconfigureDecommissionBackoffMonitorParameters()
+ throws ReconfigurationException, IOException {
+ Configuration conf = new HdfsConfiguration();
+ conf.setClass(DFSConfigKeys.DFS_NAMENODE_DECOMMISSION_MONITOR_CLASS,
+ DatanodeAdminBackoffMonitor.class,
DatanodeAdminMonitorInterface.class);
+ int defaultPendingRepLimit = 1000;
+ conf.setInt(DFS_NAMENODE_DECOMMISSION_BACKOFF_MONITOR_PENDING_LIMIT,
defaultPendingRepLimit);
+ int defaultBlocksPerLock = 1000;
+
conf.setInt(DFS_NAMENODE_DECOMMISSION_BACKOFF_MONITOR_PENDING_BLOCKS_PER_LOCK,
+ defaultBlocksPerLock);
+ MiniDFSCluster newCluster = new MiniDFSCluster.Builder(conf).build();
+ newCluster.waitActive();
+
+ try {
+ final NameNode nameNode = newCluster.getNameNode();
+ final DatanodeManager datanodeManager = nameNode.namesystem
+ .getBlockManager().getDatanodeManager();
+
+ // verify defaultPendingRepLimit.
+
assertEquals(datanodeManager.getDatanodeAdminManager().getPendingRepLimit(),
+ defaultPendingRepLimit);
+
+ // try invalid pendingRepLimit.
+ try {
+
nameNode.reconfigureProperty(DFS_NAMENODE_DECOMMISSION_BACKOFF_MONITOR_PENDING_LIMIT,
+ "non-numeric");
+ fail("Should not reach here");
+ } catch (ReconfigurationException e) {
+ assertEquals("Could not change property " +
+ "dfs.namenode.decommission.backoff.monitor.pending.limit from '" +
+ defaultPendingRepLimit + "' to 'non-numeric'", e.getMessage());
+ }
+
+ try {
+
nameNode.reconfigureProperty(DFS_NAMENODE_DECOMMISSION_BACKOFF_MONITOR_PENDING_LIMIT,
+ "-1");
+ fail("Should not reach here");
+ } catch (ReconfigurationException e) {
+ assertEquals("Could not change property " +
+ "dfs.namenode.decommission.backoff.monitor.pending.limit from '" +
+ defaultPendingRepLimit + "' to '-1'", e.getMessage());
+ }
+
+ // try correct pendingRepLimit.
+
nameNode.reconfigureProperty(DFS_NAMENODE_DECOMMISSION_BACKOFF_MONITOR_PENDING_LIMIT,
+ "20000");
+
assertEquals(datanodeManager.getDatanodeAdminManager().getPendingRepLimit(),
20000);
+
+ // verify defaultBlocksPerLock.
+
assertEquals(datanodeManager.getDatanodeAdminManager().getBlocksPerLock(),
+ defaultBlocksPerLock);
+
+ // try invalid blocksPerLock.
+ try {
+ nameNode.reconfigureProperty(
+ DFS_NAMENODE_DECOMMISSION_BACKOFF_MONITOR_PENDING_BLOCKS_PER_LOCK,
+ "non-numeric");
+ fail("Should not reach here");
+ } catch (ReconfigurationException e) {
+ assertEquals("Could not change property " +
+ "dfs.namenode.decommission.backoff.monitor.pending.blocks.per.lock
from '" +
+ defaultBlocksPerLock + "' to 'non-numeric'", e.getMessage());
+ }
+
+ try {
+ nameNode.reconfigureProperty(
+ DFS_NAMENODE_DECOMMISSION_BACKOFF_MONITOR_PENDING_BLOCKS_PER_LOCK,
"-1");
+ fail("Should not reach here");
+ } catch (ReconfigurationException e) {
+ assertEquals("Could not change property " +
+ "dfs.namenode.decommission.backoff.monitor.pending.blocks.per.lock
from '" +
+ defaultBlocksPerLock + "' to '-1'", e.getMessage());
+ }
+
+ // try correct blocksPerLock.
+ nameNode.reconfigureProperty(
+ DFS_NAMENODE_DECOMMISSION_BACKOFF_MONITOR_PENDING_BLOCKS_PER_LOCK,
"10000");
+
assertEquals(datanodeManager.getDatanodeAdminManager().getBlocksPerLock(),
10000);
+ } finally {
Review Comment:
```suggestion
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]