org.apache.hadoop.hdfs.server.namenode
Class INodeDirectory

java.lang.Object
  extended by org.apache.hadoop.hdfs.server.namenode.INode
      extended by org.apache.hadoop.hdfs.server.namenode.INodeWithAdditionalFields
          extended by org.apache.hadoop.hdfs.server.namenode.INodeDirectory
All Implemented Interfaces:
Comparable<byte[]>, org.apache.hadoop.hdfs.server.namenode.INodeAttributes, org.apache.hadoop.hdfs.server.namenode.INodeDirectoryAttributes, Diff.Element<byte[]>, org.apache.hadoop.util.LightWeightGSet.LinkedElement
Direct Known Subclasses:
Snapshot.Root

public class INodeDirectory
extends org.apache.hadoop.hdfs.server.namenode.INodeWithAdditionalFields
implements org.apache.hadoop.hdfs.server.namenode.INodeDirectoryAttributes

Directory INode class.


Nested Class Summary
static class INodeDirectory.SnapshotAndINode
          A pair of Snapshot and INode objects.
 
Nested classes/interfaces inherited from class org.apache.hadoop.hdfs.server.namenode.INode
INode.BlocksMapUpdateInfo, INode.Feature
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hdfs.server.namenode.INodeDirectoryAttributes
INodeDirectoryAttributes.CopyWithQuota, INodeDirectoryAttributes.SnapshotCopy
 
Field Summary
protected static int DEFAULT_FILES_PER_DIRECTORY
           
 
Fields inherited from class org.apache.hadoop.hdfs.server.namenode.INodeWithAdditionalFields
features
 
Fields inherited from class org.apache.hadoop.hdfs.server.namenode.INode
LOG
 
Constructor Summary
INodeDirectory(INodeDirectory other, boolean adopt, INode.Feature... featuresToCopy)
          Copy constructor
INodeDirectory(long id, byte[] name, org.apache.hadoop.fs.permission.PermissionStatus permissions, long mtime)
          constructor
 
