HDFS-3419. svn merge -c 1338802 from trunk

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1338805 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Eli Collins 2012-05-15 17:24:22 +00:00
parent 5ea3d6cf5d
commit 053f50f713
3 changed files with 10 additions and 24 deletions

View File

@ -332,6 +332,8 @@ Release 2.0.0 - UNRELEASED
HDFS-3416. Cleanup DatanodeID and DatanodeRegistration HDFS-3416. Cleanup DatanodeID and DatanodeRegistration
constructors used by testing. (eli) constructors used by testing. (eli)
HDFS-3419. Cleanup LocatedBlock. (eli)
OPTIMIZATIONS OPTIMIZATIONS
HDFS-2477. Optimize computing the diff between a block report and the HDFS-2477. Optimize computing the diff between a block report and the

View File

@ -22,11 +22,11 @@ import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier; import org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier;
import org.apache.hadoop.security.token.Token; import org.apache.hadoop.security.token.Token;
/**************************************************** /**
* A LocatedBlock is a pair of Block, DatanodeInfo[] * Associates a block with the Datanodes that contain its replicas
* objects. It tells where to find a Block. * and other block metadata (E.g. the file offset associated with this
* * block, whether it is corrupt, security token, etc).
****************************************************/ */
@InterfaceAudience.Private @InterfaceAudience.Private
@InterfaceStability.Evolving @InterfaceStability.Evolving
public class LocatedBlock { public class LocatedBlock {
@ -40,19 +40,6 @@ public class LocatedBlock {
private boolean corrupt; private boolean corrupt;
private Token<BlockTokenIdentifier> blockToken = new Token<BlockTokenIdentifier>(); private Token<BlockTokenIdentifier> blockToken = new Token<BlockTokenIdentifier>();
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) { public LocatedBlock(ExtendedBlock b, DatanodeInfo[] locs) {
this(b, locs, -1, false); // startOffset is unknown this(b, locs, -1, false); // startOffset is unknown
} }
@ -81,14 +68,10 @@ public class LocatedBlock {
this.blockToken = token; this.blockToken = token;
} }
/**
*/
public ExtendedBlock getBlock() { public ExtendedBlock getBlock() {
return b; return b;
} }
/**
*/
public DatanodeInfo[] getLocations() { public DatanodeInfo[] getLocations() {
return locs; return locs;
} }

View File

@ -105,8 +105,9 @@ public class LocatedBlocks {
* @return block if found, or null otherwise. * @return block if found, or null otherwise.
*/ */
public int findBlock(long offset) { public int findBlock(long offset) {
// create fake block of size 1 as a key // create fake block of size 0 as a key
LocatedBlock key = new LocatedBlock(); LocatedBlock key = new LocatedBlock(
new ExtendedBlock(), new DatanodeInfo[0], 0L, false);
key.setStartOffset(offset); key.setStartOffset(offset);
key.getBlock().setNumBytes(1); key.getBlock().setNumBytes(1);
Comparator<LocatedBlock> comp = Comparator<LocatedBlock> comp =