public class FSDataset extends Object implements FSConstants, FSDatasetInterface
FSConstants.DatanodeReportType, FSConstants.SafeModeAction, FSConstants.UpgradeActionFSDatasetInterface.BlockInputStreams, FSDatasetInterface.BlockWriteStreams, FSDatasetInterface.MetaDataInputStream| 限定符和类型 | 字段和说明 |
|---|---|
static String |
METADATA_EXTENSION |
static int |
METADATA_EXTENSION_LENGTH |
static short |
METADATA_VERSION |
BLOCKREPORT_INITIAL_DELAY, BLOCKREPORT_INTERVAL, BUFFER_SIZE, DEFAULT_BLOCK_SIZE, DEFAULT_DATA_SOCKET_SIZE, HEARTBEAT_INTERVAL, LAYOUT_VERSION, LEASE_HARDLIMIT_PERIOD, LEASE_RECOVER_PERIOD, LEASE_SOFTLIMIT_PERIOD, MAX_PATH_DEPTH, MAX_PATH_LENGTH, MIN_BLOCKS_FOR_WRITE, QUOTA_DONT_SET, QUOTA_RESET, SIZE_OF_INTEGER, SMALL_BUFFER_SIZE| 构造器和说明 |
|---|
FSDataset(DataStorage storage,
Configuration conf)
An FSDataset has a directory where it loads its data files.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
checkDataDir()
check if a data directory is healthy
if some volumes failed - make sure to remove all the blocks that belong
to these volumes
|
boolean |
detachBlock(Block block,
int numLinks)
Make a copy of the block if this block is linked to an existing
snapshot.
|
void |
finalizeBlock(Block b)
Finalizes the block previously opened for writing using writeToBlock.
|
void |
finalizeBlockIfNeeded(Block b)
Finalizes the block previously opened for writing using writeToBlock
if not already finalized
|
File |
findBlockFile(long blockId)
Return the block file for the given ID
|
static File |
findMetaFile(File blockFile)
Find the corresponding meta data file from a given block file
|
File |
getBlockFile(Block b)
Get File name for a given block.
|
InputStream |
getBlockInputStream(Block b)
Returns an input stream to read the contents of the specified block
|
InputStream |
getBlockInputStream(Block b,
long seekOffset)
Returns an input stream at specified offset of the specified block
|
BlockLocalPathInfo |
getBlockLocalPathInfo(Block block)
Get
BlockLocalPathInfo for the given block. |
Block[] |
getBlockReport()
Return a table of block data.
|
Block[] |
getBlocksBeingWrittenReport()
Return a table of blocks being written data
|
long |
getCapacity()
Return total capacity, used and unused
|
long |
getChannelPosition(Block b,
FSDatasetInterface.BlockWriteStreams streams)
Retrieves the offset in the block to which the
the next write will write data to.
|
long |
getDfsUsed()
Return the total space used by dfs datanode
|
File |
getFile(Block b)
Turn the block identifier into a filename.
|
long |
getLength(Block b)
Find the block's on-disk length
|
FSDatasetInterface.MetaDataInputStream |
getMetaDataInputStream(Block b)
Returns metaData of block b as an input stream (and its length)
|
long |
getMetaDataLength(Block b)
Returns the length of the metadata file of the specified block
|
protected File |
getMetaFile(Block b) |
long |
getRemaining()
Return how many bytes can still be stored in the FSDataset
|
String |
getStorageInfo()
Returns the storage id of the underlying storage
|
Block |
getStoredBlock(long blkid) |
FSDatasetInterface.BlockInputStreams |
getTmpInputStreams(Block b,
long blkOffset,
long ckoff)
Returns handles to the block file and its metadata file
|
long |
getVisibleLength(Block b)
Returns the specified block's visible length (has metadata for this)
|
boolean |
hasEnoughResource()
Return true - if there are still valid volumes on the DataNode.
|
void |
invalidate(Block[] invalidBlks)
We're informed that a block is no longer valid.
|
boolean |
isAsyncBlockReportReady() |
boolean |
isValidBlock(Block b)
Check whether the given block is a valid one.
|
boolean |
metaFileExists(Block b)
Does the meta file exist for this block?
|
void |
requestAsyncBlockReport()
Request that a block report be prepared.
|
Block[] |
retrieveAsyncBlockReport()
Retrieve an asynchronously prepared block report.
|
void |
setChannelPosition(Block b,
FSDatasetInterface.BlockWriteStreams streams,
long dataOffset,
long ckOffset)
Sets the offset in the block to which the
the next write will write data to.
|
void |
setVisibleLength(Block b,
long length)
update the specified blocks visible meta data.
|
void |
shutdown()
Shutdown the FSDataset
|
BlockRecoveryInfo |
startBlockRecovery(long blockId) |
String |
toString()
Stringifies the name of the storage
|
void |
unfinalizeBlock(Block b)
Remove the temporary block file (if any)
|
void |
updateBlock(Block oldblock,
Block newblock)
Update the block to the new generation stamp and length.
|
void |
validateBlockMetadata(Block b)
Validate that the contents in the Block matches
the file on disk.
|
FSDatasetInterface.BlockWriteStreams |
writeToBlock(Block b,
boolean isRecovery,
boolean replicationRequest)
Start writing to a block file
If isRecovery is true and the block pre-exists, then we kill all
volumeMap.put(b, v);
volumeMap.put(b, v);
other threads that might be writing to this block, and then reopen the file.
|
public static final int METADATA_EXTENSION_LENGTH
public static final short METADATA_VERSION
public FSDataset(DataStorage storage, Configuration conf) throws IOException
IOExceptionprotected File getMetaFile(Block b) throws IOException
IOExceptionpublic static File findMetaFile(File blockFile) throws IOException
IOExceptionpublic File findBlockFile(long blockId)
public Block getStoredBlock(long blkid) throws IOException
getStoredBlock 在接口中 FSDatasetInterfaceIOExceptionpublic boolean metaFileExists(Block b) throws IOException
FSDatasetInterfacemetaFileExists 在接口中 FSDatasetInterfaceb - - the blockIOExceptionpublic long getMetaDataLength(Block b) throws IOException
FSDatasetInterfacegetMetaDataLength 在接口中 FSDatasetInterfaceb - - the block for which the metadata length is desiredIOExceptionpublic FSDatasetInterface.MetaDataInputStream getMetaDataInputStream(Block b) throws IOException
FSDatasetInterfacegetMetaDataInputStream 在接口中 FSDatasetInterfaceb - - the blockIOExceptionpublic long getDfsUsed()
throws IOException
getDfsUsed 在接口中 FSDatasetMBeanIOExceptionpublic boolean hasEnoughResource()
hasEnoughResource 在接口中 FSDatasetInterfacepublic long getCapacity()
throws IOException
getCapacity 在接口中 FSDatasetMBeanIOExceptionpublic long getRemaining()
throws IOException
getRemaining 在接口中 FSDatasetMBeanIOExceptionpublic long getLength(Block b) throws IOException
getLength 在接口中 FSDatasetInterfaceIOExceptionpublic long getVisibleLength(Block b) throws IOException
FSDatasetInterfacegetVisibleLength 在接口中 FSDatasetInterfaceIOExceptionpublic void setVisibleLength(Block b, long length) throws IOException
FSDatasetInterfacesetVisibleLength 在接口中 FSDatasetInterfaceb - block to update the length forlength - value to set visible length toIOException - if the block is not in ongoingCreatespublic File getBlockFile(Block b) throws IOException
IOExceptionpublic BlockLocalPathInfo getBlockLocalPathInfo(Block block) throws IOException
FSDatasetInterfaceBlockLocalPathInfo for the given block.getBlockLocalPathInfo 在接口中 FSDatasetInterfaceIOExceptionpublic InputStream getBlockInputStream(Block b) throws IOException
FSDatasetInterfacegetBlockInputStream 在接口中 FSDatasetInterfaceIOExceptionpublic InputStream getBlockInputStream(Block b, long seekOffset) throws IOException
FSDatasetInterfacegetBlockInputStream 在接口中 FSDatasetInterfaceIOExceptionpublic FSDatasetInterface.BlockInputStreams getTmpInputStreams(Block b, long blkOffset, long ckoff) throws IOException
getTmpInputStreams 在接口中 FSDatasetInterfaceIOExceptionpublic boolean detachBlock(Block block, int numLinks) throws IOException
block - BlocknumLinks - Detach if the number of links exceed this valueIOExceptionpublic void updateBlock(Block oldblock, Block newblock) throws IOException
updateBlock 在接口中 FSDatasetInterfaceIOExceptionpublic FSDatasetInterface.BlockWriteStreams writeToBlock(Block b, boolean isRecovery, boolean replicationRequest) throws IOException
writeToBlock 在接口中 FSDatasetInterfaceisRecovery - True if this is part of error recovery, otherwise falsereplicationRequest - True if this is part of block replication requestIOExceptionpublic long getChannelPosition(Block b, FSDatasetInterface.BlockWriteStreams streams) throws IOException
getChannelPosition 在接口中 FSDatasetInterfacestreams - The stream to the data file and checksum fileIOExceptionpublic void setChannelPosition(Block b, FSDatasetInterface.BlockWriteStreams streams, long dataOffset, long ckOffset) throws IOException
setChannelPosition 在接口中 FSDatasetInterfacestreams - The stream for the data file and checksum filedataOffset - The position to which the file pointre for the data stream
should be setckOffset - The position to which the file pointre for the checksum stream
should be setIOExceptionpublic void finalizeBlock(Block b) throws IOException
FSDatasetInterfacefinalizeBlock 在接口中 FSDatasetInterfaceIOExceptionpublic void finalizeBlockIfNeeded(Block b) throws IOException
FSDatasetInterfacefinalizeBlockIfNeeded 在接口中 FSDatasetInterfaceIOExceptionpublic void unfinalizeBlock(Block b) throws IOException
unfinalizeBlock 在接口中 FSDatasetInterfaceIOExceptionpublic Block[] getBlocksBeingWrittenReport()
getBlocksBeingWrittenReport 在接口中 FSDatasetInterfacepublic void requestAsyncBlockReport()
FSDatasetInterfacerequestAsyncBlockReport 在接口中 FSDatasetInterfacepublic boolean isAsyncBlockReportReady()
isAsyncBlockReportReady 在接口中 FSDatasetInterfacepublic Block[] retrieveAsyncBlockReport()
FSDatasetInterfaceFSDatasetInterface.requestAsyncBlockReport(), and then poll
FSDatasetInterface.isAsyncBlockReportReady() until it returns true.
Retrieving the asynchronous block report also resets it; a new
one must be prepared before this method may be called again.retrieveAsyncBlockReport 在接口中 FSDatasetInterfacepublic Block[] getBlockReport()
getBlockReport 在接口中 FSDatasetInterfacepublic boolean isValidBlock(Block b)
isValidBlock 在接口中 FSDatasetInterfacepublic void validateBlockMetadata(Block b) throws IOException
validateBlockMetadata 在接口中 FSDatasetInterfaceb - The block to be verified.IOExceptionpublic void invalidate(Block[] invalidBlks) throws IOException
invalidate 在接口中 FSDatasetInterfaceinvalidBlks - - the blocks to be invalidatedIOExceptionpublic void checkDataDir()
throws DiskChecker.DiskErrorException
checkDataDir 在接口中 FSDatasetInterfaceDiskChecker.DiskErrorExceptionpublic String toString()
FSDatasetInterfacetoString 在接口中 FSDatasetInterfacetoString 在类中 Objectpublic void shutdown()
FSDatasetInterfaceshutdown 在接口中 FSDatasetInterfacepublic String getStorageInfo()
FSDatasetMBeangetStorageInfo 在接口中 FSDatasetMBeanpublic BlockRecoveryInfo startBlockRecovery(long blockId) throws IOException
startBlockRecovery 在接口中 FSDatasetInterfaceIOExceptionCopyright © 2009 The Apache Software Foundation