Method Summary
 boolean addChild(org.apache.hadoop.hdfs.server.namenode.INode node)
           
 boolean addChild(org.apache.hadoop.hdfs.server.namenode.INode node, boolean setModTime, int latestSnapshotId)
          Add a child inode to the directory.
 org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot addSnapshot(int id, String name)
           
 org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature addSnapshotFeature(DirectoryWithSnapshotFeature.DirectoryDiffList diffs)
           
 void addSnapshottableFeature()
          add DirectorySnapshottableFeature
 void addSpaceConsumed(long nsDelta, long dsDelta, boolean verify)
          Check and add namespace/diskspace consumed to itself and the ancestors.
 INodeDirectory asDirectory()
          Cast this inode to an INodeDirectory.
 Quota.Counts cleanSubtree(int snapshotId, int priorSnapshotId, INode.BlocksMapUpdateInfo collectedBlocks, List<org.apache.hadoop.hdfs.server.namenode.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(int snapshot, int prior, INode.BlocksMapUpdateInfo collectedBlocks, List<org.apache.hadoop.hdfs.server.namenode.INode> removedINodes, Map<org.apache.hadoop.hdfs.server.namenode.INode,org.apache.hadoop.hdfs.server.namenode.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.
 org.apache.hadoop.hdfs.server.namenode.ContentSummaryComputationContext computeContentSummary(org.apache.hadoop.hdfs.server.namenode.ContentSummaryComputationContext summary)
          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<org.apache.hadoop.hdfs.server.namenode.INode> removedINodes)
          Destroy self and clear everything! If the INode is a file, this method collects its blocks for further block deletion.
 void dumpTreeRecursively(PrintWriter out, StringBuilder prefix, int snapshot)
          Dump tree recursively.
static void dumpTreeRecursively(PrintWriter out, StringBuilder prefix, Iterable<INodeDirectory.SnapshotAndINode> subs)
          Dump the given subtrees.
 org.apache.hadoop.hdfs.server.namenode.INode getChild(byte[] name, int snapshotId)
           
 org.apache.hadoop.hdfs.util.ReadOnlyList<org.apache.hadoop.hdfs.server.namenode.INode> getChildrenList(int snapshotId)
           
 int getChildrenNum(int snapshotId)
           
 DirectoryWithSnapshotFeature.DirectoryDiffList getDiffs()
           
 org.apache.hadoop.hdfs.server.namenode.snapshot.DirectorySnapshottableFeature getDirectorySnapshottableFeature()
           
 DirectoryWithQuotaFeature getDirectoryWithQuotaFeature()
          If the directory contains a DirectoryWithQuotaFeature, return it; otherwise, return null.
 org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature getDirectoryWithSnapshotFeature()
          If feature list contains a DirectoryWithSnapshotFeature, return it; otherwise, return null.
 byte getLocalStoragePolicyID()
           
 Quota.Counts getQuotaCounts()
          Get the quota set for this inode
 org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot getSnapshot(byte[] snapshotName)
           
 org.apache.hadoop.hdfs.server.namenode.INodeDirectoryAttributes getSnapshotINode(int snapshotId)
           
 byte getStoragePolicyID()
           
 boolean isDirectory()
          Check whether it's a directory
 boolean isSnapshottable()
           
 boolean isWithSnapshot()
          Is this file has the snapshot feature?
 boolean metadataEquals(org.apache.hadoop.hdfs.server.namenode.INodeDirectoryAttributes other)
          Compare the metadata with another INodeDirectory
 void recordModification(int latestSnapshotId)
          This inode is being modified.
 boolean removeChild(org.apache.hadoop.hdfs.server.namenode.INode child)
          Remove the specified child from this directory.
 boolean removeChild(org.apache.hadoop.hdfs.server.namenode.INode child, int latestSnapshotId)
          Remove the specified child from this directory.
 org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot removeSnapshot(String snapshotName, INode.BlocksMapUpdateInfo collectedBlocks, List<org.apache.hadoop.hdfs.server.namenode.INode> removedINodes)
           
 void removeSnapshottableFeature()
          remove DirectorySnapshottableFeature
 void renameSnapshot(String path, String oldName, String newName)
           
 void replaceChild(org.apache.hadoop.hdfs.server.namenode.INode oldChild, org.apache.hadoop.hdfs.server.namenode.INode newChild, INodeMap inodeMap)
          Replace the given child with a new child.
 org.apache.hadoop.hdfs.server.namenode.INode saveChild2Snapshot(org.apache.hadoop.hdfs.server.namenode.INode child, int latestSnapshotId, org.apache.hadoop.hdfs.server.namenode.INode snapshotCopy)
          Save the child to the latest snapshot.
 int searchChild(org.apache.hadoop.hdfs.server.namenode.INode inode)
          Search for the given INode in the children list and the deleted lists of snapshots.
 void setSnapshotQuota(int snapshotQuota)
           
 String toDetailString()
           
 void undoRename4DstParent(org.apache.hadoop.hdfs.server.namenode.INode deletedChild, int latestSnapshotId)
          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, org.apache.hadoop.hdfs.server.namenode.INode newChild)
          This method is usually called by the undo section of rename.
static INodeDirectory valueOf(org.apache.hadoop.hdfs.server.namenode.INode inode, Object path)
          Cast INode to INodeDirectory.
 
Methods inherited from class org.apache.hadoop.hdfs.server.namenode.INodeWithAdditionalFields
addAclFeature, addFeature, addXAttrFeature, getFeature, getFeatures, getFsPermissionShort, getId, getLocalNameBytes, getNext, getPermissionLong, removeAclFeature, removeFeature, removeXAttrFeature, setAccessTime, setLocalName, setModificationTime, setNext, updateModificationTime
 
Methods inherited from class org.apache.hadoop.hdfs.server.namenode.INode
asFile, asReference, asSymlink, compareTo, computeAndConvertContentSummary, computeContentSummary, computeQuotaUsage, computeQuotaUsage, dumpTreeRecursively, dumpTreeRecursively, equals, getAccessTime, getAclFeature, getFsPermission, getFullPathName, getGroupName, getKey, getLocalName, getModificationTime, getObjectString, getParent, getParentReference, getParentString, getPathComponents, getPathNames, getUserName, getXAttrFeature, hashCode, isAncestorDirectory, isFile, isInLatestSnapshot, isQuotaSet, isReference, isSymlink, setAccessTime, setModificationTime, setParent, setParentReference, shouldRecordInSrcSnapshot, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.hadoop.hdfs.server.namenode.INodeAttributes
getAccessTime, getAclFeature, getFsPermission, getFsPermissionShort, getGroupName, getLocalNameBytes, getModificationTime, getPermissionLong, getUserName, getXAttrFeature
 

