diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/BlockListAsLongs.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/BlockListAsLongs.java index 26c7ffb02ce..8f482e3531b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/BlockListAsLongs.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/BlockListAsLongs.java @@ -468,8 +468,8 @@ public abstract class BlockListAsLongs implements Iterable { long[] longs = new long[2+values.size()]; longs[0] = finalizedBlocks; longs[1] = numBlocks - finalizedBlocks; - for (int i=0; i < longs.length; i++) { - longs[i] = values.get(i); + for(int i=0; i longs = new ArrayList(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 public void testCapabilitiesInited() { NamespaceInfo nsInfo = new NamespaceInfo(); @@ -237,7 +251,10 @@ public class TestBlockListAsLongs { // back up to prior version and check DN sends old-style BR request.set(null); 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)); proto = request.get(); assertNotNull(proto);