Class BlockIdManager

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

public class BlockIdManager extends Object
BlockIdManager allocates the generation stamps and the block ID. The FSNamesystem is responsible for persisting the allocations in the FSEditLog.
  • Constructor Details

    • BlockIdManager

      public BlockIdManager(BlockManager blockManager)
  • Method Details

    • upgradeLegacyGenerationStamp

      public long upgradeLegacyGenerationStamp()
      Upgrades the generation stamp for the filesystem by reserving a sufficient range for all existing blocks. Should be invoked only during the first upgrade to sequential block IDs.
    • setLegacyGenerationStampLimit

      public void setLegacyGenerationStampLimit(long stamp)
      Sets the generation stamp that delineates random and sequentially allocated block IDs.
      Parameters:
      stamp - set generation stamp limit to this value
    • getGenerationStampAtblockIdSwitch

      public long getGenerationStampAtblockIdSwitch()
      Gets the value of the generation stamp that delineates sequential and random block IDs.
    • setLastAllocatedContiguousBlockId

      public void setLastAllocatedContiguousBlockId(long blockId)
      Sets the maximum allocated contiguous block ID for this filesystem. This is the basis for allocating new block IDs.
    • getLastAllocatedContiguousBlockId

      public long getLastAllocatedContiguousBlockId()
      Gets the maximum sequentially allocated contiguous block ID for this filesystem
    • setLastAllocatedStripedBlockId

      public void setLastAllocatedStripedBlockId(long blockId)
      Sets the maximum allocated striped block ID for this filesystem. This is the basis for allocating new block IDs.
    • getLastAllocatedStripedBlockId

      public long getLastAllocatedStripedBlockId()
      Gets the maximum sequentially allocated striped block ID for this filesystem
    • setLegacyGenerationStamp

      public void setLegacyGenerationStamp(long stamp)
      Sets the current generation stamp for legacy blocks
    • getLegacyGenerationStamp

      public long getLegacyGenerationStamp()
      Gets the current generation stamp for legacy blocks
    • setGenerationStamp

      public void setGenerationStamp(long stamp)
      Gets the current generation stamp for this filesystem
    • setImpendingGenerationStamp

      public void setImpendingGenerationStamp(long stamp)
      Set the currently highest gen stamp from active. Used by Standby only.
      Parameters:
      stamp - new genstamp
    • applyImpendingGenerationStamp

      public void applyImpendingGenerationStamp()
      Set the current genstamp to the impending genstamp.
    • getImpendingGenerationStamp

      @VisibleForTesting public long getImpendingGenerationStamp()
    • setGenerationStampIfGreater

      public void setGenerationStampIfGreater(long stamp)
      Set genstamp only when the given one is higher.
      Parameters:
      stamp -
    • getGenerationStamp

      public long getGenerationStamp()
    • getLegacyGenerationStampLimit

      public long getLegacyGenerationStampLimit()
    • isStripedBlock

      public boolean isStripedBlock(org.apache.hadoop.hdfs.protocol.Block block)
      Return true if the block is a striped block. Before HDFS-4645, block ID was randomly generated (legacy), so it is possible that legacy block ID to be negative, which should not be considered as striped block ID.
      See Also:
      • detecting legacy block IDs.
    • isStripedBlockID

      public static boolean isStripedBlockID(long id)
      See isStripedBlock(Block), we should not use this function alone to determine a block is striped block.
    • getBlockIndex

      public static byte getBlockIndex(org.apache.hadoop.hdfs.protocol.Block reportedBlock)