@InterfaceAudience.Private public class INodeFile extends INodeWithAdditionalFields implements INodeFileAttributes, BlockCollection
INode.BlocksMapUpdateInfo
INodeFileAttributes.SnapshotCopy
Modifier and Type | Method and Description |
---|---|
INodeFile |
asFile()
Cast this inode to an
INodeFile . |
Quota.Counts |
cleanSubtree(Snapshot snapshot,
Snapshot prior,
INode.BlocksMapUpdateInfo collectedBlocks,
List<INode> removedINodes,
boolean countDiffChange)
Clean the subtree under this inode and collect the blocks from the descents
for further block deletion/update.
|
Content.Counts |
computeContentSummary(Content.Counts counts)
Count subtree content summary with a
Content.Counts . |
long |
computeFileSize()
The same as computeFileSize(null).
|
long |
computeFileSize(boolean includesLastUcBlock,
boolean usePreferredBlockSize4LastUcBlock)
Compute file size of the current file.
|
long |
computeFileSize(Snapshot snapshot)
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.
|
Quota.Counts |
computeQuotaUsage(Quota.Counts counts,
boolean useCache,
int lastSnapshotId)
Count subtree
Quota.NAMESPACE and Quota.DISKSPACE usages. |
void |
destroyAndCollectBlocks(INode.BlocksMapUpdateInfo collectedBlocks,
List<INode> removedINodes)
Destroy self and clear everything! If the INode is a file, this method
collects its blocks for further block deletion.
|
long |
diskspaceConsumed() |
long |
diskspaceConsumed(Snapshot lastSnapshot) |
void |
dumpTreeRecursively(PrintWriter out,
StringBuilder prefix,
Snapshot snapshot)
Dump tree recursively.
|
short |
getBlockReplication()
Get block replication for the collection
|
BlockInfo[] |
getBlocks()
Get the blocks.
|
short |
getFileReplication()
The same as getFileReplication(null).
|
short |
getFileReplication(Snapshot snapshot) |
long |
getHeaderLong() |
BlockInfo |
getLastBlock()
Get the last block of the collection.
|
String |
getName()
Get the name of the collection.
|
long |
getPreferredBlockSize()
Get preferred block size for the collection
|
INodeFileAttributes |
getSnapshotINode(Snapshot snapshot) |
boolean |
isFile()
Check whether it's a file.
|
boolean |
isUnderConstruction()
Is this file under construction?
|
int |
numBlocks() |
INodeFile |
recordModification(Snapshot latest,
INodeMap inodeMap)
This inode is being modified.
|
void |
setBlock(int idx,
BlockInfo blk)
Set the block of the file at the given index.
|
void |
setBlocks(BlockInfo[] blocks)
Set the blocks.
|
void |
setFileReplication(short replication)
Set the replication factor of this file.
|
INodeFile |
setFileReplication(short replication,
Snapshot latest,
INodeMap inodeMap)
Set the replication factor of this file.
|
INodeFileUnderConstruction |
toUnderConstruction(String clientName,
String clientMachine,
DatanodeDescriptor clientNode)
Convert this file to an
INodeFileUnderConstruction . |
static INodeFile |
valueOf(INode inode,
String path)
The same as valueOf(inode, path, false).
|
static INodeFile |
valueOf(INode inode,
String path,
boolean acceptNull)
Cast INode to INodeFile.
|
getFsPermissionShort, getId, getLocalNameBytes, getNext, getPermissionLong, setAccessTime, setLocalName, setModificationTime, setNext, updateModificationTime
addSpaceConsumed, asDirectory, asReference, asSymlink, clear, compareTo, computeContentSummary, computeQuotaUsage, computeQuotaUsage, dumpTreeRecursively, dumpTreeRecursively, equals, getAccessTime, getDsQuota, getFsPermission, getFullPathName, getGroupName, getKey, getLocalName, getModificationTime, getNsQuota, getObjectString, getParent, getParentReference, getParentString, getUserName, hashCode, isAncestorDirectory, isDirectory, isInLatestSnapshot, isQuotaSet, isReference, isSymlink, setAccessTime, setModificationTime, setParent, setParentReference, shouldRecordInSrcSnapshot, toDetailString, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getAccessTime, getFsPermission, getFsPermissionShort, getGroupName, getLocalNameBytes, getModificationTime, getPermissionLong, getUserName
computeContentSummary
public INodeFile(INodeFile that)
public static INodeFile valueOf(INode inode, String path) throws FileNotFoundException
FileNotFoundException
public static INodeFile valueOf(INode inode, String path, boolean acceptNull) throws FileNotFoundException
FileNotFoundException
public final boolean isFile()
INode
public final INodeFile asFile()
INode
INodeFile
.public boolean isUnderConstruction()
public INodeFileUnderConstruction toUnderConstruction(String clientName, String clientMachine, DatanodeDescriptor clientNode)
INodeFileUnderConstruction
.public INodeFileAttributes getSnapshotINode(Snapshot snapshot)
getSnapshotINode
in class INode
public INodeFile recordModification(Snapshot latest, INodeMap inodeMap) throws QuotaExceededException
INode
latest
- the latest snapshot that has been taken.
Note that it is null if no snapshots have been taken.inodeMap
- while recording modification, the inode or its parent may
get replaced, and the inodeMap needs to be updated.QuotaExceededException
public final short getFileReplication(Snapshot snapshot)
public final short getFileReplication()
getFileReplication
in interface INodeFileAttributes
public final short getBlockReplication()
BlockCollection
getBlockReplication
in interface BlockCollection
public final void setFileReplication(short replication)
public final INodeFile setFileReplication(short replication, Snapshot latest, INodeMap inodeMap) throws QuotaExceededException
QuotaExceededException
public long getPreferredBlockSize()
BlockCollection
getPreferredBlockSize
in interface BlockCollection
getPreferredBlockSize
in interface INodeFileAttributes
public long getHeaderLong()
getHeaderLong
in interface INodeFileAttributes
public BlockInfo[] getBlocks()
BlockCollection
getBlocks
in interface BlockCollection
public void setBlock(int idx, BlockInfo blk)
public void setBlocks(BlockInfo[] blocks)
public Quota.Counts cleanSubtree(Snapshot snapshot, Snapshot prior, INode.BlocksMapUpdateInfo collectedBlocks, List<INode> removedINodes, boolean countDiffChange) throws QuotaExceededException
INode
In 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 Ifprior
is 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 Ifprior
is 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 aFileWithSnapshot
. Call recordModification(..) to capture the current states. Mark the INode as deleted. 1.4 The current inode is aINodeDirectoryWithSnapshot
. 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 cleanFileWithSnapshot
: delete the corresponding snapshot in its diff list. 2.4 To cleanINodeDirectoryWithSnapshot
: delete the corresponding snapshot in its diff list. Recursively clean its children.
cleanSubtree
in class INode
snapshot
- The snapshot to delete. Null means to delete the current
file/directory.prior
- The latest snapshot before the to-be-deleted snapshot. When
deleting a current inode, this parameter captures the latest
snapshot.collectedBlocks
- blocks collected from the descents for further block
deletion/update will be added to the given map.removedINodes
- INodes collected from the descents for further cleaning up of
inodeMapQuotaExceededException
public void destroyAndCollectBlocks(INode.BlocksMapUpdateInfo collectedBlocks, List<INode> removedINodes)
INode
destroyAndCollectBlocks
in class INode
collectedBlocks
- blocks collected from the descents for further block
deletion/update will be added to this map.removedINodes
- INodes collected from the descents for further cleaning up of
inodeMappublic String getName()
BlockCollection
getName
in interface BlockCollection
public final Quota.Counts computeQuotaUsage(Quota.Counts counts, boolean useCache, int lastSnapshotId)
INode
Quota.NAMESPACE
and Quota.DISKSPACE
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.DstReference
node, 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.WithName
node, 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.WithName
node. We do not count in the size of the diff list.
computeQuotaUsage
in class INode
counts
- The subtree counts for returning.useCache
- Whether to use cached quota usage. Note that
INodeReference.WithName
node never uses cache for its subtree.lastSnapshotId
- Snapshot.INVALID_ID
indicates the computation
is in the current tree. Otherwise the id indicates
the computation range for a INodeReference.WithName
node.public final Content.Counts computeContentSummary(Content.Counts counts)
INode
Content.Counts
.computeContentSummary
in class INode
counts
- The subtree counts for returning.public final long computeFileSize()
public final long computeFileSize(Snapshot snapshot)
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 long diskspaceConsumed()
public final long diskspaceConsumed(Snapshot lastSnapshot)
public BlockInfo getLastBlock() throws IOException
BlockCollection
getLastBlock
in interface BlockCollection
IOException
public int numBlocks()
numBlocks
in interface BlockCollection
public void dumpTreeRecursively(PrintWriter out, StringBuilder prefix, Snapshot snapshot)
INode
dumpTreeRecursively
in class INode
prefix
- The prefix string that each line should print.Copyright © 2013 Apache Software Foundation. All rights reserved.