org.apache.hadoop.hdfs.server.blockmanagement
Class BlockInfo

java.lang.Object
  extended by org.apache.hadoop.hdfs.protocol.Block
      extended by org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo
All Implemented Interfaces:
Comparable<org.apache.hadoop.hdfs.protocol.Block>, LightWeightGSet.LinkedElement, org.apache.hadoop.io.Writable
Direct Known Subclasses:
BlockInfoUnderConstruction

public class BlockInfo
extends org.apache.hadoop.hdfs.protocol.Block
implements LightWeightGSet.LinkedElement

Internal class for block metadata.


Field Summary
 
Fields inherited from class org.apache.hadoop.hdfs.protocol.Block
BLOCK_FILE_PREFIX, blockFilePattern, METADATA_EXTENSION, metaFilePattern
 
Constructor Summary
protected BlockInfo(BlockInfo from)
          Copy construction.
  BlockInfo(org.apache.hadoop.hdfs.protocol.Block blk, int replication)
           
  BlockInfo(int replication)
          Construct an entry for blocksmap
 
Method Summary
 boolean addNode(org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor node)
          Add data-node this block belongs to.
 BlockInfoUnderConstruction convertToBlockUnderConstruction(HdfsServerConstants.BlockUCState s, org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor[] targets)
          Convert a complete block to an under construction block.
 boolean equals(Object obj)
           
 HdfsServerConstants.BlockUCState getBlockUCState()
          BlockInfo represents a block that is not being constructed.
 INodeFile getINode()
           
 LightWeightGSet.LinkedElement getNext()
          Get the next element.
 int hashCode()
           
 boolean isComplete()
          Is this block complete?
 BlockInfo listInsert(BlockInfo head, org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor dn)
          Insert this block into the head of the list of blocks related to the specified DatanodeDescriptor.
 BlockInfo listRemove(BlockInfo head, org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor dn)
          Remove this block from the list of blocks related to the specified DatanodeDescriptor.
 boolean removeNode(org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor node)
          Remove data-node from the block.
 void setINode(INodeFile inode)
           
 void setNext(LightWeightGSet.LinkedElement next)
          Set the next element.
 
Methods inherited from class org.apache.hadoop.hdfs.protocol.Block
compareTo, filename2id, getBlockId, getBlockId, getBlockName, getGenerationStamp, getGenerationStamp, getNumBytes, isBlockFilename, isMetaFilename, readFields, readId, set, setBlockId, setGenerationStamp, setNumBytes, toString, write, writeId
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BlockInfo

public BlockInfo(int replication)
Construct an entry for blocksmap

Parameters:
replication - the block's replication factor

BlockInfo

public BlockInfo(org.apache.hadoop.hdfs.protocol.Block blk,
                 int replication)

BlockInfo

protected BlockInfo(BlockInfo from)
Copy construction. This is used to convert BlockInfoUnderConstruction

Parameters:
from - BlockInfo to copy from.
Method Detail

getINode

public INodeFile getINode()

setINode

public void setINode(INodeFile inode)

addNode

public boolean addNode(org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor node)
Add data-node this block belongs to.


removeNode

public boolean removeNode(org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor node)
Remove data-node from the block.


listInsert

public BlockInfo listInsert(BlockInfo head,
                            org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor dn)
Insert this block into the head of the list of blocks related to the specified DatanodeDescriptor. If the head is null then form a new list.

Returns:
current block as the new head of the list.

listRemove

public BlockInfo listRemove(BlockInfo head,
                            org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor dn)
Remove this block from the list of blocks related to the specified DatanodeDescriptor. If this block is the head of the list then return the next block as the new head.

Returns:
the new head of the list or null if the list becomes empty after deletion.

getBlockUCState

public HdfsServerConstants.BlockUCState getBlockUCState()
BlockInfo represents a block that is not being constructed. In order to start modifying the block, the BlockInfo should be converted to BlockInfoUnderConstruction.

Returns:
HdfsServerConstants.BlockUCState.COMPLETE

isComplete

public boolean isComplete()
Is this block complete?

Returns:
true if the state of the block is HdfsServerConstants.BlockUCState.COMPLETE

convertToBlockUnderConstruction

public BlockInfoUnderConstruction convertToBlockUnderConstruction(HdfsServerConstants.BlockUCState s,
                                                                  org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor[] targets)
Convert a complete block to an under construction block.

Returns:
BlockInfoUnderConstruction - an under construction block.

hashCode

public int hashCode()
Overrides:
hashCode in class org.apache.hadoop.hdfs.protocol.Block

equals

public boolean equals(Object obj)
Overrides:
equals in class org.apache.hadoop.hdfs.protocol.Block

getNext

public LightWeightGSet.LinkedElement getNext()
Description copied from interface: LightWeightGSet.LinkedElement
Get the next element.

Specified by:
getNext in interface LightWeightGSet.LinkedElement

setNext

public void setNext(LightWeightGSet.LinkedElement next)
Description copied from interface: LightWeightGSet.LinkedElement
Set the next element.

Specified by:
setNext in interface LightWeightGSet.LinkedElement


Copyright © 2013 Apache Software Foundation. All Rights Reserved.