public class INodeDirectory extends INodeWithAdditionalFields implements INodeDirectoryAttributes
Modifier and Type | Class and Description |
---|---|
protected static class |
INodeDirectory.SnapshotAndINode
A pair of Snapshot and INode objects.
|
INode.BlocksMapUpdateInfo
INodeDirectoryAttributes.CopyWithQuota, INodeDirectoryAttributes.SnapshotCopy
Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_FILES_PER_DIRECTORY |
Constructor and Description |
---|
INodeDirectory(INodeDirectory other,
boolean adopt)
Copy constructor
|
INodeDirectory(long id,
byte[] name,
PermissionStatus permissions,
long mtime)
constructor
|
Modifier and Type | Method and Description |
---|---|
boolean |
addChild(INode node)
The same as addChild(node, false, null, false)
|
boolean |
addChild(INode node,
boolean setModTime,
Snapshot latest,
INodeMap inodeMap)
Add a child inode to the directory.
|
INodeDirectory |
asDirectory()
Cast this inode to an
INodeDirectory . |
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.
|
Quota.Counts |
cleanSubtreeRecursively(Snapshot snapshot,
Snapshot prior,
INode.BlocksMapUpdateInfo collectedBlocks,
List<INode> removedINodes,
Map<INode,INode> excludedNodes,
boolean countDiffChange)
Call cleanSubtree(..) recursively down the subtree.
|
void |
clear()
Clear references to other objects.
|
void |
clearChildren()
Set the children list to null.
|
Content.Counts |
computeContentSummary(Content.Counts counts)
Count subtree content summary with a
Content.Counts . |
Quota.Counts |
computeQuotaUsage(Quota.Counts counts,
boolean useCache,
int lastSnapshotId)
Count subtree
Quota.NAMESPACE and Quota.DISKSPACE usages. |
Quota.Counts |
computeQuotaUsage4CurrentDirectory(Quota.Counts counts)
Add quota usage for this inode excluding children.
|
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.
|
protected static void |
dumpTreeRecursively(PrintWriter out,
StringBuilder prefix,
Iterable<INodeDirectory.SnapshotAndINode> subs)
Dump the given subtrees.
|
void |
dumpTreeRecursively(PrintWriter out,
StringBuilder prefix,
Snapshot snapshot)
Dump tree recursively.
|
INode |
getChild(byte[] name,
Snapshot snapshot) |
ReadOnlyList<INode> |
getChildrenList(Snapshot snapshot) |
int |
getChildrenNum(Snapshot snapshot) |
boolean |
isDirectory()
Check whether it's a directory
|
boolean |
isSnapshottable()
Is this a snapshottable directory?
|
boolean |
metadataEquals(INodeDirectoryAttributes other)
Compare the metadata with another INodeDirectory
|
INodeDirectory |
recordModification(Snapshot latest,
INodeMap inodeMap)
This inode is being modified.
|
protected boolean |
removeChild(INode child)
Remove the specified child from this directory.
|
boolean |
removeChild(INode child,
Snapshot latest,
INodeMap inodeMap)
Remove the specified child from this directory.
|
void |
replaceChild(INode oldChild,
INode newChild,
INodeMap inodeMap)
Replace the given child with a new child.
|
INodeDirectory |
replaceSelf4INodeDirectory(INodeMap inodeMap)
Replace itself with
INodeDirectory . |
INodeDirectorySnapshottable |
replaceSelf4INodeDirectorySnapshottable(Snapshot latest,
INodeMap inodeMap)
Replace itself with an
INodeDirectorySnapshottable . |
INodeDirectoryWithSnapshot |
replaceSelf4INodeDirectoryWithSnapshot(INodeMap inodeMap)
Replace itself with an
INodeDirectoryWithSnapshot . |
INode |
saveChild2Snapshot(INode child,
Snapshot latest,
INode snapshotCopy,
INodeMap inodeMap)
Save the child to the latest snapshot.
|
static INodeDirectory |
valueOf(INode inode,
Object path)
Cast INode to INodeDirectory.
|
getFsPermissionShort, getId, getLocalNameBytes, getNext, getPermissionLong, setAccessTime, setLocalName, setModificationTime, setNext, updateModificationTime
addSpaceConsumed, asFile, asReference, asSymlink, compareTo, computeContentSummary, computeQuotaUsage, computeQuotaUsage, dumpTreeRecursively, dumpTreeRecursively, equals, getAccessTime, getDsQuota, getFsPermission, getFullPathName, getGroupName, getKey, getLocalName, getModificationTime, getNsQuota, getObjectString, getParent, getParentReference, getParentString, getSnapshotINode, getUserName, hashCode, isAncestorDirectory, isFile, isInLatestSnapshot, isQuotaSet, isReference, isSymlink, setAccessTime, setModificationTime, setParent, setParentReference, shouldRecordInSrcSnapshot, toDetailString, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getDsQuota, getNsQuota
getAccessTime, getFsPermission, getFsPermissionShort, getGroupName, getLocalNameBytes, getModificationTime, getPermissionLong, getUserName
protected static final int DEFAULT_FILES_PER_DIRECTORY
public INodeDirectory(long id, byte[] name, PermissionStatus permissions, long mtime)
public INodeDirectory(INodeDirectory other, boolean adopt)
other
- The INodeDirectory to be copiedadopt
- Indicate whether or not need to set the parent field of child
INodes to the new nodepublic static INodeDirectory valueOf(INode inode, Object path) throws FileNotFoundException, PathIsNotDirectoryException
public final boolean isDirectory()
INode
isDirectory
in class INode
public final INodeDirectory asDirectory()
INode
INodeDirectory
.asDirectory
in class INode
public boolean isSnapshottable()
public boolean removeChild(INode child, Snapshot latest, INodeMap inodeMap) throws QuotaExceededException
child
- the child inode to be removedlatest
- See INode.recordModification(Snapshot, INodeMap)
.QuotaExceededException
protected final boolean removeChild(INode child)
child
- the child inode to be removedpublic INodeDirectorySnapshottable replaceSelf4INodeDirectorySnapshottable(Snapshot latest, INodeMap inodeMap) throws QuotaExceededException
INodeDirectorySnapshottable
.QuotaExceededException
public INodeDirectoryWithSnapshot replaceSelf4INodeDirectoryWithSnapshot(INodeMap inodeMap)
INodeDirectoryWithSnapshot
.public INodeDirectory replaceSelf4INodeDirectory(INodeMap inodeMap)
INodeDirectory
.public void replaceChild(INode oldChild, INode newChild, INodeMap inodeMap)
public INodeDirectory 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 INode saveChild2Snapshot(INode child, Snapshot latest, INode snapshotCopy, INodeMap inodeMap) throws QuotaExceededException
QuotaExceededException
public INode getChild(byte[] name, Snapshot snapshot)
name
- the name of the childsnapshot
- if it is not null, get the result from the given snapshot;
otherwise, get the result from the current directory.public boolean addChild(INode node, boolean setModTime, Snapshot latest, INodeMap inodeMap) throws QuotaExceededException
node
- INode to insertsetModTime
- set modification time for the parent node
not needed when replaying the addition and
the parent already has the proper mod timeinodeMap
- update the inodeMap if the directory node gets replacedQuotaExceededException
public boolean addChild(INode node)
public 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 Quota.Counts computeQuotaUsage4CurrentDirectory(Quota.Counts counts)
public Content.Counts computeContentSummary(Content.Counts counts)
INode
Content.Counts
.computeContentSummary
in class INode
counts
- The subtree counts for returning.public ReadOnlyList<INode> getChildrenList(Snapshot snapshot)
snapshot
- if it is not null, get the result from the given snapshot;
otherwise, get the result from the current directory.public void clearChildren()
public void clear()
INode
public Quota.Counts cleanSubtreeRecursively(Snapshot snapshot, Snapshot prior, INode.BlocksMapUpdateInfo collectedBlocks, List<INode> removedINodes, Map<INode,INode> excludedNodes, boolean countDiffChange) throws QuotaExceededException
QuotaExceededException
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 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 boolean metadataEquals(INodeDirectoryAttributes other)
metadataEquals
in interface INodeDirectoryAttributes
public void dumpTreeRecursively(PrintWriter out, StringBuilder prefix, Snapshot snapshot)
INode
dumpTreeRecursively
in class INode
prefix
- The prefix string that each line should print.protected static void dumpTreeRecursively(PrintWriter out, StringBuilder prefix, Iterable<INodeDirectory.SnapshotAndINode> subs)
prefix
- The prefix string that each line should print.subs
- The subtrees.public final int getChildrenNum(Snapshot snapshot)
Copyright © 2013 Apache Software Foundation. All rights reserved.