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:
    org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature

      public static class DirectoryWithSnapshotFeature.DirectoryDiffList
      extends Object

  A list of directory diffs.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DirectoryDiffList()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `DiffList<D>` | `asList()`
    `void` | `clear()` Clear the list.
    `void` | `deleteSnapshotDiff(INode.ReclaimContext reclaimContext, int snapshot, int prior, N currentINode)` Delete a snapshot.
    `int` | `findSnapshotDeleted(org.apache.hadoop.hdfs.server.namenode.INode child)` Find the corresponding snapshot whose deleted list contains the given inode.
    `D` | `getDiffById(int snapshotId)`
    `int` | `getDiffIndexById(int snapshotId)`
    `D` | `getLast()`
    `int` | `getLastSnapshotId()`
    `int` | `getPrior(int snapshotId)`
    `int` | `getPrior(int anchorId, boolean exclusive)` Find the latest snapshot before a given snapshot.
    `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.
    `A` | `getSnapshotINode(int snapshotId, A currentINode)`
    `boolean` | `isEmpty()`
    `Iterator<D>` | `iterator()`
    `boolean` | `removeDeletedChild(org.apache.hadoop.hdfs.server.namenode.INode child)` Remove the given child from the deleted list, if there is any.
    `boolean` | `replaceCreatedChild(org.apache.hadoop.hdfs.server.namenode.INode oldChild, org.apache.hadoop.hdfs.server.namenode.INode newChild)` Replace the given child in the created/deleted list, if there is any.
    `D` | `saveSelf2Snapshot(int latestSnapshotId, N currentINode, A 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 Detail

    - #### DirectoryDiffList

          public DirectoryDiffList()

  - ### Method Detail

    - #### replaceCreatedChild

          public boolean replaceCreatedChild(org.apache.hadoop.hdfs.server.namenode.INode oldChild,
                                             org.apache.hadoop.hdfs.server.namenode.INode newChild)

      Replace the given child in the created/deleted list, if there is any.

    - #### removeDeletedChild

          public boolean removeDeletedChild(org.apache.hadoop.hdfs.server.namenode.INode child)

      Remove the given child from the deleted list, if there is any.

    - #### findSnapshotDeleted

          public int findSnapshotDeleted(org.apache.hadoop.hdfs.server.namenode.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<D> 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,
                                               N 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 D 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 D 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 A getSnapshotINode(int snapshotId,
                                    A 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 D saveSelf2Snapshot(int latestSnapshotId,
                                     N currentINode,
                                     A snapshotCopy)

      Save the snapshot copy to the latest snapshot.

    - #### iterator

          public Iterator<D> iterator()

      Specified by:
        `iterator` in interface `Iterable<D extends org.apache.hadoop.hdfs.server.namenode.snapshot.AbstractINodeDiff<N,A,D>>`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2008–2022 Apache Software Foundation. All rights reserved.