|
@@ -27,6 +27,7 @@ import org.apache.hadoop.hdfs.DFSTestUtil;
|
|
import org.apache.hadoop.hdfs.HdfsConfiguration;
|
|
import org.apache.hadoop.hdfs.HdfsConfiguration;
|
|
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
|
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
|
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
|
|
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
|
|
|
|
+import org.apache.hadoop.hdfs.server.datanode.DataNodeTestUtils;
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
|
|
|
|
public class TestUnderReplicatedBlocks {
|
|
public class TestUnderReplicatedBlocks {
|
|
@@ -49,6 +50,12 @@ public class TestUnderReplicatedBlocks {
|
|
ExtendedBlock b = DFSTestUtil.getFirstBlock(fs, FILE_PATH);
|
|
ExtendedBlock b = DFSTestUtil.getFirstBlock(fs, FILE_PATH);
|
|
DatanodeDescriptor dn = bm.blocksMap.nodeIterator(b.getLocalBlock()).next();
|
|
DatanodeDescriptor dn = bm.blocksMap.nodeIterator(b.getLocalBlock()).next();
|
|
bm.addToInvalidates(b.getLocalBlock(), dn);
|
|
bm.addToInvalidates(b.getLocalBlock(), dn);
|
|
|
|
+ // Compute the invalidate work in NN, and trigger the heartbeat from DN
|
|
|
|
+ BlockManagerTestUtil.computeAllPendingWork(bm);
|
|
|
|
+ DataNodeTestUtils.triggerHeartbeat(cluster.getDataNode(dn.getIpcPort()));
|
|
|
|
+ // Wait to make sure the DataNode receives the deletion request
|
|
|
|
+ Thread.sleep(1000);
|
|
|
|
+ // Remove the record from blocksMap
|
|
bm.blocksMap.removeNode(b.getLocalBlock(), dn);
|
|
bm.blocksMap.removeNode(b.getLocalBlock(), dn);
|
|
|
|
|
|
// increment this file's replication factor
|
|
// increment this file's replication factor
|