public class INodeDirectoryWithSnapshot extends INodeDirectoryWithQuota
Modifier and Type | Class and Description |
---|---|
static class |
INodeDirectoryWithSnapshot.DirectoryDiff
The difference of an
INodeDirectory between two snapshots. |
static class |
INodeDirectoryWithSnapshot.DirectoryDiffList
A list of directory diffs.
|
INodeDirectory.SnapshotAndINode
INode.BlocksMapUpdateInfo
INodeDirectoryAttributes.CopyWithQuota, INodeDirectoryAttributes.SnapshotCopy
DEFAULT_FILES_PER_DIRECTORY
Constructor and Description |
---|
INodeDirectoryWithSnapshot(INodeDirectory that) |
Modifier and Type | Method and Description |
---|---|
boolean |
addChild(INode inode,
boolean setModTime,
Snapshot latest,
INodeMap inodeMap)
Add a child inode to the directory.
|
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 . |
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.
|
static void |
destroyDstSubtree(INode inode,
Snapshot snapshot,
Snapshot prior,
INode.BlocksMapUpdateInfo collectedBlocks,
List<INode> removedINodes)
Destroy a subtree under a DstReference node.
|
INode |
getChild(byte[] name,
Snapshot snapshot) |
ReadOnlyList<INode> |
getChildrenList(Snapshot snapshot) |
INodeDirectoryWithSnapshot.DirectoryDiffList |
getDiffs() |
Snapshot |
getLastSnapshot() |
void |
getSnapshotDirectory(List<INodeDirectory> snapshotDir)
Get all the directories that are stored in some snapshot but not in the
current children list.
|
INodeDirectoryAttributes |
getSnapshotINode(Snapshot snapshot) |
INodeDirectoryWithSnapshot |
recordModification(Snapshot latest,
INodeMap inodeMap)
This inode is being modified.
|
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.
|
INode |
saveChild2Snapshot(INode child,
Snapshot latest,
INode snapshotCopy,
INodeMap inodeMap)
Save the child to the latest snapshot.
|
INodeDirectoryWithSnapshot |
saveSelf2Snapshot(Snapshot latest,
INodeDirectory snapshotCopy)
Save the snapshot copy to the latest snapshot.
|
String |
toDetailString() |
void |
undoRename4DstParent(INode deletedChild,
Snapshot latestSnapshot)
Undo the rename operation for the dst tree, i.e., if the rename operation
(with OVERWRITE option) removes a file/dir from the dst tree, add it back
and delete possible record in the deleted list.
|
void |
undoRename4ScrParent(INodeReference oldChild,
INode newChild,
Snapshot latestSnapshot)
This method is usually called by the undo section of rename.
|
addSpaceConsumed, addSpaceConsumed2Cache, getDiskspace, getDsQuota, getNamespace, getNsQuota, setQuota
addChild, asDirectory, cleanSubtreeRecursively, clear, clearChildren, dumpTreeRecursively, dumpTreeRecursively, getChildrenNum, isDirectory, isSnapshottable, metadataEquals, removeChild, replaceSelf4INodeDirectory, replaceSelf4INodeDirectorySnapshottable, replaceSelf4INodeDirectoryWithSnapshot, valueOf
getFsPermissionShort, getId, getLocalNameBytes, getNext, getPermissionLong, setAccessTime, setLocalName, setModificationTime, setNext, updateModificationTime
asFile, asReference, asSymlink, compareTo, computeContentSummary, computeQuotaUsage, computeQuotaUsage, dumpTreeRecursively, dumpTreeRecursively, equals, getAccessTime, getFsPermission, getFullPathName, getGroupName, getKey, getLocalName, getModificationTime, getObjectString, getParent, getParentReference, getParentString, getUserName, hashCode, isAncestorDirectory, isFile, isInLatestSnapshot, isQuotaSet, isReference, isSymlink, setAccessTime, setModificationTime, setParent, setParentReference, shouldRecordInSrcSnapshot, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getAccessTime, getFsPermission, getFsPermissionShort, getGroupName, getLocalNameBytes, getModificationTime, getPermissionLong, getUserName
public INodeDirectoryWithSnapshot(INodeDirectory that)
public Snapshot getLastSnapshot()
public INodeDirectoryWithSnapshot.DirectoryDiffList getDiffs()
public INodeDirectoryAttributes getSnapshotINode(Snapshot snapshot)
getSnapshotINode
in class INode
public INodeDirectoryWithSnapshot recordModification(Snapshot latest, INodeMap inodeMap) throws QuotaExceededException
INode
recordModification
in class INodeDirectory
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 INodeDirectoryWithSnapshot saveSelf2Snapshot(Snapshot latest, INodeDirectory snapshotCopy) throws QuotaExceededException
QuotaExceededException
public INode saveChild2Snapshot(INode child, Snapshot latest, INode snapshotCopy, INodeMap inodeMap) throws QuotaExceededException
INodeDirectory
saveChild2Snapshot
in class INodeDirectory
QuotaExceededException
public boolean addChild(INode inode, boolean setModTime, Snapshot latest, INodeMap inodeMap) throws QuotaExceededException
INodeDirectory
addChild
in class INodeDirectory
inode
- 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 removeChild(INode child, Snapshot latest, INodeMap inodeMap) throws QuotaExceededException
INodeDirectory
removeChild
in class INodeDirectory
child
- the child inode to be removedlatest
- See INode.recordModification(Snapshot, INodeMap)
.QuotaExceededException
public void replaceChild(INode oldChild, INode newChild, INodeMap inodeMap)
INodeDirectory
replaceChild
in class INodeDirectory
public void undoRename4ScrParent(INodeReference oldChild, INode newChild, Snapshot latestSnapshot) throws QuotaExceededException
1) remove the WithName node from the deleted list (if it exists) 2) replace the WithName node in the created list with srcChild 3) add srcChild back as a child of srcParent. Note that we already add the node into the created list of a snapshot diff in step 2, we do not need to add srcChild to the created list of the latest snapshot.We do not need to update quota usage because the old child is in the deleted list before.
oldChild
- The reference node to be removed/replacednewChild
- The node to be added backlatestSnapshot
- The latest snapshot. Note this may not be the last snapshot in the
diffs
, since the src tree of the current rename operation
may be the dst tree of a previous rename.QuotaExceededException
- should not throw this exceptionpublic void undoRename4DstParent(INode deletedChild, Snapshot latestSnapshot) throws QuotaExceededException
QuotaExceededException
public ReadOnlyList<INode> getChildrenList(Snapshot snapshot)
getChildrenList
in class INodeDirectory
snapshot
- if it is not null, get the result from the given snapshot;
otherwise, get the result from the current directory.public INode getChild(byte[] name, Snapshot snapshot)
getChild
in class INodeDirectory
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 String toDetailString()
toDetailString
in class INode
public void getSnapshotDirectory(List<INodeDirectory> snapshotDir)
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 INodeDirectory
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 INodeDirectory
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 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 INodeDirectoryWithQuota
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)
INodeDirectory
computeQuotaUsage4CurrentDirectory
in class INodeDirectory
public Content.Counts computeContentSummary(Content.Counts counts)
INode
Content.Counts
.computeContentSummary
in class INodeDirectoryWithQuota
counts
- The subtree counts for returning.public static void destroyDstSubtree(INode inode, Snapshot snapshot, Snapshot prior, INode.BlocksMapUpdateInfo collectedBlocks, List<INode> removedINodes) throws QuotaExceededException
QuotaExceededException
Copyright © 2013 Apache Software Foundation. All rights reserved.