@InterfaceAudience.Private @Metrics(context="dfs") public class FSNamesystem extends Object implements Namesystem, FSClusterStats, FSNamesystemMBean, NameNodeMXBean
| Modifier and Type | Field and Description |
|---|---|
static org.apache.commons.logging.Log |
auditLog
Logger for audit events, noting successful FSNamesystem operations.
|
static org.apache.commons.logging.Log |
LOG |
| Modifier and Type | Method and Description |
|---|---|
void |
adjustSafeModeBlockTotals(int deltaSafe,
int deltaTotal)
Adjust the total number of blocks safe and expected during safe mode.
|
long |
allocateNewInodeId()
Allocate a new inode ID.
|
void |
checkOperation(NameNode.OperationCategory op) |
void |
checkSafeMode()
Check safe mode conditions.
|
void |
checkSuperuserPrivilege()
Check if the user has superuser privilege.
|
void |
decrementSafeBlockCount(Block b)
Decrement number of blocks that reached minimal replication.
|
int |
getBlockCapacity() |
BlockManager |
getBlockManager() |
String |
getBlockPoolId()
Gets the block pool id.
|
long |
getBlockPoolUsedSpace()
Get the total space used by the block pools of this namenode
|
long |
getBlocksTotal()
Get the total number of blocks in the system.
|
long |
getCapacityRemaining()
Free (unused) storage capacity
|
float |
getCapacityRemainingGB() |
long |
getCapacityTotal()
Total storage capacity
|
float |
getCapacityTotalGB() |
long |
getCapacityUsed()
Used storage capacity
|
float |
getCapacityUsedGB() |
long |
getCapacityUsedNonDFS() |
String |
getClusterId()
Gets the cluster id.
|
long |
getCorruptReplicaBlocks()
Returns number of blocks with corrupt replicas
|
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
|
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
|
int |
getDistinctVersionCount()
Get the number of distinct versions of live datanodes
|
Map<String,Integer> |
getDistinctVersions()
Get the number of live datanodes for each distinct versions
|
FSEditLog |
getEditLog() |
EditLogTailer |
getEditLogTailer() |
long |
getExcessBlocks() |
int |
getExpiredHeartbeats() |
long |
getFilesTotal()
Total number of files and directories
|
long |
getFree()
Gets total non-used raw bytes.
|
FSDirectory |
getFSDirectory() |
FSImage |
getFSImage() |
String |
getFSState()
The state of the file system: Safemode or Operational
|
String |
getHAState() |
String |
getJournalTransactionInfo()
Get information about the transaction ID, including the last applied
transaction ID and the most recent checkpoint's transaction ID
|
long |
getLastCheckpointTime() |
long |
getLastInodeId() |
long |
getLastWrittenTransactionId() |
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
|
long |
getMillisSinceLastLoadedEdits() |
long |
getMissingBlocksCount() |
String |
getNameDirStatuses()
Get status information about the directories storing image and edits logs
of the NN.
|
static Collection<URI> |
getNamespaceDirs(Configuration conf) |
static List<URI> |
getNamespaceEditsDirs(Configuration conf)
Return an ordered list of edits directories to write to.
|
static List<URI> |
getNamespaceEditsDirs(Configuration conf,
boolean includeShared) |
long |
getNonDfsUsedSpace()
Gets total used space by data nodes for non DFS purposes such as storing
temporary files on the local file system
|
long |
getNumberOfMissingBlocks()
Gets the total number of missing blocks on the cluster
|
int |
getNumDeadDataNodes()
Number of dead data nodes
|
int |
getNumLiveDataNodes()
Number of Live data nodes
|
int |
getNumSnapshots() |
int |
getNumSnapshottableDirs() |
int |
getNumStaleDataNodes()
Number of stale data nodes
|
int |
getPendingDataNodeMessageCount() |
long |
getPendingDeletionBlocks() |
long |
getPendingReplicationBlocks()
Blocks pending to be replicated
|
float |
getPercentBlockPoolUsed()
Get the total space used by the block pool as percentage of total capacity
|
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
|
long |
getPostponedMisreplicatedBlocks() |
static Collection<URI> |
getRequiredNamespaceEditsDirs(Configuration conf)
Get all edits dirs which are required.
|
RetryCache |
getRetryCache() |
String |
getSafemode()
Gets the safemode status
|
org.apache.hadoop.hdfs.server.namenode.FSNamesystem.SafeModeInfo |
getSafeModeInfoForTests() |
long |
getScheduledReplicationBlocks()
Blocks scheduled for replication
|
static List<URI> |
getSharedEditsDirs(Configuration conf)
Returns edit directories that are shared between primary and secondary.
|
SnapshotManager |
getSnapshotManager() |
SnapshottableDirectoryStatus[] |
getSnapshottableDirListing()
Get the list of snapshottable directories that are owned
by the current user.
|
String |
getSoftwareVersion()
Get the version of software running on the Namenode
|
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 |
getTransactionsSinceLastCheckpoint() |
long |
getTransactionsSinceLastLogRoll() |
long |
getUnderReplicatedBlocks()
Blocks under replicated
|
long |
getUsed()
Gets the used space by data nodes.
|
String |
getVersion()
Class representing Namenode information for JMX interfaces
|
boolean |
hasReadLock()
Check if the current thread holds read lock.
|
boolean |
hasReadOrWriteLock()
Check if the current thread holds read or write lock.
|
boolean |
hasWriteLock()
Check if the current thread holds write lock.
|
void |
incrementSafeBlockCount(int replication)
Increment number of blocks that reached minimal replication.
|
boolean |
isAuditEnabled() |
boolean |
isAvoidingStaleDataNodesForWrite()
Indicate whether or not the cluster is now avoiding
to use stale DataNodes for writing.
|
boolean |
isGenStampInFuture(Block block) |
boolean |
isInSafeMode()
Is the system in safe mode?
|
boolean |
isInStandbyState() |
boolean |
isInStartupSafeMode()
Is the system in startup safe mode, i.e.
|
boolean |
isPopulatingReplQueues()
Check if replication queues are to be populated
|
boolean |
isRunning()
Is this name system running?
|
boolean |
isUpgradeFinalized()
Checks if upgrade is finalized.
|
static FSNamesystem |
loadFromDisk(Configuration conf)
Instantiates an FSNamesystem loaded from the image and edits
directories specified in the passed Configuration.
|
void |
logExpireDelegationToken(DelegationTokenIdentifier id)
Log the cancellation of expired tokens to edit logs
|
void |
logUpdateMasterKey(DelegationKey key)
Log the updateMasterKey operation to edit logs
|
void |
processIncrementalBlockReport(DatanodeID nodeID,
String poolId,
ReceivedDeletedBlockInfo[] blockInfos) |
void |
readLock()
Acquire read lock.
|
void |
readUnlock()
Release read lock.
|
void |
resetLastInodeId(long newValue)
Set the last allocated inode id when fsimage or editlog is loaded.
|
void |
setBlockTotal()
Set the total number of blocks in the system.
|
void |
setNNResourceChecker(NameNodeResourceChecker nnResourceChecker) |
void |
verifyToken(DelegationTokenIdentifier identifier,
byte[] password)
Verifies that the given identifier and password are valid and match.
|
void |
writeLock()
Acquire write lock.
|
void |
writeLockInterruptibly()
Acquire write lock, unless interrupted while waiting
|
void |
writeUnlock()
Release write lock.
|
public static final org.apache.commons.logging.Log LOG
public static final org.apache.commons.logging.Log auditLog
key=value pairs to be written for the following properties:
ugi=<ugi in RPC>
ip=<remote IP>
cmd=<command>
src=<src path>
dst=<dst path (optional)>
perm=<permissions (optional)>
public boolean isAuditEnabled()
public void resetLastInodeId(long newValue)
throws IOException
IOExceptionpublic long getLastInodeId()
public long allocateNewInodeId()
public static FSNamesystem loadFromDisk(Configuration conf) throws IOException
conf - the Configuration which specifies the storage directories
from which to loadIOException - if loading failspublic RetryCache getRetryCache()
public void checkOperation(NameNode.OperationCategory op) throws StandbyException
checkOperation in interface NamesystemStandbyExceptionpublic static Collection<URI> getNamespaceDirs(Configuration conf)
public static Collection<URI> getRequiredNamespaceEditsDirs(Configuration conf)
conf - the HDFS configuration.public static List<URI> getNamespaceEditsDirs(Configuration conf) throws IOException
IOException - if multiple shared edits directories are configuredpublic static List<URI> getNamespaceEditsDirs(Configuration conf, boolean includeShared) throws IOException
IOExceptionpublic static List<URI> getSharedEditsDirs(Configuration conf)
conf - public void readLock()
RwLockpublic void readUnlock()
RwLockreadUnlock in interface RwLockpublic void writeLock()
RwLockpublic void writeLockInterruptibly()
throws InterruptedException
RwLockwriteLockInterruptibly in interface RwLockInterruptedExceptionpublic void writeUnlock()
RwLockwriteUnlock in interface RwLockpublic boolean hasWriteLock()
RwLockhasWriteLock in interface RwLockpublic boolean hasReadLock()
RwLockhasReadLock in interface RwLockpublic boolean hasReadOrWriteLock()
RwLockhasReadOrWriteLock in interface RwLockpublic boolean isRunning()
NamesystemisRunning in interface Namesystempublic boolean isInStandbyState()
isInStandbyState in interface Namesystempublic FSImage getFSImage()
public FSEditLog getEditLog()
@Metric(value={"MissingBlocks","Number of missing blocks"}) public long getMissingBlocksCount()
@Metric(value={"ExpiredHeartbeats","Number of expired heartbeats"}) public int getExpiredHeartbeats()
@Metric(value={"TransactionsSinceLastCheckpoint","Number of transactions since last checkpoint"}) public long getTransactionsSinceLastCheckpoint()
@Metric(value={"TransactionsSinceLastLogRoll","Number of transactions since last edit log roll"}) public long getTransactionsSinceLastLogRoll()
@Metric(value={"LastWrittenTransactionId","Transaction ID written to the edit log"}) public long getLastWrittenTransactionId()
@Metric(value={"LastCheckpointTime","Time in milliseconds since the epoch of the last checkpoint"}) public long getLastCheckpointTime()
@Metric(value={"CapacityTotal","Total raw capacity of data nodes in bytes"}) public long getCapacityTotal()
FSNamesystemMBeangetCapacityTotal in interface FSNamesystemMBean@Metric(value={"CapacityTotalGB","Total raw capacity of data nodes in GB"}) public float getCapacityTotalGB()
@Metric(value={"CapacityUsed","Total used capacity across all data nodes in bytes"}) public long getCapacityUsed()
FSNamesystemMBeangetCapacityUsed in interface FSNamesystemMBean@Metric(value={"CapacityUsedGB","Total used capacity across all data nodes in GB"}) public float getCapacityUsedGB()
@Metric(value={"CapacityRemaining","Remaining capacity in bytes"}) public long getCapacityRemaining()
FSNamesystemMBeangetCapacityRemaining in interface FSNamesystemMBean@Metric(value={"CapacityRemainingGB","Remaining capacity in GB"}) public float getCapacityRemainingGB()
@Metric(value={"CapacityUsedNonDFS","Total space used by data nodes for non DFS purposes in bytes"}) public long getCapacityUsedNonDFS()
@Metric public int getTotalLoad()
getTotalLoad in interface FSClusterStatsgetTotalLoad in interface FSNamesystemMBean@Metric(value={"SnapshottableDirectories","Number of snapshottable directories"}) public int getNumSnapshottableDirs()
public void checkSafeMode()
SafeModecheckSafeMode in interface SafeModepublic boolean isInSafeMode()
SafeModeisInSafeMode in interface SafeModepublic boolean isInStartupSafeMode()
SafeModeisInStartupSafeMode in interface SafeModepublic boolean isPopulatingReplQueues()
isPopulatingReplQueues in interface SafeModepublic void incrementSafeBlockCount(int replication)
SafeModeincrementSafeBlockCount in interface SafeModereplication - current replicationpublic void decrementSafeBlockCount(Block b)
SafeModedecrementSafeBlockCount in interface SafeModepublic void adjustSafeModeBlockTotals(int deltaSafe,
int deltaTotal)
adjustSafeModeBlockTotals in interface NamesystemdeltaSafe - the change in number of safe blocksdeltaTotal - the change i nnumber of total blocks expectedpublic void setBlockTotal()
@Metric public long getBlocksTotal()
getBlocksTotal in interface FSNamesystemMBeanpublic void processIncrementalBlockReport(DatanodeID nodeID, String poolId, ReceivedDeletedBlockInfo[] blockInfos) throws IOException
IOExceptionpublic void checkSuperuserPrivilege()
throws AccessControlException
NamesystemcheckSuperuserPrivilege in interface NamesystemAccessControlException@Metric public long getFilesTotal()
FSNamesystemMBeangetFilesTotal in interface FSNamesystemMBean@Metric public long getPendingReplicationBlocks()
FSNamesystemMBeangetPendingReplicationBlocks in interface FSNamesystemMBean@Metric public long getUnderReplicatedBlocks()
FSNamesystemMBeangetUnderReplicatedBlocks in interface FSNamesystemMBean@Metric(value={"CorruptBlocks","Number of blocks with corrupt replicas"}) public long getCorruptReplicaBlocks()
@Metric public long getScheduledReplicationBlocks()
FSNamesystemMBeangetScheduledReplicationBlocks in interface FSNamesystemMBean@Metric public long getPendingDeletionBlocks()
@Metric public long getExcessBlocks()
@Metric public long getPostponedMisreplicatedBlocks()
@Metric public int getPendingDataNodeMessageCount()
@Metric public long getMillisSinceLastLoadedEdits()
@Metric public int getBlockCapacity()
public String getFSState()
FSNamesystemMBeangetFSState in interface FSNamesystemMBeanpublic int getNumLiveDataNodes()
FSNamesystemMBeangetNumLiveDataNodes in interface FSNamesystemMBeanpublic int getNumDeadDataNodes()
FSNamesystemMBeangetNumDeadDataNodes in interface FSNamesystemMBean@Metric(value={"StaleDataNodes","Number of datanodes marked stale due to delayed heartbeat"}) public int getNumStaleDataNodes()
FSNamesystemMBeangetNumStaleDataNodes in interface FSNamesystemMBeanpublic void logUpdateMasterKey(DelegationKey key)
key - new delegation key.public void logExpireDelegationToken(DelegationTokenIdentifier id)
id - token identifier to cancelpublic String getVersion()
getVersion in interface NameNodeMXBeanpublic long getUsed()
NameNodeMXBeangetUsed in interface NameNodeMXBeanpublic long getFree()
NameNodeMXBeangetFree in interface NameNodeMXBeanpublic long getTotal()
NameNodeMXBeangetTotal in interface NameNodeMXBeanpublic String getSafemode()
NameNodeMXBeangetSafemode in interface NameNodeMXBeanpublic boolean isUpgradeFinalized()
NameNodeMXBeanisUpgradeFinalized in interface NameNodeMXBeanpublic long getNonDfsUsedSpace()
NameNodeMXBeangetNonDfsUsedSpace in interface NameNodeMXBeanpublic float getPercentUsed()
NameNodeMXBeangetPercentUsed in interface NameNodeMXBeanpublic long getBlockPoolUsedSpace()
NameNodeMXBeangetBlockPoolUsedSpace in interface NameNodeMXBeanpublic float getPercentBlockPoolUsed()
NameNodeMXBeangetPercentBlockPoolUsed in interface NameNodeMXBeanpublic float getPercentRemaining()
NameNodeMXBeangetPercentRemaining in interface NameNodeMXBeanpublic long getTotalBlocks()
NameNodeMXBeangetTotalBlocks in interface NameNodeMXBean@Metric public long getTotalFiles()
NameNodeMXBeangetTotalFiles in interface NameNodeMXBeanpublic long getNumberOfMissingBlocks()
NameNodeMXBeangetNumberOfMissingBlocks in interface NameNodeMXBeanpublic int getThreads()
NameNodeMXBeangetThreads in interface NameNodeMXBeanpublic String getLiveNodes()
getLiveNodes in interface NameNodeMXBeanpublic String getDeadNodes()
getDeadNodes in interface NameNodeMXBeanpublic String getDecomNodes()
getDecomNodes in interface NameNodeMXBeanpublic String getClusterId()
NameNodeMXBeangetClusterId in interface NameNodeMXBeanpublic String getBlockPoolId()
NameNodeMXBeangetBlockPoolId in interface NameNodeMXBeangetBlockPoolId in interface Namesystempublic String getNameDirStatuses()
NameNodeMXBeangetNameDirStatuses in interface NameNodeMXBeanpublic String getJournalTransactionInfo()
NameNodeMXBeangetJournalTransactionInfo in interface NameNodeMXBeanpublic BlockManager getBlockManager()
public FSDirectory getFSDirectory()
public int getDistinctVersionCount()
NameNodeMXBeangetDistinctVersionCount in interface NameNodeMXBeanpublic Map<String,Integer> getDistinctVersions()
NameNodeMXBeangetDistinctVersions in interface NameNodeMXBeanpublic String getSoftwareVersion()
NameNodeMXBeangetSoftwareVersion in interface NameNodeMXBeanpublic void verifyToken(DelegationTokenIdentifier identifier, byte[] password) throws SecretManager.InvalidToken
identifier - Token identifier.password - Password in the token.SecretManager.InvalidTokenpublic boolean isGenStampInFuture(Block block)
isGenStampInFuture in interface Namesystempublic EditLogTailer getEditLogTailer()
public org.apache.hadoop.hdfs.server.namenode.FSNamesystem.SafeModeInfo getSafeModeInfoForTests()
public void setNNResourceChecker(NameNodeResourceChecker nnResourceChecker)
public boolean isAvoidingStaleDataNodesForWrite()
FSClusterStatsisAvoidingStaleDataNodesForWrite in interface FSClusterStatspublic SnapshotManager getSnapshotManager()
public SnapshottableDirectoryStatus[] getSnapshottableDirListing() throws IOException
IOExceptionCopyright © 2013 Apache Software Foundation. All rights reserved.