HDFS-5457. Fix TestDatanodeRegistration, TestFsck and TestAddBlockRetry. (Contributed by szetszwo)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-2832@1538794 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Arpit Agarwal 2013-11-04 22:49:00 +00:00
parent 1d357365b7
commit d2b7b6589d
4 changed files with 11 additions and 6 deletions

View File

@ -70,3 +70,6 @@ IMPROVEMENTS:
HDFS-5455. NN should update storageMap on first heartbeat. (Arpit Agarwal)
HDFS-5457. Fix TestDatanodeRegistration, TestFsck and TestAddBlockRetry.
(Contributed bt szetszwo)

View File

@ -385,7 +385,7 @@ private BlockIterator(final DatanodeStorageInfo... storages) {
@Override
public boolean hasNext() {
update();
return iterators.get(index).hasNext();
return !iterators.isEmpty() && iterators.get(index).hasNext();
}
@Override

View File

@ -5774,7 +5774,8 @@ void reportBadBlocks(LocatedBlock[] blocks) throws IOException {
DatanodeInfo[] nodes = blocks[i].getLocations();
String[] storageIDs = blocks[i].getStorageIDs();
for (int j = 0; j < nodes.length; j++) {
blockManager.findAndMarkBlockAsCorrupt(blk, nodes[j], storageIDs[j],
blockManager.findAndMarkBlockAsCorrupt(blk, nodes[j],
storageIDs == null ? null: storageIDs[j],
"client machine reported it");
}
}

View File

@ -39,6 +39,7 @@
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor;
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeStorageInfo;
import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocols;
import org.apache.hadoop.io.EnumSetWritable;
import org.apache.hadoop.net.Node;
@ -99,13 +100,13 @@ public void testRetryAddBlockWhileInChooseTarget() throws Exception {
bmField.setAccessible(true);
bmField.set(ns, spyBM);
doAnswer(new Answer<DatanodeDescriptor[]>() {
doAnswer(new Answer<DatanodeStorageInfo[]>() {
@Override
public DatanodeDescriptor[] answer(InvocationOnMock invocation)
public DatanodeStorageInfo[] answer(InvocationOnMock invocation)
throws Throwable {
LOG.info("chooseTarget for " + src);
DatanodeDescriptor[] ret =
(DatanodeDescriptor[]) invocation.callRealMethod();
DatanodeStorageInfo[] ret =
(DatanodeStorageInfo[]) invocation.callRealMethod();
count++;
if(count == 1) { // run second addBlock()
LOG.info("Starting second addBlock for " + src);