DirectoryWithSnapshotFeature.DirectoryDiffList (Apache Hadoop HDFS 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.server.namenode.snapshot, class: DirectoryWithSnapshotFeature, class: DirectoryDiffList

Package org.apache.hadoop.hdfs.server.namenode.snapshot

# Class DirectoryWithSnapshotFeature.DirectoryDiffList

java.lang.Object
org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature.DirectoryDiffList

All Implemented Interfaces:
  `Iterable<DirectoryWithSnapshotFeature.DirectoryDiff>`

Enclosing class:
  DirectoryWithSnapshotFeature

public static class DirectoryWithSnapshotFeature.DirectoryDiffList extends Object
A list of directory diffs.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DirectoryDiffList()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `final DiffList<DirectoryWithSnapshotFeature.DirectoryDiff>`
  `asList()`
  `void`
  `clear()`
  Clear the list.
  `final void`
  `deleteSnapshotDiff(INode.ReclaimContext reclaimContext, int snapshot, int prior, INodeDirectory currentINode)`
  Delete a snapshot.
  `int`
  `findSnapshotDeleted(INode child)`
  Find the corresponding snapshot whose deleted list contains the given inode.
  `final DirectoryWithSnapshotFeature.DirectoryDiff`
  `getDiffById(int snapshotId)`
  `final int`
  `getDiffIndexById(int snapshotId)`
  `final DirectoryWithSnapshotFeature.DirectoryDiff`
  `getLast()`
  `final int`
  `getLastSnapshotId()`
  `final int`
  `getPrior(int snapshotId)`
  `final int`
  `getPrior(int anchorId, boolean exclusive)`
  Find the latest snapshot before a given snapshot.
  `final int`
  `getSnapshotById(int snapshotId)`
  Search for the snapshot whose id is 1) no less than the given id, and 2) most close to the given id.
  `INodeDirectoryAttributes`
  `getSnapshotINode(int snapshotId, INodeDirectoryAttributes currentINode)`
  `boolean`
  `isEmpty()`
  `Iterator<DirectoryWithSnapshotFeature.DirectoryDiff>`
  `iterator()`
  `boolean`
  `removeDeletedChild(INode child)`
  Remove the given child from the deleted list, if there is any.
  `boolean`
  `replaceCreatedChild(INode oldChild, INode newChild)`
  Replace the given child in the created/deleted list, if there is any.
  `DirectoryWithSnapshotFeature.DirectoryDiff`
  `saveSelf2Snapshot(int latestSnapshotId, INodeDirectory currentINode, INodeDirectoryAttributes snapshotCopy)`
  Save the snapshot copy to the latest snapshot.
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface java.lang.Iterable

  `forEach, spliterator`

- ## Constructor Details

  - ### DirectoryDiffList

    public DirectoryDiffList()

- ## Method Details

  - ### replaceCreatedChild

    public boolean replaceCreatedChild(INode oldChild, INode newChild)
    Replace the given child in the created/deleted list, if there is any.

  - ### removeDeletedChild

    public boolean removeDeletedChild(INode child)
    Remove the given child from the deleted list, if there is any.

  - ### findSnapshotDeleted

    public int findSnapshotDeleted(INode child)
    Find the corresponding snapshot whose deleted list contains the given inode.
    Returns:
      the id of the snapshot. `Snapshot.NO_SNAPSHOT_ID` if the given inode is not in any of the snapshot.

  - ### asList

    public final DiffList<DirectoryWithSnapshotFeature.DirectoryDiff> asList()
    Returns:
      this list as a unmodifiable `List`.

  - ### isEmpty

    public boolean isEmpty()

  - ### clear

    public void clear()
    Clear the list.

  - ### deleteSnapshotDiff

    public final void deleteSnapshotDiff(INode.ReclaimContext reclaimContext, int snapshot, int prior, INodeDirectory currentINode)
    Delete a snapshot. The synchronization of the diff list will be done outside. If the diff to remove is not the first one in the diff list, we need to combine the diff with its previous one.
    Parameters:
      `reclaimContext` - blocks and inodes that need to be reclaimed
      `snapshot` - The id of the snapshot to be deleted
      `prior` - The id of the snapshot taken before the to-be-deleted snapshot
      `currentINode` - the inode where the snapshot diff is deleted

  - ### getLast

    public final DirectoryWithSnapshotFeature.DirectoryDiff getLast()
    Returns:
      the last diff.

  - ### getLastSnapshotId

    public final int getLastSnapshotId()
    Returns:
      the id of the last snapshot.

  - ### getPrior

    public final int getPrior(int anchorId, boolean exclusive)
    Find the latest snapshot before a given snapshot.
    Parameters:
      `anchorId` - The returned snapshot's id must be <= or < this given snapshot id.
      `exclusive` - True means the returned snapshot's id must be < the given id, otherwise <=.
    Returns:
      The id of the latest snapshot before the given snapshot.

  - ### getPrior

    public final int getPrior(int snapshotId)

  - ### getDiffById

    public final DirectoryWithSnapshotFeature.DirectoryDiff getDiffById(int snapshotId)

  - ### getSnapshotById

    public final int getSnapshotById(int snapshotId)
    Search for the snapshot whose id is 1) no less than the given id, and 2) most close to the given id.

  - ### getDiffIndexById

    public final int getDiffIndexById(int snapshotId)

  - ### getSnapshotINode

    public INodeDirectoryAttributes getSnapshotINode(int snapshotId, INodeDirectoryAttributes currentINode)
    Returns:
      the inode corresponding to the given snapshot. Note that the current inode is returned if there is no change between the given snapshot and the current state.

  - ### saveSelf2Snapshot

    public DirectoryWithSnapshotFeature.DirectoryDiff saveSelf2Snapshot(int latestSnapshotId, INodeDirectory currentINode, INodeDirectoryAttributes snapshotCopy)
    Save the snapshot copy to the latest snapshot.

  - ### iterator

    public Iterator<DirectoryWithSnapshotFeature.DirectoryDiff> iterator()
    Specified by:
      `iterator` in interface `Iterable<N extends INode>`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`