Class LocatedBlock

java.lang.Object
org.apache.hadoop.hdfs.protocol.LocatedBlock
Direct Known Subclasses:
LocatedStripedBlock

@Private @Evolving public class LocatedBlock extends Object
Associates a block with the Datanodes that contain its replicas and other block metadata (E.g. the file offset associated with this block, whether it is corrupt, a location is cached in memory, security token, etc).
  • Constructor Details

  • Method Details

    • getBlockToken

      public org.apache.hadoop.security.token.Token<BlockTokenIdentifier> getBlockToken()
    • setBlockToken

      public void setBlockToken(org.apache.hadoop.security.token.Token<BlockTokenIdentifier> token)
    • getBlock

      public ExtendedBlock getBlock()
    • getLocations

      public DatanodeInfoWithStorage[] getLocations()
      Returns the locations associated with this block. The returned array is not expected to be modified. If it is, caller must immediately invoke updateCachedStorageInfo() to update the cached Storage ID/Type arrays.
    • getStorageTypes

      public org.apache.hadoop.fs.StorageType[] getStorageTypes()
    • getStorageIDs

      public String[] getStorageIDs()
    • updateCachedStorageInfo

      public void updateCachedStorageInfo()
      Updates the cached StorageID and StorageType information. Must be called when the locations array is modified.
    • moveProvidedToEnd

      public void moveProvidedToEnd(int activeLen)
      Moves all locations that have StorageType PROVIDED to the end of the locations array without changing the relative ordering of the remaining locations Only the first activeLen locations are considered. The caller must immediately invoke updateCachedStorageInfo() to update the cached Storage ID/Type arrays.
      Parameters:
      activeLen -
    • getStartOffset

      public long getStartOffset()
    • getBlockSize

      public long getBlockSize()
    • setStartOffset

      public void setStartOffset(long value)
    • setCorrupt

      public void setCorrupt(boolean corrupt)
    • isCorrupt

      public boolean isCorrupt()
    • addCachedLoc

      public void addCachedLoc(DatanodeInfo loc)
      Add a the location of a cached replica of the block.
      Parameters:
      loc - of datanode with the cached replica
    • getCachedLocations

      public DatanodeInfo[] getCachedLocations()
      Returns:
      Datanodes with a cached block replica
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isStriped

      public boolean isStriped()
    • getBlockType

      public BlockType getBlockType()