hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dran...@apache.org
Subject [25/30] hadoop git commit: HDFS-10569. A bug causes OutOfIndex error in BlockListAsLongs. Contributed by Weiwei Yang.
Date Thu, 04 Aug 2016 12:42:14 GMT
HDFS-10569. A bug causes OutOfIndex error in BlockListAsLongs. Contributed by Weiwei Yang.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/6f635666
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/6f635666
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/6f635666

Branch: refs/heads/HADOOP-12756
Commit: 6f63566694f8cec64a469448a8fa00ce921ce367
Parents: c827454
Author: Kihwal Lee <kihwal@apache.org>
Authored: Wed Aug 3 15:19:31 2016 -0500
Committer: Kihwal Lee <kihwal@apache.org>
Committed: Wed Aug 3 15:20:20 2016 -0500

----------------------------------------------------------------------
 .../hadoop/hdfs/protocol/BlockListAsLongs.java   |  4 ++--
 .../hdfs/protocol/TestBlockListAsLongs.java      | 19 ++++++++++++++++++-
 2 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/6f635666/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/BlockListAsLongs.java
----------------------------------------------------------------------
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 26c7ffb..8f482e3 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<BlockReportReplica>
{
       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<values.size(); i++) {
+        longs[2+i] = values.get(i);
       }
       return longs;
     }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/6f635666/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/TestBlockListAsLongs.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/TestBlockListAsLongs.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/TestBlockListAsLongs.java
index 2cc1f7d..cd2b5e8 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/TestBlockListAsLongs.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/TestBlockListAsLongs.java
@@ -188,6 +188,20 @@ public class TestBlockListAsLongs {
     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
   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, true));
     proto = request.get();
     assertNotNull(proto);


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message