public class FSNamesystem extends Object implements FSConstants, FSNamesystemMBean, FSClusterStats, NameNodeMXBean, MetricsSource
FSConstants.DatanodeReportType, FSConstants.SafeModeAction, FSConstants.UpgradeAction| 限定符和类型 | 字段和说明 |
|---|---|
static String |
AUDIT_FORMAT |
static org.apache.commons.logging.Log |
auditLog |
CorruptReplicasMap |
corruptReplicas |
static int |
DEFAULT_INITIAL_MAP_CAPACITY |
static float |
DEFAULT_MAP_LOAD_FACTOR |
org.apache.hadoop.hdfs.server.namenode.FSDirectory |
dir |
static FSNamesystem |
fsNamesystemObject |
LeaseManager |
leaseManager |
Daemon |
lmthread |
static org.apache.commons.logging.Log |
LOG |
Daemon |
replthread |
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| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
abandonBlock(Block b,
String src,
String holder)
The client would like to let go of the given block
|
void |
blockReceived(DatanodeID nodeID,
Block block,
String delHint)
The given node is reporting that it received a certain block.
|
void |
cancelDelegationToken(Token<DelegationTokenIdentifier> token) |
DatanodeInfo |
chooseDatanode(String srcPath,
String address,
long blocksize)
Choose a datanode near to the given address.
|
void |
close()
Close down this file system manager.
|
void |
commitBlockSynchronization(Block lastblock,
long newgenerationstamp,
long newlength,
boolean closeFile,
boolean deleteblock,
DatanodeID[] newtargets) |
org.apache.hadoop.hdfs.server.namenode.FSNamesystem.CompleteFileStatus |
completeFile(String src,
String holder) |
int |
computeDatanodeWork()
Compute block replication and block invalidation work
that can be scheduled on data-nodes.
|
DatanodeInfo[] |
datanodeReport(FSConstants.DatanodeReportType type) |
boolean |
delete(String src,
boolean recursive)
Remove the indicated filename from namespace.
|
void |
DFSNodesStatus(ArrayList<DatanodeDescriptor> live,
ArrayList<DatanodeDescriptor> dead) |
LocatedBlock |
getAdditionalBlock(String src,
String clientName)
Stub for old callers pre-HDFS-630
|
LocatedBlock |
getAdditionalBlock(String src,
String clientName,
HashMap<Node,Node> excludedNodes)
The client would like to obtain an additional block for the indicated
filename (which is being written-to).
|
int |
getBlockCapacity() |
LocatedBlocks |
getBlockLocations(String src,
long offset,
long length)
Get block locations within the specified range.
|
LocatedBlocks |
getBlockLocations(String src,
long offset,
long length,
boolean doAccessTime,
boolean needBlockToken,
boolean checkSafeMode)
Get block locations within the specified range.
|
long |
getBlocksTotal()
Get the total number of blocks in the system.
|
long |
getCapacityRemaining()
Total non-used raw bytes.
|
float |
getCapacityRemainingPercent()
Total remaining space by data nodes as percentage of total capacity
|
long |
getCapacityTotal()
Total raw bytes including non-dfs used space.
|
long |
getCapacityUsed()
Total used space by data nodes
|
long |
getCapacityUsedNonDFS()
Total used space by data nodes for non DFS purposes such
as storing temporary files on the local file system
|
float |
getCapacityUsedPercent()
Total used space by data nodes as percentage of total capacity
|
long |
getCorruptReplicaBlocks()
Returns number of blocks with corrupt replicas
|
DatanodeDescriptor |
getDatanode(DatanodeID nodeID)
Get data node by storage ID.
|
DatanodeInfo |
getDataNodeInfo(String name) |
ArrayList<DatanodeDescriptor> |
getDatanodeListForReport(FSConstants.DatanodeReportType type) |
String |
getDeadNodes()
Returned information is a JSON representation of map with host name as the
key and value is a map of dead node attribute keys to its values
|
ArrayList<DatanodeDescriptor> |
getDecommissioningNodes() |
String |
getDecomNodes()
Returned information is a JSON representation of map with host name as the
key and value is a map of decomisioning node attribute keys to its values
|
Token<DelegationTokenIdentifier> |
getDelegationToken(Text renewer) |
DelegationTokenSecretManager |
getDelegationTokenSecretManager()
Returns the DelegationTokenSecretManager instance in the namesystem.
|
InetSocketAddress |
getDFSNameNodeAddress()
已过时。
use
NameNode.getNameNodeAddress() instead. |
long |
getExcessBlocks() |
long |
getFilesTotal()
Total number of files and directories
|
long |
getFree()
Gets total non-used raw bytes.
|
static FSNamesystem |
getFSNamesystem()
Return the FSNamesystem object
|
String |
getFSState()
The state of the file system: Safemode or Operational
|
long |
getGenerationStamp()
Gets the generation stamp for this filesystem
|
String |
getHostName() |
DirectoryListing |
getListing(String src,
byte[] startAfter)
Get a partial listing of the indicated directory
|
String |
getLiveNodes()
Returned information is a JSON representation of map with host name as the
key and value is a map of live node attribute keys to its values
|
void |
getMetrics(MetricsBuilder builder,
boolean all)
Get metrics from the source
|
long |
getMissingBlocksCount() |
String |
getNameDirStatuses()
Get status information about the directories storing image and edits logs
of the NN.
|
static Collection<File> |
getNamespaceDirs(Configuration conf) |
static Collection<File> |
getNamespaceEditsDirs(Configuration conf) |
long |
getNonDfsUsedSpace()
Gets total used space by data nodes for non DFS purposes such as storing
temporary files on the local file system
|
int |
getNumStaleNodes() |
long |
getPendingDeletionBlocks() |
long |
getPendingReplicationBlocks()
Blocks pending to be replicated
|
float |
getPercentRemaining()
Gets the total remaining space by data nodes as percentage of total
capacity
|
float |
getPercentUsed()
Gets the total used space by data nodes as percentage of total capacity
|
DatanodeDescriptor |
getRandomDatanode() |
String |
getRegistrationID()
Get registrationID for datanodes based on the namespaceID.
|
String |
getSafemode()
Gets the safemode status
|
String |
getSafeModeTip() |
long |
getScheduledReplicationBlocks()
Blocks scheduled for replication
|
Date |
getStartTime() |
int |
getThreads()
Gets the number of threads.
|
long |
getTotal()
Gets total raw bytes including non-dfs used space.
|
long |
getTotalBlocks()
Gets the total numbers of blocks on the cluster.
|
long |
getTotalFiles()
Gets the total number of files on the cluster
|
int |
getTotalLoad()
Total number of connections.
|
long |
getUnderReplicatedBlocks()
Blocks under replicated
|
protected PermissionStatus |
getUpgradePermission()
Return the default path permission when upgrading from releases with no
permissions (<=0.15) to releases with permissions (>=0.16)
|
long |
getUsed()
Gets the used space by data nodes.
|
String |
getVersion()
Gets the version of Hadoop.
|
boolean |
isUpgradeFinalized()
Checks if upgrade is finalized.
|
void |
logUpdateMasterKey(DelegationKey key)
Log the updateMasterKey operation to edit logs
|
void |
markBlockAsCorrupt(Block blk,
DatanodeInfo dn)
Mark the block belonging to datanode as corrupt
|
boolean |
mkdirs(String src,
PermissionStatus permissions)
Create all the necessary directories
|
int |
numDeadDataNodes()
Number of dead data nodes
|
int |
numLiveDataNodes()
Number of live data nodes
|
void |
processBlocksBeingWrittenReport(DatanodeID nodeID,
BlockListAsLongs blocksBeingWritten)
It will update the targets for INodeFileUnderConstruction
|
void |
processReport(DatanodeID nodeID,
BlockListAsLongs newReport)
The given node is reporting all its blocks.
|
String |
randomDataNode()
已过时。
|
void |
refreshNodes(Configuration conf)
Rereads the config to get hosts and exclude list file names.
|
void |
registerDatanode(DatanodeRegistration nodeReg)
Register Datanode.
|
void |
removeDatanode(DatanodeID nodeID)
remove a datanode descriptor
|
boolean |
renameTo(String src,
String dst)
Change the indicated filename.
|
long |
renewDelegationToken(Token<DelegationTokenIdentifier> token) |
void |
restartReplicationWork() |
void |
setBalancerBandwidth(long bandwidth)
Tell all datanodes to use a new, non-persistent bandwidth value for
dfs.balance.bandwidthPerSec.
|
void |
setGenerationStamp(long stamp)
Sets the generation stamp for this filesystem
|
void |
setNodeReplicationLimit(int limit) |
void |
setOwner(String src,
String username,
String group)
Set owner for an existing file.
|
void |
setPermission(String src,
FsPermission permission)
Set permissions for an existing file.
|
boolean |
setReplication(String src,
short replication)
Set replication for an existing file.
|
void |
setTimes(String src,
long mtime,
long atime)
stores the modification and access time for this inode.
|
boolean |
shouldAvoidStaleDataNodesForWrite()
Indicate whether or not the cluster is now avoiding to use stale DataNodes
for writing.
|
void |
shutdown()
shutdown FSNamesystem
|
void |
stallReplicationWork() |
void |
stopDecommission(DatanodeDescriptor node)
Stop decommissioning the specified datanodes.
|
String |
toString() |
public static final org.apache.commons.logging.Log LOG
public static final org.apache.commons.logging.Log auditLog
public static final int DEFAULT_INITIAL_MAP_CAPACITY
public static final float DEFAULT_MAP_LOAD_FACTOR
public org.apache.hadoop.hdfs.server.namenode.FSDirectory dir
public CorruptReplicasMap corruptReplicas
public LeaseManager leaseManager
public Daemon lmthread
public Daemon replthread
public static FSNamesystem fsNamesystemObject
public static Collection<File> getNamespaceDirs(Configuration conf)
public static Collection<File> getNamespaceEditsDirs(Configuration conf)
protected PermissionStatus getUpgradePermission()
public static FSNamesystem getFSNamesystem()
public void close()
public void setBalancerBandwidth(long bandwidth)
throws IOException
bandwidth - Blanacer bandwidth in bytes per second for all datanodes.IOExceptionpublic void setPermission(String src, FsPermission permission) throws IOException
IOExceptionpublic void setOwner(String src, String username, String group) throws IOException
IOExceptionpublic LocatedBlocks getBlockLocations(String src, long offset, long length) throws IOException
public LocatedBlocks getBlockLocations(String src, long offset, long length, boolean doAccessTime, boolean needBlockToken, boolean checkSafeMode) throws IOException
public void setTimes(String src, long mtime, long atime) throws IOException
IOExceptionpublic boolean setReplication(String src, short replication) throws IOException
src - file namereplication - new replicationIOExceptionClientProtocol.setReplication(String, short)public LocatedBlock getAdditionalBlock(String src, String clientName) throws IOException
IOExceptionpublic LocatedBlock getAdditionalBlock(String src, String clientName, HashMap<Node,Node> excludedNodes) throws IOException
IOExceptionpublic boolean abandonBlock(Block b, String src, String holder) throws IOException
IOExceptionpublic org.apache.hadoop.hdfs.server.namenode.FSNamesystem.CompleteFileStatus completeFile(String src, String holder) throws IOException
IOExceptionpublic void markBlockAsCorrupt(Block blk, DatanodeInfo dn) throws IOException
blk - Block to be marked as corruptdn - Datanode which holds the corrupt replicaIOExceptionpublic boolean renameTo(String src, String dst) throws IOException
IOExceptionpublic boolean delete(String src, boolean recursive) throws IOException
IOExceptionpublic boolean mkdirs(String src, PermissionStatus permissions) throws IOException
IOExceptionpublic void commitBlockSynchronization(Block lastblock, long newgenerationstamp, long newlength, boolean closeFile, boolean deleteblock, DatanodeID[] newtargets) throws IOException
IOExceptionpublic DirectoryListing getListing(String src, byte[] startAfter) throws IOException
src - the directory namestartAfter - the name to start afterIOExceptionpublic void registerDatanode(DatanodeRegistration nodeReg) throws IOException
The purpose of registration is to identify whether the new datanode serves a new data storage, and will report new data block copies, which the namenode was not aware of; or the datanode is a replacement node for the data storage that was previously served by a different or the same (in terms of host:port) datanode. The data storages are distinguished by their storageIDs. When a new data storage is reported the namenode issues a new unique storageID.
Finally, the namenode returns its namespaceID as the registrationID for the datanodes. namespaceID is a persistent attribute of the name space. The registrationID is checked every time the datanode is communicating with the namenode. Datanodes with inappropriate registrationID are rejected. If the namenode stops, and then restarts it can restore its namespaceID and will continue serving the datanodes that has previously registered with the namenode without restarting the whole cluster.
IOExceptionDataNode.register()public String getRegistrationID()
registerDatanode(DatanodeRegistration),
FSImage.newNamespaceID()public int computeDatanodeWork()
throws IOException
IOExceptionpublic DatanodeInfo chooseDatanode(String srcPath, String address, long blocksize)
public void setNodeReplicationLimit(int limit)
public void removeDatanode(DatanodeID nodeID) throws IOException
nodeID - datanode IDIOExceptionpublic void processBlocksBeingWrittenReport(DatanodeID nodeID, BlockListAsLongs blocksBeingWritten) throws IOException
nodeID - - DataNode IDblocksBeingWritten - - list of blocks which are still inprogress.IOExceptionpublic void processReport(DatanodeID nodeID, BlockListAsLongs newReport) throws IOException
IOExceptionpublic void blockReceived(DatanodeID nodeID, Block block, String delHint) throws IOException
IOExceptionpublic long getMissingBlocksCount()
public long getCapacityTotal()
getCapacityTotal 在接口中 FSNamesystemMBeanpublic long getCapacityUsed()
getCapacityUsed 在接口中 FSNamesystemMBeanpublic float getCapacityUsedPercent()
public long getCapacityUsedNonDFS()
public long getCapacityRemaining()
getCapacityRemaining 在接口中 FSNamesystemMBeanpublic float getCapacityRemainingPercent()
public int getTotalLoad()
getTotalLoad 在接口中 FSClusterStatsgetTotalLoad 在接口中 FSNamesystemMBeanpublic ArrayList<DatanodeDescriptor> getDatanodeListForReport(FSConstants.DatanodeReportType type)
public DatanodeInfo[] datanodeReport(FSConstants.DatanodeReportType type) throws AccessControlException
public void DFSNodesStatus(ArrayList<DatanodeDescriptor> live, ArrayList<DatanodeDescriptor> dead)
public void stopDecommission(DatanodeDescriptor node) throws IOException
IOExceptionpublic DatanodeInfo getDataNodeInfo(String name)
@Deprecated public InetSocketAddress getDFSNameNodeAddress()
NameNode.getNameNodeAddress() instead.public Date getStartTime()
public void stallReplicationWork()
public void restartReplicationWork()
public void refreshNodes(Configuration conf) throws IOException
IOExceptionpublic DatanodeDescriptor getDatanode(DatanodeID nodeID) throws IOException
nodeID - IOException@Deprecated public String randomDataNode()
public DatanodeDescriptor getRandomDatanode()
public long getBlocksTotal()
getBlocksTotal 在接口中 FSNamesystemMBeanpublic String getSafeModeTip()
public long getFilesTotal()
FSNamesystemMBeangetFilesTotal 在接口中 FSNamesystemMBeanpublic long getPendingReplicationBlocks()
FSNamesystemMBeangetPendingReplicationBlocks 在接口中 FSNamesystemMBeanpublic long getUnderReplicatedBlocks()
FSNamesystemMBeangetUnderReplicatedBlocks 在接口中 FSNamesystemMBeanpublic long getCorruptReplicaBlocks()
public long getScheduledReplicationBlocks()
FSNamesystemMBeangetScheduledReplicationBlocks 在接口中 FSNamesystemMBeanpublic long getPendingDeletionBlocks()
public long getExcessBlocks()
public int getBlockCapacity()
public String getFSState()
FSNamesystemMBeangetFSState 在接口中 FSNamesystemMBeanpublic void shutdown()
public int numLiveDataNodes()
numLiveDataNodes 在接口中 FSNamesystemMBeanpublic int numDeadDataNodes()
numDeadDataNodes 在接口中 FSNamesystemMBeanpublic void setGenerationStamp(long stamp)
public long getGenerationStamp()
public ArrayList<DatanodeDescriptor> getDecommissioningNodes()
public DelegationTokenSecretManager getDelegationTokenSecretManager()
public Token<DelegationTokenIdentifier> getDelegationToken(Text renewer) throws IOException
renewer - IOExceptionpublic long renewDelegationToken(Token<DelegationTokenIdentifier> token) throws SecretManager.InvalidToken, IOException
token - SecretManager.InvalidTokenIOExceptionpublic void cancelDelegationToken(Token<DelegationTokenIdentifier> token) throws IOException
token - IOExceptionpublic void logUpdateMasterKey(DelegationKey key) throws IOException
key - new delegation key.IOExceptionpublic String getHostName()
getHostName 在接口中 NameNodeMXBeanpublic String getVersion()
NameNodeMXBeangetVersion 在接口中 NameNodeMXBeanpublic long getUsed()
NameNodeMXBeangetUsed 在接口中 NameNodeMXBeanpublic long getFree()
NameNodeMXBeangetFree 在接口中 NameNodeMXBeanpublic long getTotal()
NameNodeMXBeangetTotal 在接口中 NameNodeMXBeanpublic String getSafemode()
NameNodeMXBeangetSafemode 在接口中 NameNodeMXBeanpublic boolean isUpgradeFinalized()
NameNodeMXBeanisUpgradeFinalized 在接口中 NameNodeMXBeanpublic long getNonDfsUsedSpace()
NameNodeMXBeangetNonDfsUsedSpace 在接口中 NameNodeMXBeanpublic float getPercentUsed()
NameNodeMXBeangetPercentUsed 在接口中 NameNodeMXBeanpublic float getPercentRemaining()
NameNodeMXBeangetPercentRemaining 在接口中 NameNodeMXBeanpublic long getTotalBlocks()
NameNodeMXBeangetTotalBlocks 在接口中 NameNodeMXBeanpublic long getTotalFiles()
NameNodeMXBeangetTotalFiles 在接口中 NameNodeMXBeanpublic int getThreads()
NameNodeMXBeangetThreads 在接口中 NameNodeMXBeanpublic String getLiveNodes()
getLiveNodes 在接口中 NameNodeMXBeanpublic String getDeadNodes()
getDeadNodes 在接口中 NameNodeMXBeanpublic String getDecomNodes()
getDecomNodes 在接口中 NameNodeMXBeanpublic String getNameDirStatuses()
NameNodeMXBeangetNameDirStatuses 在接口中 NameNodeMXBeanpublic void getMetrics(MetricsBuilder builder, boolean all)
MetricsSourcegetMetrics 在接口中 MetricsSourcebuilder - to contain the resulting metrics snapshotall - if true, return all metrics even if unchanged.public int getNumStaleNodes()
public boolean shouldAvoidStaleDataNodesForWrite()
FSClusterStatsshouldAvoidStaleDataNodesForWrite 在接口中 FSClusterStatsCopyright © 2009 The Apache Software Foundation