Field Detail

DEFAULT_FILES_PER_DIRECTORY

protected static final int DEFAULT_FILES_PER_DIRECTORY
See Also:
Constant Field Values
Constructor Detail

INodeDirectory

public INodeDirectory(long id,
                      byte[] name,
                      org.apache.hadoop.fs.permission.PermissionStatus permissions,
                      long mtime)
constructor


INodeDirectory

public INodeDirectory(INodeDirectory other,
                      boolean adopt,
                      INode.Feature... featuresToCopy)
Copy constructor

Parameters:
other - The INodeDirectory to be copied
adopt - Indicate whether or not need to set the parent field of child INodes to the new node
featuresToCopy - any number of features to copy to the new node. The method will do a reference copy, not a deep copy.
Method Detail

valueOf

public static INodeDirectory valueOf(org.apache.hadoop.hdfs.server.namenode.INode inode,
                                     Object path)
                              throws FileNotFoundException,
                                     org.apache.hadoop.fs.PathIsNotDirectoryException
Cast INode to INodeDirectory.

Throws:
FileNotFoundException
org.apache.hadoop.fs.PathIsNotDirectoryException

isDirectory

public final boolean isDirectory()
Description copied from class: org.apache.hadoop.hdfs.server.namenode.INode
Check whether it's a directory

Overrides:
isDirectory in class org.apache.hadoop.hdfs.server.namenode.INode
Returns:
true unconditionally.

asDirectory

public final INodeDirectory asDirectory()
Description copied from class: org.apache.hadoop.hdfs.server.namenode.INode
Cast this inode to an INodeDirectory.

Overrides:
asDirectory in class org.apache.hadoop.hdfs.server.namenode.INode
Returns:
this object.

getLocalStoragePolicyID

public byte getLocalStoragePolicyID()
Specified by:
getLocalStoragePolicyID in class org.apache.hadoop.hdfs.server.namenode.INode
Returns:
the storage policy directly specified on the INode. Return BlockStoragePolicySuite.ID_UNSPECIFIED if no policy has been specified.

getStoragePolicyID

public byte getStoragePolicyID()
Specified by:
getStoragePolicyID in class org.apache.hadoop.hdfs.server.namenode.INode
Returns:
the latest block storage policy id of the INode. Specifically, if a storage policy is directly specified on the INode then return the ID of that policy. Otherwise follow the latest parental path and return the ID of the first specified storage policy.

getQuotaCounts

public Quota.Counts getQuotaCounts()
Description copied from class: org.apache.hadoop.hdfs.server.namenode.INode
Get the quota set for this inode

Specified by:
getQuotaCounts in interface org.apache.hadoop.hdfs.server.namenode.INodeDirectoryAttributes
Overrides:
getQuotaCounts in class org.apache.hadoop.hdfs.server.namenode.INode
Returns:
the quota counts. The count is -1 if it is not set.

addSpaceConsumed

public void addSpaceConsumed(long nsDelta,
                             long dsDelta,
                             boolean verify)
                      throws org.apache.hadoop.hdfs.protocol.QuotaExceededException
Description copied from class: org.apache.hadoop.hdfs.server.namenode.INode
Check and add namespace/diskspace consumed to itself and the ancestors.

Overrides:
addSpaceConsumed in class org.apache.hadoop.hdfs.server.namenode.INode
Throws:
org.apache.hadoop.hdfs.protocol.QuotaExceededException - if quote is violated.

getDirectoryWithQuotaFeature

public final DirectoryWithQuotaFeature getDirectoryWithQuotaFeature()
If the directory contains a DirectoryWithQuotaFeature, return it; otherwise, return null.


addSnapshotFeature

public org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature addSnapshotFeature(DirectoryWithSnapshotFeature.DirectoryDiffList diffs)

getDirectoryWithSnapshotFeature

public final org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature getDirectoryWithSnapshotFeature()
If feature list contains a DirectoryWithSnapshotFeature, return it; otherwise, return null.


isWithSnapshot

public final boolean isWithSnapshot()
Is this file has the snapshot feature?


getDiffs

