HDFS-10569. A bug causes OutOfIndex error in BlockListAsLongs. Contributed by Weiwei Yang.
(cherry picked from commit6f63566694
) Conflicts: hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/TestBlockListAsLongs.java (cherry picked from commit1ca2ab4013
)
This commit is contained in:
parent
6fc68a379b
commit
ceac628378
|
@ -468,8 +468,8 @@ public abstract class BlockListAsLongs implements Iterable<BlockReportReplica> {
|
||||||
long[] longs = new long[2+values.size()];
|
long[] longs = new long[2+values.size()];
|
||||||
longs[0] = finalizedBlocks;
|
longs[0] = finalizedBlocks;
|
||||||
longs[1] = numBlocks - finalizedBlocks;
|
longs[1] = numBlocks - finalizedBlocks;
|
||||||
for (int i=0; i < longs.length; i++) {
|
for(int i=0; i<values.size(); i++) {
|
||||||
longs[i] = values.get(i);
|
longs[2+i] = values.get(i);
|
||||||
}
|
}
|
||||||
return longs;
|
return longs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,6 +188,20 @@ public class TestBlockListAsLongs {
|
||||||
assertTrue(reportReplicas.isEmpty());
|
assertTrue(reportReplicas.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BlockListAsLongs getBlockList(Replica ... replicas) {
|
||||||
|
int numBlocks = replicas.length;
|
||||||
|
List<Long> longs = new ArrayList<Long>(2 + numBlocks);
|
||||||
|
longs.add(Long.valueOf(numBlocks));
|
||||||
|
longs.add(0L);
|
||||||
|
for(Replica r : replicas) {
|
||||||
|
longs.add(r.getBlockId());
|
||||||
|
longs.add(r.getBytesOnDisk());
|
||||||
|
longs.add(r.getGenerationStamp());
|
||||||
|
}
|
||||||
|
BlockListAsLongs blockList = BlockListAsLongs.decodeLongs(longs);
|
||||||
|
return blockList;
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCapabilitiesInited() {
|
public void testCapabilitiesInited() {
|
||||||
NamespaceInfo nsInfo = new NamespaceInfo();
|
NamespaceInfo nsInfo = new NamespaceInfo();
|
||||||
|
@ -237,7 +251,10 @@ public class TestBlockListAsLongs {
|
||||||
// back up to prior version and check DN sends old-style BR
|
// back up to prior version and check DN sends old-style BR
|
||||||
request.set(null);
|
request.set(null);
|
||||||
nsInfo.setCapabilities(Capability.UNKNOWN.getMask());
|
nsInfo.setCapabilities(Capability.UNKNOWN.getMask());
|
||||||
nn.blockReport(reg, "pool", sbr,
|
BlockListAsLongs blockList = getBlockList(r);
|
||||||
|
StorageBlockReport[] obp = new StorageBlockReport[] {
|
||||||
|
new StorageBlockReport(new DatanodeStorage("s1"), blockList) };
|
||||||
|
nn.blockReport(reg, "pool", obp,
|
||||||
new BlockReportContext(1, 0, System.nanoTime(), 0L));
|
new BlockReportContext(1, 0, System.nanoTime(), 0L));
|
||||||
proto = request.get();
|
proto = request.get();
|
||||||
assertNotNull(proto);
|
assertNotNull(proto);
|
||||||
|
|
Loading…
Reference in New Issue