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 and Description
    `BlockUnderConstructionFeature(org.apache.hadoop.hdfs.protocol.Block blk, HdfsServerConstants.BlockUCState state, DatanodeStorageInfo[] targets, org.apache.hadoop.hdfs.protocol.BlockType blockType)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `appendUCPartsConcise(StringBuilder sb)`
    `byte[]` | `getBlockIndices()`
    `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()`
    `org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo` | `getTruncateBlock()` Get recover block
    `void` | `initializeBlockRecovery(org.apache.hadoop.hdfs.server.blockmanagement.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(org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo recoveryBlock)`
    `String` | `toString()`

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

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

- - ### Constructor Detail

    - #### BlockUnderConstructionFeature

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

  - ### Method Detail

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

    - #### 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 org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo getTruncateBlock()

      Get recover block

    - #### setTruncateBlock

          public void setTruncateBlock(org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo recoveryBlock)

    - #### initializeBlockRecovery

          public void initializeBlockRecovery(org.apache.hadoop.hdfs.server.blockmanagement.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)

Copyright © 2008–2022 Apache Software Foundation. All rights reserved.