public DirectoryWithSnapshotFeature.DirectoryDiffList getDiffs()

getSnapshotINode

public org.apache.hadoop.hdfs.server.namenode.INodeDirectoryAttributes getSnapshotINode(int snapshotId)
Overrides:
getSnapshotINode in class org.apache.hadoop.hdfs.server.namenode.INode
Returns:
if the given snapshot id is Snapshot.CURRENT_STATE_ID, return this; otherwise return the corresponding snapshot inode.

toDetailString

public String toDetailString()
Overrides:
toDetailString in class org.apache.hadoop.hdfs.server.namenode.INode

getDirectorySnapshottableFeature

public org.apache.hadoop.hdfs.server.namenode.snapshot.DirectorySnapshottableFeature getDirectorySnapshottableFeature()

isSnapshottable

public boolean isSnapshottable()

getSnapshot

public org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot getSnapshot(byte[] snapshotName)

setSnapshotQuota

public void setSnapshotQuota(int snapshotQuota)

addSnapshot

public org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot addSnapshot(int id,
                                                                            String name)
                                                                     throws SnapshotException,
                                                                            org.apache.hadoop.hdfs.protocol.QuotaExceededException
Throws:
SnapshotException
org.apache.hadoop.hdfs.protocol.QuotaExceededException

removeSnapshot

public org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot removeSnapshot(String snapshotName,
                                                                               INode.BlocksMapUpdateInfo collectedBlocks,
                                                                               List<org.apache.hadoop.hdfs.server.namenode.INode> removedINodes)
                                                                        throws SnapshotException
Throws:
SnapshotException

renameSnapshot

public void renameSnapshot(String path,
                           String oldName,
                           String newName)
                    throws SnapshotException
Throws:
SnapshotException

addSnapshottableFeature

public void addSnapshottableFeature()
add DirectorySnapshottableFeature


removeSnapshottableFeature

public void removeSnapshottableFeature()
remove DirectorySnapshottableFeature


replaceChild

public void replaceChild(org.apache.hadoop.hdfs.server.namenode.INode oldChild,
                         org.apache.hadoop.hdfs.server.namenode.INode newChild,
                         INodeMap inodeMap)
Replace the given child with a new child. Note that we no longer need to replace an normal INodeDirectory or INodeFile into an INodeDirectoryWithSnapshot or INodeFileUnderConstruction. The only cases for child replacement is for reference nodes.


recordModification

public void recordModification(int latestSnapshotId)
                        throws org.apache.hadoop.hdfs.protocol.QuotaExceededException
Description copied from class: org.apache.hadoop.hdfs.server.namenode.INode
This inode is being modified. The previous version of the inode needs to be recorded in the latest snapshot.

Specified by:
recordModification in class org.apache.hadoop.hdfs.server.namenode.INode
Parameters:
latestSnapshotId - The id of the latest snapshot that has been taken. Note that it is Snapshot.CURRENT_STATE_ID if no snapshots have been taken.
Throws:
org.apache.hadoop.hdfs.protocol.QuotaExceededException

saveChild2Snapshot

public org.apache.hadoop.hdfs.server.namenode.INode saveChild2Snapshot(org.apache.hadoop.hdfs.server.namenode.INode child,
                                                                       int latestSnapshotId,
                                                                       org.apache.hadoop.hdfs.server.namenode.INode snapshotCopy)
                                                                throws org.apache.hadoop.hdfs.protocol.QuotaExceededException
Save the child to the latest snapshot.

Returns:
the child inode, which may be replaced.
Throws:
org.apache.hadoop.hdfs.protocol.QuotaExceededException

getChild

public org.apache.hadoop.hdfs.server.namenode.INode getChild(byte[] name,
                                                             int snapshotId)
Parameters:
name - the name of the child
snapshotId - if it is not Snapshot.CURRENT_STATE_ID, get the result from the corresponding snapshot; otherwise, get the result from the current directory.
Returns:
the child inode.

searchChild

public int searchChild(org.apache.hadoop.hdfs.server.namenode.INode inode)
Search for the given INode in the children list and the deleted lists of snapshots.

Returns:
Snapshot.CURRENT_STATE_ID if the inode is in the children list; Snapshot.NO_SNAPSHOT_ID if the inode is neither in the children list nor in any snapshot; otherwise the snapshot id of the corresponding snapshot diff list.

