java.lang.Object
org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot
All Implemented Interfaces:
Comparable<byte[]>

@Private public class Snapshot extends Object implements Comparable<byte[]>
Snapshot of a sub-tree in the namesystem.
  • Field Details

    • CURRENT_STATE_ID

      public static final int CURRENT_STATE_ID
      This id is used to indicate the current state (vs. snapshots)
      See Also:
    • NO_SNAPSHOT_ID

      public static final int NO_SNAPSHOT_ID
      See Also:
    • ID_COMPARATOR

      public static final Comparator<Snapshot> ID_COMPARATOR
      Compare snapshot with IDs, where null indicates the current status thus is greater than any non-null snapshot.
    • ID_INTEGER_COMPARATOR

      public static final Comparator<Integer> ID_INTEGER_COMPARATOR
      Compare snapshot with IDs, where null indicates the current status thus is greater than any non-null ID.
  • Method Details

    • generateDefaultSnapshotName

      public static String generateDefaultSnapshotName()
    • generateDeletedSnapshotName

      public static String generateDeletedSnapshotName(Snapshot s)
    • getSnapshotPath

      public static String getSnapshotPath(String snapshottableDir, String snapshotRelativePath)
    • getSnapshotId

      public static int getSnapshotId(Snapshot s)
    • getSnapshotString

      public static String getSnapshotString(int snapshot)
    • findLatestSnapshot

      public static int findLatestSnapshot(INode inode, int anchor)
      Find the latest snapshot that 1) covers the given inode (which means the snapshot was either taken on the inode or taken on an ancestor of the inode), and 2) was taken before the given snapshot (if the given snapshot is not null).
      Parameters:
      inode - the given inode that the returned snapshot needs to cover
      anchor - the returned snapshot should be taken before this given id.
      Returns:
      id of the latest snapshot that covers the given inode and was taken before the the given snapshot (if it is not null).
    • getId

      public int getId()
    • getRoot

      public Snapshot.Root getRoot()
      Returns:
      the root directory of the snapshot.
    • compareTo

      public int compareTo(byte[] bytes)
      Specified by:
      compareTo in interface Comparable<byte[]>
    • equals

      public boolean equals(Object that)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object