Class INodeReference.WithName

All Implemented Interfaces:
Comparable<byte[]>, INodeAttributes, Diff.Element<byte[]>
Enclosing class:
INodeReference

public static class INodeReference.WithName extends INodeReference
A reference with a fixed name.
  • Constructor Details

  • Method Details

    • getLocalNameBytes

      public final byte[] getLocalNameBytes()
      Specified by:
      getLocalNameBytes in interface INodeAttributes
      Overrides:
      getLocalNameBytes in class INodeReference
      Returns:
      null if the local name is null; otherwise, return the local name byte array.
    • setLocalName

      public final void setLocalName(byte[] name)
      Description copied from class: INode
      Set local file name
      Overrides:
      setLocalName in class INodeReference
    • getLastSnapshotId

      public int getLastSnapshotId()
    • computeContentSummary

      public final ContentSummaryComputationContext computeContentSummary(int snapshotId, ContentSummaryComputationContext summary) throws org.apache.hadoop.security.AccessControlException
      Description copied from class: INode
      Count subtree content summary with a ContentCounts.
      Overrides:
      computeContentSummary in class INodeReference
      Parameters:
      snapshotId - Specify the time range for the calculation. If this parameter equals to Snapshot.CURRENT_STATE_ID, the result covers both the current states and all the snapshots. Otherwise the result only covers all the files/directories contained in the specific snapshot.
      summary - the context object holding counts for the subtree.
      Returns:
      The same objects as summary.
      Throws:
      org.apache.hadoop.security.AccessControlException
    • computeQuotaUsage

      public final QuotaCounts computeQuotaUsage(BlockStoragePolicySuite bsps, byte blockStoragePolicyId, boolean useCache, int lastSnapshotId)
      Description copied from class: INode
      Count subtree Quota.NAMESPACE and Quota.STORAGESPACE 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.
       
      Overrides:
      computeQuotaUsage in class INodeReference
      Parameters:
      bsps - Block storage policy suite to calculate intended storage type usage
      blockStoragePolicyId - block storage policy id of the current INode
      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 subtree quota counts.
    • cleanSubtree

      public void cleanSubtree(INode.ReclaimContext reclaimContext, int snapshot, int prior)
      Description copied from class: 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.
       
      Overrides:
      cleanSubtree in class INodeReference
      Parameters:
      reclaimContext - Record blocks and inodes that need to be reclaimed.
      snapshot - The id of the snapshot to delete. Snapshot.CURRENT_STATE_ID means to delete the current file/directory.
      prior - The id of the latest snapshot before the to-be-deleted snapshot. When deleting a current inode, this parameter captures the latest snapshot.
    • destroyAndCollectBlocks

      public void destroyAndCollectBlocks(INode.ReclaimContext reclaimContext)
      Description copied from class: 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.
      Overrides:
      destroyAndCollectBlocks in class INodeReference
      Parameters:
      reclaimContext - Record blocks and inodes that need to be reclaimed.