public class FSDataset extends Object implements FSConstants, FSDatasetInterface
FSConstants.DatanodeReportType, FSConstants.SafeModeAction, FSConstants.UpgradeAction
FSDatasetInterface.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
IOException
protected File getMetaFile(Block b) throws IOException
IOException
public static File findMetaFile(File blockFile) throws IOException
IOException
public File findBlockFile(long blockId)
public Block getStoredBlock(long blkid) throws IOException
getStoredBlock
在接口中 FSDatasetInterface
IOException
public boolean metaFileExists(Block b) throws IOException
FSDatasetInterface
metaFileExists
在接口中 FSDatasetInterface
b
- - the blockIOException
public long getMetaDataLength(Block b) throws IOException
FSDatasetInterface
getMetaDataLength
在接口中 FSDatasetInterface
b
- - the block for which the metadata length is desiredIOException
public FSDatasetInterface.MetaDataInputStream getMetaDataInputStream(Block b) throws IOException
FSDatasetInterface
getMetaDataInputStream
在接口中 FSDatasetInterface
b
- - the blockIOException
public long getDfsUsed() throws IOException
getDfsUsed
在接口中 FSDatasetMBean
IOException
public boolean hasEnoughResource()
hasEnoughResource
在接口中 FSDatasetInterface
public long getCapacity() throws IOException
getCapacity
在接口中 FSDatasetMBean
IOException
public long getRemaining() throws IOException
getRemaining
在接口中 FSDatasetMBean
IOException
public long getLength(Block b) throws IOException
getLength
在接口中 FSDatasetInterface
IOException
public long getVisibleLength(Block b) throws IOException
FSDatasetInterface
getVisibleLength
在接口中 FSDatasetInterface
IOException
public void setVisibleLength(Block b, long length) throws IOException
FSDatasetInterface
setVisibleLength
在接口中 FSDatasetInterface
b
- 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
IOException
public BlockLocalPathInfo getBlockLocalPathInfo(Block block) throws IOException
FSDatasetInterface
BlockLocalPathInfo
for the given block.getBlockLocalPathInfo
在接口中 FSDatasetInterface
IOException
public InputStream getBlockInputStream(Block b) throws IOException
FSDatasetInterface
getBlockInputStream
在接口中 FSDatasetInterface
IOException
public InputStream getBlockInputStream(Block b, long seekOffset) throws IOException
FSDatasetInterface
getBlockInputStream
在接口中 FSDatasetInterface
IOException
public FSDatasetInterface.BlockInputStreams getTmpInputStreams(Block b, long blkOffset, long ckoff) throws IOException
getTmpInputStreams
在接口中 FSDatasetInterface
IOException
public boolean detachBlock(Block block, int numLinks) throws IOException
block
- BlocknumLinks
- Detach if the number of links exceed this valueIOException
public void updateBlock(Block oldblock, Block newblock) throws IOException
updateBlock
在接口中 FSDatasetInterface
IOException
public FSDatasetInterface.BlockWriteStreams writeToBlock(Block b, boolean isRecovery, boolean replicationRequest) throws IOException
writeToBlock
在接口中 FSDatasetInterface
isRecovery
- True if this is part of error recovery, otherwise falsereplicationRequest
- True if this is part of block replication requestIOException
public long getChannelPosition(Block b, FSDatasetInterface.BlockWriteStreams streams) throws IOException
getChannelPosition
在接口中 FSDatasetInterface
streams
- The stream to the data file and checksum fileIOException
public void setChannelPosition(Block b, FSDatasetInterface.BlockWriteStreams streams, long dataOffset, long ckOffset) throws IOException
setChannelPosition
在接口中 FSDatasetInterface
streams
- 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 setIOException
public void finalizeBlock(Block b) throws IOException
FSDatasetInterface
finalizeBlock
在接口中 FSDatasetInterface
IOException
public void finalizeBlockIfNeeded(Block b) throws IOException
FSDatasetInterface
finalizeBlockIfNeeded
在接口中 FSDatasetInterface
IOException
public void unfinalizeBlock(Block b) throws IOException
unfinalizeBlock
在接口中 FSDatasetInterface
IOException
public Block[] getBlocksBeingWrittenReport()
getBlocksBeingWrittenReport
在接口中 FSDatasetInterface
public void requestAsyncBlockReport()
FSDatasetInterface
requestAsyncBlockReport
在接口中 FSDatasetInterface
public boolean isAsyncBlockReportReady()
isAsyncBlockReportReady
在接口中 FSDatasetInterface
public Block[] retrieveAsyncBlockReport()
FSDatasetInterface
FSDatasetInterface.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
在接口中 FSDatasetInterface
public Block[] getBlockReport()
getBlockReport
在接口中 FSDatasetInterface
public boolean isValidBlock(Block b)
isValidBlock
在接口中 FSDatasetInterface
public void validateBlockMetadata(Block b) throws IOException
validateBlockMetadata
在接口中 FSDatasetInterface
b
- The block to be verified.IOException
public void invalidate(Block[] invalidBlks) throws IOException
invalidate
在接口中 FSDatasetInterface
invalidBlks
- - the blocks to be invalidatedIOException
public void checkDataDir() throws DiskChecker.DiskErrorException
checkDataDir
在接口中 FSDatasetInterface
DiskChecker.DiskErrorException
public String toString()
FSDatasetInterface
toString
在接口中 FSDatasetInterface
toString
在类中 Object
public void shutdown()
FSDatasetInterface
shutdown
在接口中 FSDatasetInterface
public String getStorageInfo()
FSDatasetMBean
getStorageInfo
在接口中 FSDatasetMBean
public BlockRecoveryInfo startBlockRecovery(long blockId) throws IOException
startBlockRecovery
在接口中 FSDatasetInterface
IOException
Copyright © 2009 The Apache Software Foundation