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.IOException
public void setPermission(String src, FsPermission permission) throws IOException
IOException
public void setOwner(String src, String username, String group) throws IOException
IOException
public 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
IOException
public boolean setReplication(String src, short replication) throws IOException
src
- file namereplication
- new replicationIOException
ClientProtocol.setReplication(String, short)
public LocatedBlock getAdditionalBlock(String src, String clientName) throws IOException
IOException
public LocatedBlock getAdditionalBlock(String src, String clientName, HashMap<Node,Node> excludedNodes) throws IOException
IOException
public boolean abandonBlock(Block b, String src, String holder) throws IOException
IOException
public org.apache.hadoop.hdfs.server.namenode.FSNamesystem.CompleteFileStatus completeFile(String src, String holder) throws IOException
IOException
public void markBlockAsCorrupt(Block blk, DatanodeInfo dn) throws IOException
blk
- Block to be marked as corruptdn
- Datanode which holds the corrupt replicaIOException
public boolean renameTo(String src, String dst) throws IOException
IOException
public boolean delete(String src, boolean recursive) throws IOException
IOException
public boolean mkdirs(String src, PermissionStatus permissions) throws IOException
IOException
public void commitBlockSynchronization(Block lastblock, long newgenerationstamp, long newlength, boolean closeFile, boolean deleteblock, DatanodeID[] newtargets) throws IOException
IOException
public DirectoryListing getListing(String src, byte[] startAfter) throws IOException
src
- the directory namestartAfter
- the name to start afterIOException
public 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.
IOException
DataNode.register()
public String getRegistrationID()
registerDatanode(DatanodeRegistration)
,
FSImage.newNamespaceID()
public int computeDatanodeWork() throws IOException
IOException
public DatanodeInfo chooseDatanode(String srcPath, String address, long blocksize)
public void setNodeReplicationLimit(int limit)
public void removeDatanode(DatanodeID nodeID) throws IOException
nodeID
- datanode IDIOException
public void processBlocksBeingWrittenReport(DatanodeID nodeID, BlockListAsLongs blocksBeingWritten) throws IOException
nodeID
- - DataNode IDblocksBeingWritten
- - list of blocks which are still inprogress.IOException
public void processReport(DatanodeID nodeID, BlockListAsLongs newReport) throws IOException
IOException
public void blockReceived(DatanodeID nodeID, Block block, String delHint) throws IOException
IOException
public long getMissingBlocksCount()
public long getCapacityTotal()
getCapacityTotal
在接口中 FSNamesystemMBean
public long getCapacityUsed()
getCapacityUsed
在接口中 FSNamesystemMBean
public float getCapacityUsedPercent()
public long getCapacityUsedNonDFS()
public long getCapacityRemaining()
getCapacityRemaining
在接口中 FSNamesystemMBean
public float getCapacityRemainingPercent()
public int getTotalLoad()
getTotalLoad
在接口中 FSClusterStats
getTotalLoad
在接口中 FSNamesystemMBean
public 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
IOException
public 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
IOException
public DatanodeDescriptor getDatanode(DatanodeID nodeID) throws IOException
nodeID
- IOException
@Deprecated public String randomDataNode()
public DatanodeDescriptor getRandomDatanode()
public long getBlocksTotal()
getBlocksTotal
在接口中 FSNamesystemMBean
public String getSafeModeTip()
public long getFilesTotal()
FSNamesystemMBean
getFilesTotal
在接口中 FSNamesystemMBean
public long getPendingReplicationBlocks()
FSNamesystemMBean
getPendingReplicationBlocks
在接口中 FSNamesystemMBean
public long getUnderReplicatedBlocks()
FSNamesystemMBean
getUnderReplicatedBlocks
在接口中 FSNamesystemMBean
public long getCorruptReplicaBlocks()
public long getScheduledReplicationBlocks()
FSNamesystemMBean
getScheduledReplicationBlocks
在接口中 FSNamesystemMBean
public long getPendingDeletionBlocks()
public long getExcessBlocks()
public int getBlockCapacity()
public String getFSState()
FSNamesystemMBean
getFSState
在接口中 FSNamesystemMBean
public void shutdown()
public int numLiveDataNodes()
numLiveDataNodes
在接口中 FSNamesystemMBean
public int numDeadDataNodes()
numDeadDataNodes
在接口中 FSNamesystemMBean
public void setGenerationStamp(long stamp)
public long getGenerationStamp()
public ArrayList<DatanodeDescriptor> getDecommissioningNodes()
public DelegationTokenSecretManager getDelegationTokenSecretManager()
public Token<DelegationTokenIdentifier> getDelegationToken(Text renewer) throws IOException
renewer
- IOException
public long renewDelegationToken(Token<DelegationTokenIdentifier> token) throws SecretManager.InvalidToken, IOException
token
- SecretManager.InvalidToken
IOException
public void cancelDelegationToken(Token<DelegationTokenIdentifier> token) throws IOException
token
- IOException
public void logUpdateMasterKey(DelegationKey key) throws IOException
key
- new delegation key.IOException
public String getHostName()
getHostName
在接口中 NameNodeMXBean
public String getVersion()
NameNodeMXBean
getVersion
在接口中 NameNodeMXBean
public long getUsed()
NameNodeMXBean
getUsed
在接口中 NameNodeMXBean
public long getFree()
NameNodeMXBean
getFree
在接口中 NameNodeMXBean
public long getTotal()
NameNodeMXBean
getTotal
在接口中 NameNodeMXBean
public String getSafemode()
NameNodeMXBean
getSafemode
在接口中 NameNodeMXBean
public boolean isUpgradeFinalized()
NameNodeMXBean
isUpgradeFinalized
在接口中 NameNodeMXBean
public long getNonDfsUsedSpace()
NameNodeMXBean
getNonDfsUsedSpace
在接口中 NameNodeMXBean
public float getPercentUsed()
NameNodeMXBean
getPercentUsed
在接口中 NameNodeMXBean
public float getPercentRemaining()
NameNodeMXBean
getPercentRemaining
在接口中 NameNodeMXBean
public long getTotalBlocks()
NameNodeMXBean
getTotalBlocks
在接口中 NameNodeMXBean
public long getTotalFiles()
NameNodeMXBean
getTotalFiles
在接口中 NameNodeMXBean
public int getThreads()
NameNodeMXBean
getThreads
在接口中 NameNodeMXBean
public String getLiveNodes()
getLiveNodes
在接口中 NameNodeMXBean
public String getDeadNodes()
getDeadNodes
在接口中 NameNodeMXBean
public String getDecomNodes()
getDecomNodes
在接口中 NameNodeMXBean
public String getNameDirStatuses()
NameNodeMXBean
getNameDirStatuses
在接口中 NameNodeMXBean
public void getMetrics(MetricsBuilder builder, boolean all)
MetricsSource
getMetrics
在接口中 MetricsSource
builder
- to contain the resulting metrics snapshotall
- if true, return all metrics even if unchanged.public int getNumStaleNodes()
public boolean shouldAvoidStaleDataNodesForWrite()
FSClusterStats
shouldAvoidStaleDataNodesForWrite
在接口中 FSClusterStats
Copyright © 2009 The Apache Software Foundation