Class FsVolumeSpi.ScanInfo

java.lang.Object
org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeSpi.ScanInfo
All Implemented Interfaces:
Comparable<FsVolumeSpi.ScanInfo>
Enclosing interface:
FsVolumeSpi

public static class FsVolumeSpi.ScanInfo extends Object implements Comparable<FsVolumeSpi.ScanInfo>
Tracks the files and other information related to a block on the disk Missing file is indicated by setting the corresponding member to null. Because millions of these structures may be created, we try to save memory here. So instead of storing full paths, we store path suffixes. The block file, if it exists, will have a path like this: <volume_base_path>/<block_path> So we don't need to store the volume path, since we already know what the volume is. The metadata file, if it exists, will have a path like this: <volume_base_path>/<block_path>_<genstamp>.meta So if we have a block file, there isn't any need to store the block path again. The accessor functions take care of these manipulations.
  • Constructor Details

    • ScanInfo

      public ScanInfo(long blockId, File basePath, String blockFile, String metaFile, FsVolumeSpi vol)
      Create a ScanInfo object for a block. This constructor will examine the block data and meta-data files.
      Parameters:
      blockId - the block ID
      basePath - The full path to the directory the block is stored in
      blockFile - The block filename, with no path
      metaFile - The meta filename, with no path. If blockFile is not null then the metaFile and blockFile should have the same prefix, with the meta file having a suffix like "_1234.meta". To save memory, if the blockFile is present we store only the meta file suffix in the object
      vol - the volume that contains the block
    • ScanInfo

      public ScanInfo(long blockId, FsVolumeSpi vol, FileRegion fileRegion, long length)
      Create a ScanInfo object for a block. This constructor will examine the block data and meta-data files.
      Parameters:
      blockId - the block ID
      vol - the volume that contains the block
      fileRegion - the file region (for provided blocks)
      length - the length of the block data
  • Method Details

    • getBlockFile

      public File getBlockFile()
      Returns the block data file.
      Returns:
      the block data file
    • getBlockLength

      public long getBlockLength()
      Return the length of the data block. The length returned is the length cached when this object was created.
      Returns:
      the length of the data block
    • getMetaFile

      public File getMetaFile()
      Returns the block meta data file or null if there isn't one.
      Returns:
      the block meta data file
    • getBlockId

      public long getBlockId()
      Returns the block ID.
      Returns:
      the block ID
    • getVolume

      public FsVolumeSpi getVolume()
      Returns the volume that contains the block that this object describes.
      Returns:
      the volume
    • compareTo

      public int compareTo(FsVolumeSpi.ScanInfo b)
      Specified by:
      compareTo in interface Comparable<FsVolumeSpi.ScanInfo>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getGenStamp

      public long getGenStamp()
    • getFileRegion

      public FileRegion getFileRegion()