BlockUnderConstructionFeature (Apache Hadoop HDFS 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.server.blockmanagement, class: BlockUnderConstructionFeature

Package org.apache.hadoop.hdfs.server.blockmanagement

# Class BlockUnderConstructionFeature

java.lang.Object
org.apache.hadoop.hdfs.server.blockmanagement.BlockUnderConstructionFeature

public class BlockUnderConstructionFeature extends Object
Represents the under construction feature of a Block. This is usually the last block of a file opened for write or append.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BlockUnderConstructionFeature(org.apache.hadoop.hdfs.protocol.Block blk, HdfsServerConstants.BlockUCState state, DatanodeStorageInfo[] targets, org.apache.hadoop.hdfs.protocol.BlockType blockType)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `appendUCPartsConcise(StringBuilder sb)`
  `byte[]`
  `getBlockIndices()`
  `byte[]`
  `getBlockIndicesForSpecifiedStorages(List<Integer> storageIdx)`
  `long`
  `getBlockRecoveryId()`
  `HdfsServerConstants.BlockUCState`
  `getBlockUCState()`
  Return the state of the block under construction.
  `DatanodeStorageInfo[]`
  `getExpectedStorageLocations()`
  Create array of expected replica locations (as has been assigned by chooseTargets()).
  `Iterator<DatanodeStorageInfo>`
  `getExpectedStorageLocationsIterator()`
  Note that this iterator doesn't guarantee thread-safe.
  `int`
  `getNumExpectedLocations()`
  `BlockInfo`
  `getTruncateBlock()`
  Get recover block
  `void`
  `initializeBlockRecovery(BlockInfo blockInfo, long recoveryId, boolean startRecovery)`
  Initialize lease recovery for this block.
  `void`
  `setExpectedLocations(org.apache.hadoop.hdfs.protocol.Block block, DatanodeStorageInfo[] targets, org.apache.hadoop.hdfs.protocol.BlockType blockType)`
  Set expected locations
  `void`
  `setTruncateBlock(BlockInfo recoveryBlock)`
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## 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

    public DatanodeStorageInfo[] getExpectedStorageLocations()
    Create array of expected replica locations (as has been assigned by chooseTargets()).

  - ### getExpectedStorageLocationsIterator

    public Iterator<DatanodeStorageInfo> 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

    public byte[] getBlockIndicesForSpecifiedStorages(List<Integer> storageIdx)

  - ### getNumExpectedLocations

    public int getNumExpectedLocations()

  - ### getBlockUCState

    public HdfsServerConstants.BlockUCState getBlockUCState()
    Return the state of the block under construction.
    See Also:
      - `HdfsServerConstants.BlockUCState`

  - ### getBlockRecoveryId

    public long getBlockRecoveryId()

  - ### getTruncateBlock

    public BlockInfo getTruncateBlock()
    Get recover block

  - ### setTruncateBlock

    public void setTruncateBlock(BlockInfo recoveryBlock)

  - ### initializeBlockRecovery

    public void initializeBlockRecovery(BlockInfo blockInfo, long recoveryId, boolean startRecovery)
    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 recovered
      `recoveryId` - Recovery ID (new gen stamp)
      `startRecovery` - Issue recovery command to datanode if true.

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### appendUCPartsConcise

    public void appendUCPartsConcise(StringBuilder sb)