Class BlockUnderConstructionFeature
java.lang.Object
org.apache.hadoop.hdfs.server.blockmanagement.BlockUnderConstructionFeature
Represents the under construction feature of a Block.
This is usually the last block of a file opened for write or append.
-
Constructor Summary
ConstructorsConstructorDescriptionBlockUnderConstructionFeature(org.apache.hadoop.hdfs.protocol.Block blk, HdfsServerConstants.BlockUCState state, DatanodeStorageInfo[] targets, org.apache.hadoop.hdfs.protocol.BlockType blockType) -
Method Summary
Modifier and TypeMethodDescriptionvoidbyte[]byte[]getBlockIndicesForSpecifiedStorages(List<Integer> storageIdx) longReturn the state of the block under construction.Create array of expected replica locations (as has been assigned by chooseTargets()).Note that this iterator doesn't guarantee thread-safe.intGet recover blockvoidinitializeBlockRecovery(BlockInfo blockInfo, long recoveryId, boolean startRecovery) Initialize lease recovery for this block.voidsetExpectedLocations(org.apache.hadoop.hdfs.protocol.Block block, DatanodeStorageInfo[] targets, org.apache.hadoop.hdfs.protocol.BlockType blockType) Set expected locationsvoidsetTruncateBlock(BlockInfo recoveryBlock) toString()
-
Constructor Details
-
BlockUnderConstructionFeature
public BlockUnderConstructionFeature(org.apache.hadoop.hdfs.protocol.Block blk, HdfsServerConstants.BlockUCState state, DatanodeStorageInfo[] targets, org.apache.hadoop.hdfs.protocol.BlockType blockType)
-
-
Method Details
-
setExpectedLocations
public void setExpectedLocations(org.apache.hadoop.hdfs.protocol.Block block, DatanodeStorageInfo[] targets, org.apache.hadoop.hdfs.protocol.BlockType blockType) Set expected locations -
getExpectedStorageLocations
Create array of expected replica locations (as has been assigned by chooseTargets()). -
getExpectedStorageLocationsIterator
Note that this iterator doesn't guarantee thread-safe. It depends on external mechanisms such as the FSNamesystem lock for protection. -
getBlockIndices
public byte[] getBlockIndices()- Returns:
- the index array indicating the block index in each storage. Used only by striped blocks.
-
getBlockIndicesForSpecifiedStorages
-
getNumExpectedLocations
public int getNumExpectedLocations() -
getBlockUCState
Return the state of the block under construction.- See Also:
-
getBlockRecoveryId
public long getBlockRecoveryId() -
getTruncateBlock
Get recover block -
setTruncateBlock
-
initializeBlockRecovery
Initialize lease recovery for this block. Find the first alive data-node starting from the previous primary and make it primary.- Parameters:
blockInfo- Block to be recoveredrecoveryId- Recovery ID (new gen stamp)startRecovery- Issue recovery command to datanode if true.
-
toString
-
appendUCPartsConcise
-