From c4e4e561608d332245837060e777786644046a90 Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Tue, 15 May 2012 17:23:50 +0000 Subject: [PATCH] HDFS-3419. Cleanup LocatedBlock. Contributed by Eli Collins git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1338802 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 ++ .../hadoop/hdfs/protocol/LocatedBlock.java | 27 ++++--------------- .../hadoop/hdfs/protocol/LocatedBlocks.java | 5 ++-- 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index e05ac898a9a..661f17b83a7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -468,6 +468,8 @@ Release 2.0.0 - UNRELEASED HDFS-3416. Cleanup DatanodeID and DatanodeRegistration constructors used by testing. (eli) + HDFS-3419. Cleanup LocatedBlock. (eli) + OPTIMIZATIONS HDFS-3024. Improve performance of stringification in addStoredBlock (todd) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/LocatedBlock.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/LocatedBlock.java index c905e532465..d9da5b845b7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/LocatedBlock.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/LocatedBlock.java @@ -22,11 +22,11 @@ import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier; import org.apache.hadoop.security.token.Token; -/**************************************************** - * A LocatedBlock is a pair of Block, DatanodeInfo[] - * objects. It tells where to find a Block. - * - ****************************************************/ +/** + * Associates a block with the Datanodes that contain its replicas + * and other block metadata (E.g. the file offset associated with this + * block, whether it is corrupt, security token, etc). + */ @InterfaceAudience.Private @InterfaceStability.Evolving public class LocatedBlock { @@ -40,19 +40,6 @@ public class LocatedBlock { private boolean corrupt; private Token blockToken = new Token(); - public LocatedBlock() { - this(new ExtendedBlock(), new DatanodeInfo[0], 0L, false); - } - - - public LocatedBlock(ExtendedBlock eb) { - this(eb, new DatanodeInfo[0], 0L, false); - } - - public LocatedBlock(String bpid, Block b, DatanodeInfo[] locs) { - this(new ExtendedBlock(bpid, b), locs, -1, false); // startOffset is unknown - } - public LocatedBlock(ExtendedBlock b, DatanodeInfo[] locs) { this(b, locs, -1, false); // startOffset is unknown } @@ -81,14 +68,10 @@ public class LocatedBlock { this.blockToken = token; } - /** - */ public ExtendedBlock getBlock() { return b; } - /** - */ public DatanodeInfo[] getLocations() { return locs; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/LocatedBlocks.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/LocatedBlocks.java index 72aa47f3c0a..fbe869079a1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/LocatedBlocks.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/LocatedBlocks.java @@ -105,8 +105,9 @@ public class LocatedBlocks { * @return block if found, or null otherwise. */ public int findBlock(long offset) { - // create fake block of size 1 as a key - LocatedBlock key = new LocatedBlock(); + // create fake block of size 0 as a key + LocatedBlock key = new LocatedBlock( + new ExtendedBlock(), new DatanodeInfo[0], 0L, false); key.setStartOffset(offset); key.getBlock().setNumBytes(1); Comparator comp =