getChildrenList

public org.apache.hadoop.hdfs.util.ReadOnlyList<org.apache.hadoop.hdfs.server.namenode.INode> getChildrenList(int snapshotId)
Parameters:
snapshotId - if it is not Snapshot.CURRENT_STATE_ID, get the result from the corresponding snapshot; otherwise, get the result from the current directory.
Returns:
the current children list if the specified snapshot is null; otherwise, return the children list corresponding to the snapshot. Note that the returned list is never null.

removeChild

public boolean removeChild(org.apache.hadoop.hdfs.server.namenode.INode child,
                           int latestSnapshotId)
                    throws org.apache.hadoop.hdfs.protocol.QuotaExceededException
Remove the specified child from this directory.

Throws:
org.apache.hadoop.hdfs.protocol.QuotaExceededException

removeChild

public boolean removeChild(org.apache.hadoop.hdfs.server.namenode.INode child)
Remove the specified child from this directory. The basic remove method which actually calls children.remove(..).

Parameters:
child - the child inode to be removed
Returns:
true if the child is removed; false if the child is not found.

addChild

public boolean addChild(org.apache.hadoop.hdfs.server.namenode.INode node,
                        boolean setModTime,
                        int latestSnapshotId)
                 throws org.apache.hadoop.hdfs.protocol.QuotaExceededException
Add a child inode to the directory.

Parameters:
node - INode to insert
setModTime - set modification time for the parent node not needed when replaying the addition and the parent already has the proper mod time
Returns:
false if the child with this name already exists; otherwise, return true;
Throws:
org.apache.hadoop.hdfs.protocol.QuotaExceededException

addChild

public boolean addChild(org.apache.hadoop.hdfs.server.namenode.INode node)

computeQuotaUsage

public Quota.Counts computeQuotaUsage(Quota.Counts counts,
                                      boolean useCache,
                                      int lastSnapshotId)
Description copied from class: org.apache.hadoop.hdfs.server.namenode.INode
Count subtree 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 a INodeReference.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 a INodeReference.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 the INodeReference.WithName node.
 We do not count in the size of the diff list.  
 

Specified by:
computeQuotaUsage in class org.apache.hadoop.hdfs.server.namenode.INode
Parameters:
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.CURRENT_STATE_ID indicates the computation is in the current tree. Otherwise the id indicates the computation range for a INodeReference.WithName node.
Returns:
The same objects as the counts parameter.

computeQuotaUsage4CurrentDirectory

public Quota.Counts computeQuotaUsage4CurrentDirectory(Quota.Counts counts)
Add quota usage for this inode excluding children.


computeContentSummary

public org.apache.hadoop.hdfs.server.namenode.ContentSummaryComputationContext computeContentSummary(org.apache.hadoop.hdfs.server.namenode.ContentSummaryComputationContext summary)
Description copied from class: org.apache.hadoop.hdfs.server.namenode.INode
Count subtree content summary with a Content.Counts.

Specified by:
computeContentSummary in class org.apache.hadoop.hdfs.server.namenode.INode
Parameters:
summary - the context object holding counts for the subtree.
Returns:
The same objects as summary.

undoRename4ScrParent

public void undoRename4ScrParent(INodeReference oldChild,
                                 org.apache.hadoop.hdfs.server.namenode.INode newChild)
                          throws org.apache.hadoop.hdfs.protocol.QuotaExceededException
This method is usually called by the undo section of rename. Before calling this function, in the rename operation, we replace the original src node (of the rename operation) with a reference node (WithName instance) in both the children list and a created list, delete the reference node from the children list, and add it to the corresponding deleted list. To undo the above operations, we have the following steps in particular:
 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.

Parameters:
oldChild - The reference node to be removed/replaced
newChild - The node to be added back
Throws:
org.apache.hadoop.hdfs.protocol.QuotaExceededException - should not throw this exception

undoRename4DstParent

public void undoRename4DstParent(org.apache.hadoop.hdfs.server.namenode.INode deletedChild,
                                 int latestSnapshotId)
                          throws org.apache.hadoop.hdfs.protocol.QuotaExceededException
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.

Throws:
org.apache.hadoop.hdfs.protocol.QuotaExceededException

clearChildren

