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

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

# Interface BlockCollection

All Known Implementing Classes:
  `INodeFile`

@Private public interface BlockCollection
This interface is used by the block manager to expose a few characteristics of a collection of Block/BlockUnderConstruction.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `org.apache.hadoop.fs.ContentSummary`
  `computeContentSummary(BlockStoragePolicySuite bsps)`
  Get content summary.
  `void`
  `convertLastBlockToUC(BlockInfo lastBlock, DatanodeStorageInfo[] targets)`
  Convert the last block of the collection to an under-construction block and set the locations.
  `BlockInfo[]`
  `getBlocks()`
  Get the blocks (striped or contiguous).
  `long`
  `getId()`
  `BlockInfo`
  `getLastBlock()`
  Get the last block of the collection.
  `String`
  `getName()`
  Get the name of the collection.
  `short`
  `getPreferredBlockReplication()`
  Get block replication for the collection.
  `long`
  `getPreferredBlockSize()`
  Get preferred block size for the collection
  `byte`
  `getStoragePolicyID()`
  `boolean`
  `isStriped()`
  `boolean`
  `isUnderConstruction()`
  `int`
  `numBlocks()`
  `void`
  `setBlock(int index, BlockInfo blk)`
  Set the block (contiguous or striped) at the given index.

- ## Method Details

  - ### getLastBlock

    BlockInfo getLastBlock()
    Get the last block of the collection.

  - ### computeContentSummary

    org.apache.hadoop.fs.ContentSummary computeContentSummary(BlockStoragePolicySuite bsps) throws org.apache.hadoop.security.AccessControlException
    Get content summary.
    Throws:
      `org.apache.hadoop.security.AccessControlException`

  - ### numBlocks

    int numBlocks()
    Returns:
      the number of blocks or block groups

  - ### getBlocks

    BlockInfo[] getBlocks()
    Get the blocks (striped or contiguous).

  - ### getPreferredBlockSize

    long getPreferredBlockSize()
    Get preferred block size for the collection
    Returns:
      preferred block size in bytes

  - ### getPreferredBlockReplication

    short getPreferredBlockReplication()
    Get block replication for the collection.
    Returns:
      block replication value. Return 0 if the file is erasure coded.

  - ### getStoragePolicyID

    byte getStoragePolicyID()
    Returns:
      the storage policy ID.

  - ### getName

    String getName()
    Get the name of the collection.

  - ### setBlock

    void setBlock(int index, BlockInfo blk)
    Set the block (contiguous or striped) at the given index.

  - ### convertLastBlockToUC

    void convertLastBlockToUC(BlockInfo lastBlock, DatanodeStorageInfo[] targets) throws IOException
    Convert the last block of the collection to an under-construction block and set the locations.
    Throws:
      `IOException`

  - ### isUnderConstruction

    boolean isUnderConstruction()
    Returns:
      whether the block collection is under construction.

  - ### isStriped

    boolean isStriped()
    Returns:
      whether the block collection is in striping format

  - ### getId

    long getId()
    Returns:
      the id for the block collection