Class FsVolumeSpi.ScanInfo
java.lang.Object
org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeSpi.ScanInfo
- All Implemented Interfaces:
Comparable<FsVolumeSpi.ScanInfo>
- Enclosing interface:
- FsVolumeSpi
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 Summary
ConstructorsConstructorDescriptionScanInfo(long blockId, File basePath, String blockFile, String metaFile, FsVolumeSpi vol) Create a ScanInfo object for a block.ScanInfo(long blockId, FsVolumeSpi vol, FileRegion fileRegion, long length) Create a ScanInfo object for a block. -
Method Summary
Modifier and TypeMethodDescriptionintbooleanReturns the block data file.longReturns the block ID.longReturn the length of the data block.longReturns the block meta data file or null if there isn't one.Returns the volume that contains the block that this object describes.inthashCode()
-
Constructor Details
-
ScanInfo
Create a ScanInfo object for a block. This constructor will examine the block data and meta-data files.- Parameters:
blockId- the block IDbasePath- The full path to the directory the block is stored inblockFile- The block filename, with no pathmetaFile- 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 objectvol- the volume that contains the block
-
ScanInfo
Create a ScanInfo object for a block. This constructor will examine the block data and meta-data files.- Parameters:
blockId- the block IDvol- the volume that contains the blockfileRegion- the file region (for provided blocks)length- the length of the block data
-
-
Method Details
-
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
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
Returns the volume that contains the block that this object describes.- Returns:
- the volume
-
compareTo
- Specified by:
compareToin interfaceComparable<FsVolumeSpi.ScanInfo>
-
equals
-
hashCode
public int hashCode() -
getGenStamp
public long getGenStamp() -
getFileRegion
-