public void clearChildren()
Set the children list to null.


clear

public void clear()
Description copied from class: org.apache.hadoop.hdfs.server.namenode.INode
Clear references to other objects.

Overrides:
clear in class org.apache.hadoop.hdfs.server.namenode.INode

cleanSubtreeRecursively

public Quota.Counts cleanSubtreeRecursively(int snapshot,
                                            int prior,
                                            INode.BlocksMapUpdateInfo collectedBlocks,
                                            List<org.apache.hadoop.hdfs.server.namenode.INode> removedINodes,
                                            Map<org.apache.hadoop.hdfs.server.namenode.INode,org.apache.hadoop.hdfs.server.namenode.INode> excludedNodes,
                                            boolean countDiffChange)
                                     throws org.apache.hadoop.hdfs.protocol.QuotaExceededException
Call cleanSubtree(..) recursively down the subtree.

Throws:
org.apache.hadoop.hdfs.protocol.QuotaExceededException

destroyAndCollectBlocks

public void destroyAndCollectBlocks(INode.BlocksMapUpdateInfo collectedBlocks,
                                    List<org.apache.hadoop.hdfs.server.namenode.INode> removedINodes)
Description copied from class: org.apache.hadoop.hdfs.server.namenode.INode
Destroy self and clear everything! If the INode is a file, this method collects its blocks for further block deletion. If the INode is a directory, the method goes down the subtree and collects blocks from the descents, and clears its parent/children references as well. The method also clears the diff list if the INode contains snapshot diff list.

Specified by:
destroyAndCollectBlocks in class org.apache.hadoop.hdfs.server.namenode.INode
Parameters:
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 inodeMap

cleanSubtree

public Quota.Counts cleanSubtree(int snapshotId,
                                 int priorSnapshotId,
                                 INode.BlocksMapUpdateInfo collectedBlocks,
                                 List<org.apache.hadoop.hdfs.server.namenode.INode> removedINodes,
                                 boolean countDiffChange)
                          throws org.apache.hadoop.hdfs.protocol.QuotaExceededException
Description copied from class: org.apache.hadoop.hdfs.server.namenode.INode
Clean the subtree under this inode and collect the blocks from the descents for further block deletion/update. The current inode can either resides in the current tree or be stored as a snapshot copy.
 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 an INodeFile. 
 1.1.1 If prior 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 an INodeDirectory.
 1.2.1 If prior 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 a file with snapshot.
 Call recordModification(..) to capture the current states.
 Mark the INode as deleted.
 
 1.4 The current inode is an INodeDirectory with 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 clean INodeFile: do nothing.
 2.2 To clean INodeDirectory: recursively clean its children.
 2.3 To clean INodeFile with snapshot: delete the corresponding snapshot in
 its diff list.
 2.4 To clean INodeDirectory with snapshot: delete the corresponding 
 snapshot in its diff list. Recursively clean its children.
 

Specified by:
cleanSubtree in class org.apache.hadoop.hdfs.server.namenode.INode
Parameters:
snapshotId - 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.
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 inodeMap
Returns:
quota usage delta when deleting a snapshot
Throws:
org.apache.hadoop.hdfs.protocol.QuotaExceededException

metadataEquals

public boolean metadataEquals(org.apache.hadoop.hdfs.server.namenode.INodeDirectoryAttributes other)
Compare the metadata with another INodeDirectory

Specified by:
metadataEquals in interface org.apache.hadoop.hdfs.server.namenode.INodeDirectoryAttributes

dumpTreeRecursively

public void dumpTreeRecursively(PrintWriter out,
                                StringBuilder prefix,
                                int snapshot)
Description copied from class: org.apache.hadoop.hdfs.server.namenode.INode
Dump tree recursively.

Overrides:
dumpTreeRecursively in class org.apache.hadoop.hdfs.server.namenode.INode
prefix - The prefix string that each line should print.

dumpTreeRecursively

public static void dumpTreeRecursively(PrintWriter out,
                                       StringBuilder prefix,
                                       Iterable<INodeDirectory.SnapshotAndINode> subs)
Dump the given subtrees.

Parameters:
prefix - The prefix string that each line should print.
subs - The subtrees.

getChildrenNum

public final int getChildrenNum(int snapshotId)


Copyright © 2014 Apache Software Foundation. All Rights Reserved.