org.apache.hadoop.hdfs.server.namenode
Class INodeReference.DstReference

java.lang.Object
  extended by org.apache.hadoop.hdfs.server.namenode.INode
      extended by org.apache.hadoop.hdfs.server.namenode.INodeReference
          extended by org.apache.hadoop.hdfs.server.namenode.INodeReference.DstReference
All Implemented Interfaces:
Comparable<byte[]>, org.apache.hadoop.hdfs.server.namenode.INodeAttributes, Diff.Element<byte[]>
Enclosing class:
INodeReference

public static class INodeReference.DstReference
extends INodeReference


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.hdfs.server.namenode.INodeReference
INodeReference.DstReference, INodeReference.WithCount, INodeReference.WithName
 
Nested classes/interfaces inherited from class org.apache.hadoop.hdfs.server.namenode.INode
INode.BlocksMapUpdateInfo
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hdfs.server.namenode.INodeAttributes
INodeAttributes.SnapshotCopy
 
Field Summary
 
Fields inherited from class org.apache.hadoop.hdfs.server.namenode.INode
LOG
 
Constructor Summary
INodeReference.DstReference(INodeDirectory parent, INodeReference.WithCount referred, int dstSnapshotId)
           
 
Method Summary
 Quota.Counts cleanSubtree(org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot snapshot, org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot prior, 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.
 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.
 int getDstSnapshotId()
           
 
Methods inherited from class org.apache.hadoop.hdfs.server.namenode.INodeReference
asDirectory, asFile, asReference, asSymlink, clear, computeContentSummary, computeQuotaUsage, dumpTreeRecursively, getAccessTime, getDsQuota, getFsPermission, getFsPermissionShort, getGroupName, getId, getLocalNameBytes, getModificationTime, getNsQuota, getPermissionLong, getPermissionStatus, getReferredINode, getSnapshotINode, getUserName, isDirectory, isFile, isReference, isSymlink, setAccessTime, setLocalName, setModificationTime, setReferredINode, tryRemoveReference, updateModificationTime
 
Methods inherited from class org.apache.hadoop.hdfs.server.namenode.INode
addSpaceConsumed, compareTo, computeAndConvertContentSummary, computeContentSummary, computeQuotaUsage, computeQuotaUsage, dumpTreeRecursively, dumpTreeRecursively, equals, getAccessTime, getFsPermission, getFullPathName, getGroupName, getKey, getLocalName, getModificationTime, getObjectString, getParent, getParentReference, getParentString, getUserName, hashCode, isAncestorDirectory, isInLatestSnapshot, isQuotaSet, setAccessTime, setModificationTime, setParent, setParentReference, shouldRecordInSrcSnapshot, toDetailString, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

INodeReference.DstReference

public INodeReference.DstReference(INodeDirectory parent,
                                   INodeReference.WithCount referred,
                                   int dstSnapshotId)
Method Detail

getDstSnapshotId

public final int getDstSnapshotId()
Overrides:
getDstSnapshotId in class INodeReference

cleanSubtree

public Quota.Counts cleanSubtree(org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot snapshot,
                                 org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot prior,
                                 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 FileWithSnapshot.
 Call recordModification(..) to capture the current states.
 Mark the INode as deleted.
 
 1.4 The current inode is a INodeDirectoryWithSnapshot.
 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 FileWithSnapshot: delete the corresponding snapshot in
 its diff list.
 2.4 To clean INodeDirectoryWithSnapshot: delete the corresponding 
 snapshot in its diff list. Recursively clean its children.
 

Overrides:
cleanSubtree in class INodeReference
Parameters:
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 inodeMap
Returns:
quota usage delta when deleting a snapshot
Throws:
org.apache.hadoop.hdfs.protocol.QuotaExceededException

destroyAndCollectBlocks

public 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. 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.
To destroy a DstReference node, we first remove its link with the referred node. If the reference number of the referred node is <= 0, we destroy the subtree of the referred node. Otherwise, we clean the referred node's subtree and delete everything created after the last rename operation, i.e., everything outside of the scope of the prior WithName nodes.

Overrides:
destroyAndCollectBlocks in class INodeReference
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


Copyright © 2014 Apache Software Foundation. All Rights Reserved.