java.lang.Comparable<byte[]>, BlockCollection, INodeAttributes, INodeFileAttributes, Diff.Element<byte[]>, org.apache.hadoop.util.LightWeightGSet.LinkedElement@Private public class INodeFile extends INodeWithAdditionalFields implements INodeFileAttributes, BlockCollection
INode.BlocksMapUpdateInfo, INode.Feature, INode.QuotaDelta, INode.ReclaimContextINodeAttributes.SnapshotCopyINodeFileAttributes.SnapshotCopy| Modifier and Type | Field | Description |
|---|---|---|
static short |
DEFAULT_REPL_FOR_STRIPED_BLOCKS |
Erasure Coded striped blocks have replication factor of 1.
|
features| Modifier and Type | Method | Description |
|---|---|---|
void |
accept(NamespaceVisitor visitor,
int snapshot) |
Accept a visitor to visit this
INode. |
FileWithSnapshotFeature |
addSnapshotFeature(FileDiffList diffs) |
|
INodeFile |
asFile() |
Cast this inode to an
INodeFile. |
void |
cleanSubtree(INode.ReclaimContext reclaimContext,
int snapshot,
int priorSnapshotId) |
Clean the subtree under this inode and collect the blocks from the descents
for further block deletion/update.
|
void |
clearBlocks() |
Clear all blocks of the file.
|
void |
clearFile(INode.ReclaimContext reclaimContext) |
|
long |
collectBlocksBeyondMax(long max,
INode.BlocksMapUpdateInfo collectedBlocks,
java.util.Set<BlockInfo> toRetain) |
Remove full blocks at the end file up to newLength
|
void |
collectBlocksBeyondSnapshot(BlockInfo[] snapshotBlocks,
INode.BlocksMapUpdateInfo collectedBlocks) |
This function is only called when block list is stored in snapshot
diffs.
|
ContentSummaryComputationContext |
computeContentSummary(int snapshotId,
ContentSummaryComputationContext summary) |
Count subtree content summary with a
ContentCounts. |
long |
computeFileSize() |
The same as computeFileSize(null).
|
long |
computeFileSize(boolean includesLastUcBlock,
boolean usePreferredBlockSize4LastUcBlock) |
Compute file size of the current file.
|
long |
computeFileSize(int snapshotId) |
Compute file size of the current file if the given snapshot is null;
otherwise, get the file size from the given snapshot.
|
long |
computeFileSizeNotIncludingLastUcBlock() |
Compute file size of the current file size
but not including the last block if it is under construction.
|
QuotaCounts |
computeQuotaUsage(BlockStoragePolicySuite bsps,
byte blockStoragePolicyId,
boolean useCache,
int lastSnapshotId) |
Count subtree
Quota.NAMESPACE and Quota.STORAGESPACE usages. |
QuotaCounts |
computeQuotaUsageWithStriped(org.apache.hadoop.hdfs.protocol.BlockStoragePolicy bsp,
QuotaCounts counts) |
Compute quota of striped file.
|
void |
convertLastBlockToUC(BlockInfo lastBlock,
DatanodeStorageInfo[] locations) |
Convert the last block of the collection to an under-construction block
and set the locations.
|
void |
destroyAndCollectBlocks(INode.ReclaimContext reclaimContext) |
Destroy self and clear everything! If the INode is a file, this method
collects its blocks for further block deletion.
|
void |
dumpINodeFile(java.io.PrintWriter out,
java.lang.StringBuilder prefix,
int snapshotId) |
|
void |
dumpTreeRecursively(java.io.PrintWriter out,
java.lang.StringBuilder prefix,
int snapshotId) |
Dump tree recursively.
|
BlockInfo[] |
getBlocks() |
Get the blocks (striped or contiguous).
|
BlockInfo[] |
getBlocks(int snapshot) |
|
org.apache.hadoop.hdfs.protocol.BlockType |
getBlockType() |
|
FileDiffList |
getDiffs() |
|
byte |
getErasureCodingPolicyID() |
|
short |
getFileReplication() |
The same as getFileReplication(null).
|
short |
getFileReplication(int snapshot) |
|
FileUnderConstructionFeature |
getFileUnderConstructionFeature() |
If the inode contains a
FileUnderConstructionFeature, return it;
otherwise, return null. |
FileWithSnapshotFeature |
getFileWithSnapshotFeature() |
If feature list contains a
FileWithSnapshotFeature, return it;
otherwise, return null. |
long |
getHeaderLong() |
|
BlockInfo |
getLastBlock() |
Get the last block of the collection.
|
byte |
getLocalStoragePolicyID() |
|
java.lang.String |
getName() |
Get the name of the collection.
|
short |
getPreferredBlockReplication() |
Get block replication for the collection.
|
long |
getPreferredBlockSize() |
Get preferred block size for the collection
|
INodeFileAttributes |
getSnapshotINode(int snapshotId) |
|
byte |
getStoragePolicyID() |
|
boolean |
isFile() |
Check whether it's a file.
|
boolean |
isStriped() |
|
boolean |
isUnderConstruction() |
Is this file under construction?
|
boolean |
isWithSnapshot() |
Is this file has the snapshot feature?
|
INodeFile |
loadSnapshotFeature(FileDiffList diffs) |
Used by FSImage.
|
boolean |
metadataEquals(INodeFileAttributes other) |
|
int |
numBlocks() |
|
void |
recordModification(int latestSnapshotId) |
|
void |
recordModification(int latestSnapshotId,
boolean withBlocks) |
|
void |
setBlock(int index,
BlockInfo blk) |
Set the block (contiguous or striped) at the given index.
|
INodeFile |
setFileReplication(short replication,
int latestSnapshotId) |
Set the replication factor of this file.
|
void |
setStoragePolicyID(byte storagePolicyId,
int latestSnapshotId) |
|
QuotaCounts |
storagespaceConsumed(org.apache.hadoop.hdfs.protocol.BlockStoragePolicy bsp) |
Compute size consumed by all blocks of the current file,
including blocks in its snapshots.
|
QuotaCounts |
storagespaceConsumedContiguous(org.apache.hadoop.hdfs.protocol.BlockStoragePolicy bsp) |
|
QuotaCounts |
storagespaceConsumedStriped() |
|
java.lang.String |
toDetailString() |
|
static INodeFile |
valueOf(INode inode,
java.lang.String path) |
The same as valueOf(inode, path, false).
|
static INodeFile |
valueOf(INode inode,
java.lang.String path,
boolean acceptNull) |
Cast INode to INodeFile.
|
addAclFeature, addFeature, addXAttrFeature, getAclFeature, getFeature, getFeatures, getFsPermissionShort, getId, getLocalNameBytes, getNext, getPermissionLong, getPermissionStatus, removeAclFeature, removeFeature, removeXAttrFeature, setAccessTime, setLocalName, setModificationTime, setNext, updateModificationTimeaddSpaceConsumed, asDirectory, asReference, asSymlink, clear, compareTo, computeAndConvertContentSummary, computeContentSummary, computeQuotaUsage, computeQuotaUsage, dumpINode, dumpParentINodes, dumpTreeRecursively, dumpTreeRecursively, equals, getAccessTime, getAclFeature, getFsPermission, getFullPathAndObjectString, getFullPathName, getGroupName, getKey, getLocalName, getModificationTime, getObjectString, getParent, getParentReference, getParentString, getPathComponents, getPathComponents, getPathNames, getQuotaCounts, getStoragePolicyIDForQuota, getUserName, getXAttrFeature, hashCode, isAncestorDirectory, isDeleted, isDirectory, isInCurrentState, isInLatestSnapshot, isLastReference, isQuotaSet, isReference, isSetStoragePolicy, isSymlink, setAccessTime, setModificationTime, setParent, setParentReference, shouldRecordInSrcSnapshot, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitcomputeContentSummary, getIdgetAccessTime, getAclFeature, getFsPermission, getFsPermissionShort, getGroupName, getLocalNameBytes, getModificationTime, getPermissionLong, getUserName, getXAttrFeature, isDirectorypublic static final short DEFAULT_REPL_FOR_STRIPED_BLOCKS
public INodeFile(INodeFile that)
public static INodeFile valueOf(INode inode, java.lang.String path) throws java.io.FileNotFoundException
java.io.FileNotFoundExceptionpublic static INodeFile valueOf(INode inode, java.lang.String path, boolean acceptNull) throws java.io.FileNotFoundException
java.io.FileNotFoundExceptionpublic final boolean isFile()
INodepublic final INodeFile asFile()
INodeINodeFile.public boolean metadataEquals(INodeFileAttributes other)
metadataEquals in interface INodeFileAttributespublic final FileUnderConstructionFeature getFileUnderConstructionFeature()
FileUnderConstructionFeature, return it;
otherwise, return null.public boolean isUnderConstruction()
isUnderConstruction in interface BlockCollectionpublic void setBlock(int index,
BlockInfo blk)
BlockCollectionsetBlock in interface BlockCollectionpublic void convertLastBlockToUC(BlockInfo lastBlock, DatanodeStorageInfo[] locations) throws java.io.IOException
BlockCollectionconvertLastBlockToUC in interface BlockCollectionjava.io.IOExceptionpublic FileWithSnapshotFeature addSnapshotFeature(FileDiffList diffs)
public INodeFile loadSnapshotFeature(FileDiffList diffs)
public final FileWithSnapshotFeature getFileWithSnapshotFeature()
FileWithSnapshotFeature, return it;
otherwise, return null.public final boolean isWithSnapshot()
public java.lang.String toDetailString()
toDetailString in class INodepublic INodeFileAttributes getSnapshotINode(int snapshotId)
getSnapshotINode in class INodeSnapshot.CURRENT_STATE_ID,
return this; otherwise return the corresponding snapshot inode.public void recordModification(int latestSnapshotId)
public void recordModification(int latestSnapshotId,
boolean withBlocks)
public FileDiffList getDiffs()
public final short getFileReplication(int snapshot)
public final short getFileReplication()
getFileReplication in interface INodeFileAttributespublic short getPreferredBlockReplication()
BlockCollectiongetPreferredBlockReplication in interface BlockCollectionpublic final INodeFile setFileReplication(short replication, int latestSnapshotId) throws org.apache.hadoop.hdfs.protocol.QuotaExceededException
org.apache.hadoop.hdfs.protocol.QuotaExceededExceptionpublic long getPreferredBlockSize()
BlockCollectiongetPreferredBlockSize in interface BlockCollectiongetPreferredBlockSize in interface INodeFileAttributespublic byte getLocalStoragePolicyID()
getLocalStoragePolicyID in interface INodeFileAttributesgetLocalStoragePolicyID in class INodeHdfsConstants.BLOCK_STORAGE_POLICY_ID_UNSPECIFIED if no policy has
been specified.public byte getStoragePolicyID()
getStoragePolicyID in interface BlockCollectiongetStoragePolicyID in class INodepublic final void setStoragePolicyID(byte storagePolicyId,
int latestSnapshotId)
throws org.apache.hadoop.hdfs.protocol.QuotaExceededException
org.apache.hadoop.hdfs.protocol.QuotaExceededException@VisibleForTesting public byte getErasureCodingPolicyID()
getErasureCodingPolicyID in interface INodeFileAttributes@VisibleForTesting public boolean isStriped()
isStriped in interface BlockCollectionisStriped in interface INodeFileAttributes@VisibleForTesting public org.apache.hadoop.hdfs.protocol.BlockType getBlockType()
getBlockType in interface INodeFileAttributespublic long getHeaderLong()
getHeaderLong in interface INodeFileAttributespublic BlockInfo[] getBlocks()
BlockCollectiongetBlocks in interface BlockCollectionpublic BlockInfo[] getBlocks(int snapshot)
public void clearBlocks()
public void cleanSubtree(INode.ReclaimContext reclaimContext, int snapshot, int priorSnapshotId)
INodeIn general, we have the following rules. 1. When deleting a file/directory in the current tree, we have different actions according to the type of the node to delete. 1.1 The current inode (this) is anINodeFile. 1.1.1 Ifprioris null, there is no snapshot taken on ancestors before. Thus we simply destroy (i.e., to delete completely, no need to save snapshot copy) the current INode and collect its blocks for further cleansing. 1.1.2 Else do nothing since the current INode will be stored as a snapshot copy. 1.2 The current inode is anINodeDirectory. 1.2.1 Ifprioris null, there is no snapshot taken on ancestors before. Similarly, we destroy the whole subtree and collect blocks. 1.2.2 Else do nothing with the current INode. Recursively clean its children. 1.3 The current inode is a file with snapshot. Call recordModification(..) to capture the current states. Mark the INode as deleted. 1.4 The current inode is anINodeDirectorywith snapshot feature. Call recordModification(..) to capture the current states. Destroy files/directories created after the latest snapshot (i.e., the inodes stored in the created list of the latest snapshot). Recursively clean remaining children. 2. When deleting a snapshot. 2.1 To cleanINodeFile: do nothing. 2.2 To cleanINodeDirectory: recursively clean its children. 2.3 To clean INodeFile with snapshot: delete the corresponding snapshot in its diff list. 2.4 To cleanINodeDirectorywith snapshot: delete the corresponding snapshot in its diff list. Recursively clean its children.
cleanSubtree in class INodereclaimContext - Record blocks and inodes that need to be reclaimed.snapshot - The id of the snapshot to delete.
Snapshot.CURRENT_STATE_ID means to delete the current
file/directory.priorSnapshotId - The id of the latest snapshot before the to-be-deleted snapshot.
When deleting a current inode, this parameter captures the latest
snapshot.public void destroyAndCollectBlocks(INode.ReclaimContext reclaimContext)
INodedestroyAndCollectBlocks in class INodereclaimContext - Record blocks and inodes that need to be reclaimed.public void clearFile(INode.ReclaimContext reclaimContext)
public java.lang.String getName()
BlockCollectiongetName in interface BlockCollectionpublic final QuotaCounts computeQuotaUsage(BlockStoragePolicySuite bsps, byte blockStoragePolicyId, boolean useCache, int lastSnapshotId)
INodeQuota.NAMESPACE and Quota.STORAGESPACE usages.
With the existence of INodeReference, the same inode and its
subtree may be referred by multiple INodeReference.WithName nodes and a
INodeReference.DstReference node. To avoid circles while quota usage computation,
we have the following rules:
1. For aINodeReference.DstReferencenode, since the node must be in the current tree (or has been deleted as the end point of a series of rename operations), we compute the quota usage of the referred node (and its subtree) in the regular manner, i.e., including every inode in the current tree and in snapshot copies, as well as the size of diff list. 2. For aINodeReference.WithNamenode, since the node must be in a snapshot, we only count the quota usage for those nodes that still existed at the creation time of the snapshot associated with theINodeReference.WithNamenode. We do not count in the size of the diff list.
computeQuotaUsage in class INodebsps - Block storage policy suite to calculate intended storage type usageblockStoragePolicyId - block storage policy id of the current INodeuseCache - Whether to use cached quota usage. Note that
INodeReference.WithName node never uses cache for its subtree.lastSnapshotId - Snapshot.CURRENT_STATE_ID indicates the
computation is in the current tree. Otherwise the id
indicates the computation range for a
INodeReference.WithName node.public final QuotaCounts computeQuotaUsageWithStriped(org.apache.hadoop.hdfs.protocol.BlockStoragePolicy bsp, QuotaCounts counts)
public final ContentSummaryComputationContext computeContentSummary(int snapshotId, ContentSummaryComputationContext summary)
INodeContentCounts.computeContentSummary in class INodesnapshotId - Specify the time range for the calculation. If this
parameter equals to Snapshot.CURRENT_STATE_ID,
the result covers both the current states and all the
snapshots. Otherwise the result only covers all the
files/directories contained in the specific snapshot.summary - the context object holding counts for the subtree.public final long computeFileSize()
public final long computeFileSize(int snapshotId)
public final long computeFileSizeNotIncludingLastUcBlock()
public final long computeFileSize(boolean includesLastUcBlock,
boolean usePreferredBlockSize4LastUcBlock)
includesLastUcBlock - If the last block is under construction, should it be included?usePreferredBlockSize4LastUcBlock - If the last block is under construction, should we use actual
block size or preferred block size?
Note that usePreferredBlockSize4LastUcBlock is ignored
if includesLastUcBlock == false.public final QuotaCounts storagespaceConsumed(org.apache.hadoop.hdfs.protocol.BlockStoragePolicy bsp)
public final QuotaCounts storagespaceConsumedStriped()
public final QuotaCounts storagespaceConsumedContiguous(org.apache.hadoop.hdfs.protocol.BlockStoragePolicy bsp)
public BlockInfo getLastBlock()
BlockCollectiongetLastBlock in interface BlockCollectionpublic int numBlocks()
numBlocks in interface BlockCollection@VisibleForTesting
public void dumpTreeRecursively(java.io.PrintWriter out,
java.lang.StringBuilder prefix,
int snapshotId)
INodedumpTreeRecursively in class INodeprefix - The prefix string that each line should print.public void dumpINodeFile(java.io.PrintWriter out,
java.lang.StringBuilder prefix,
int snapshotId)
public void accept(NamespaceVisitor visitor, int snapshot)
INodeINode.public long collectBlocksBeyondMax(long max,
INode.BlocksMapUpdateInfo collectedBlocks,
java.util.Set<BlockInfo> toRetain)
public void collectBlocksBeyondSnapshot(BlockInfo[] snapshotBlocks, INode.BlocksMapUpdateInfo collectedBlocks)
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.