HDFS-4815. TestRBWBlockInvalidation: Double call countReplicas() to fetch corruptReplicas and liveReplicas is not needed. Contributed by Tian Hong Wang.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1489668 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Aaron Myers 2013-06-04 23:01:37 +00:00
parent 66de4ccf60
commit 8171203692
2 changed files with 15 additions and 12 deletions

View File

@ -563,6 +563,9 @@ Release 2.1.0-beta - UNRELEASED
HDFS-4840. ReplicationMonitor gets NPE during shutdown. (kihwal) HDFS-4840. ReplicationMonitor gets NPE during shutdown. (kihwal)
HDFS-4815. TestRBWBlockInvalidation: Double call countReplicas() to fetch
corruptReplicas and liveReplicas is not needed. (Tian Hong Wang via atm)
BREAKDOWN OF HDFS-347 SUBTASKS AND RELATED JIRAS BREAKDOWN OF HDFS-347 SUBTASKS AND RELATED JIRAS
HDFS-4353. Encapsulate connections to peers in Peer and PeerServer classes. HDFS-4353. Encapsulate connections to peers in Peer and PeerServer classes.

View File

@ -70,7 +70,7 @@ public class TestRBWBlockInvalidation {
throws IOException, InterruptedException { throws IOException, InterruptedException {
Configuration conf = new HdfsConfiguration(); Configuration conf = new HdfsConfiguration();
conf.setInt(DFSConfigKeys.DFS_REPLICATION_KEY, 2); conf.setInt(DFSConfigKeys.DFS_REPLICATION_KEY, 2);
conf.setLong(DFSConfigKeys.DFS_BLOCKREPORT_INTERVAL_MSEC_KEY, 300); conf.setLong(DFSConfigKeys.DFS_BLOCKREPORT_INTERVAL_MSEC_KEY, 100);
conf.setLong(DFSConfigKeys.DFS_DATANODE_DIRECTORYSCAN_INTERVAL_KEY, 1); conf.setLong(DFSConfigKeys.DFS_DATANODE_DIRECTORYSCAN_INTERVAL_KEY, 1);
conf.setLong(DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_KEY, 1); conf.setLong(DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_KEY, 1);
MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(2) MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(2)
@ -101,27 +101,27 @@ public class TestRBWBlockInvalidation {
out.close(); out.close();
// Check datanode has reported the corrupt block. // Check datanode has reported the corrupt block.
boolean isCorruptReported = false; int corruptReplicas = 0;
while (!isCorruptReported) { while (true) {
if (countReplicas(namesystem, blk).corruptReplicas() > 0) { if ((corruptReplicas = countReplicas(namesystem, blk).corruptReplicas()) > 0) {
isCorruptReported = true; break;
} }
Thread.sleep(100); Thread.sleep(100);
} }
assertEquals("There should be 1 replica in the corruptReplicasMap", 1, assertEquals("There should be 1 replica in the corruptReplicasMap", 1,
countReplicas(namesystem, blk).corruptReplicas()); corruptReplicas);
// Check the block has got replicated to another datanode. // Check the block has got replicated to another datanode.
blk = DFSTestUtil.getFirstBlock(fs, testPath); blk = DFSTestUtil.getFirstBlock(fs, testPath);
boolean isReplicated = false; int liveReplicas = 0;
while (!isReplicated) { while (true) {
if (countReplicas(namesystem, blk).liveReplicas() > 1) { if ((liveReplicas = countReplicas(namesystem, blk).liveReplicas()) > 1) {
isReplicated = true; break;
} }
Thread.sleep(100); Thread.sleep(100);
} }
assertEquals("There should be two live replicas", 2, countReplicas( assertEquals("There should be two live replicas", 2,
namesystem, blk).liveReplicas()); liveReplicas);
// sleep for 1 second, so that by this time datanode reports the corrupt // sleep for 1 second, so that by this time datanode reports the corrupt
// block after a live replica of block got replicated. // block after a live replica of block got replicated.