haiyang1987 commented on code in PR #6896:
URL: https://github.com/apache/hadoop/pull/6896#discussion_r1730368502
##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockManager.java:
##########
@@ -2329,4 +2331,81 @@ public void delayDeleteReplica() {
DataNodeFaultInjector.set(oldInjector);
}
}
+
+ private void waitForDecommissionedNodes(final DatanodeAdminManager
dnAdminMgr,
+ final int trackedNumber)
+ throws TimeoutException, InterruptedException {
+ GenericTestUtils
+ .waitFor(() -> dnAdminMgr.getNumTrackedNodes() == trackedNumber,
+ 100, 2000);
+ }
+
+ @Test(timeout = 360000)
+ public void testDecommissionWithPendingTimeout() throws Exception {
+ Configuration conf = new HdfsConfiguration();
+ conf.setBoolean(DFSConfigKeys.DFS_NAMENODE_REDUNDANCY_CONSIDERLOAD_KEY,
false);
+
+ HostsFileWriter hostsFileWriter = new HostsFileWriter();
+ hostsFileWriter.initialize(conf, "work-dir/decommission");
+ conf.setInt(DFSConfigKeys.DFS_NAMENODE_HEARTBEAT_RECHECK_INTERVAL_KEY,
1000);
+ conf.setInt(DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_KEY, 1);
+
conf.setInt(DFSConfigKeys.DFS_NAMENODE_RECONSTRUCTION_PENDING_TIMEOUT_SEC_KEY,
2);
+ conf.setInt(DFSConfigKeys.DFS_NAMENODE_REDUNDANCY_INTERVAL_SECONDS_KEY,
10);
+ conf.setInt(DFSConfigKeys.DFS_NAMENODE_DECOMMISSION_INTERVAL_KEY, 1);
+ conf.setLong(DFSConfigKeys.DFS_DATANODE_BALANCE_BANDWIDTHPERSEC_KEY, 1);
+
+ MiniDFSCluster cluster = new
MiniDFSCluster.Builder(conf).numDataNodes(2).build();
Review Comment:
From [2357-2380], maybe can update logic
```
MiniDFSCluster cluster = new
MiniDFSCluster.Builder(conf).numDataNodes(2).build();
try {
cluster.waitActive();
BlockManager blockManager = cluster.getNamesystem().getBlockManager();
DatanodeManager dm = blockManager.getDatanodeManager();
dm.setHeartbeatExpireInterval(3000);
DistributedFileSystem fs = cluster.getFileSystem();
// create a file
Path filePath = new Path("/tmp.txt");
DFSTestUtil.createFile(fs, filePath, 1024, (short) 1, 0L);
LocatedBlocks blocks =
NameNodeAdapter.getBlockLocations(cluster.getNameNode(),
filePath.toString(), 0, 1);
LocatedBlock locatedBlock = blocks.get(0);
BlockInfo bi =
blockManager.getStoredBlock(locatedBlock.getBlock().getLocalBlock());
String dnName = locatedBlock.getLocations()[0].getXferAddr();
ArrayList<String> dns = new ArrayList<String>(1);
```
--
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]