Class SnapshotChainManager

java.lang.Object
org.apache.hadoop.ozone.om.SnapshotChainManager

public class SnapshotChainManager extends Object
This class is used for creating and accessing Snapshot Chains.

The snapshot chain maintains the in-memory sequence of snapshots created in chronological order. There are two such snapshots maintained i.) Path based snapshot chain, sequence of snapshots created for a given /volume/bucket ii.) Global snapshot chain, sequence of all snapshots created in order

On start, the snapshot chains are initialized from the on disk SnapshotInfoTable from the OM RocksDB.

  • Constructor Details

    • SnapshotChainManager

      public SnapshotChainManager(org.apache.hadoop.ozone.om.OMMetadataManager metadataManager)
  • Method Details

    • addSnapshot

      public void addSnapshot(org.apache.hadoop.ozone.om.helpers.SnapshotInfo snapshotInfo) throws IOException
      Add snapshot to snapshot chain.
      Throws:
      IOException
    • updateSnapshot

      public void updateSnapshot(org.apache.hadoop.ozone.om.helpers.SnapshotInfo snapshotInfo)
      Update snapshot chain when snapshot changes (e.g. renamed).
    • deleteSnapshot

      public boolean deleteSnapshot(org.apache.hadoop.ozone.om.helpers.SnapshotInfo snapshotInfo) throws IOException
      Delete snapshot from snapshot chain.
      Throws:
      IOException
    • removeFromSnapshotIdToTable

      public void removeFromSnapshotIdToTable(UUID snapshotId) throws IOException
      Remove the snapshot from snapshotIdToSnapshotTableKey map.
      Throws:
      IOException
    • getLatestGlobalSnapshotId

      public UUID getLatestGlobalSnapshotId() throws IOException
      Get latest global snapshot in snapshot chain.
      Throws:
      IOException
    • getOldestGlobalSnapshotId

      public UUID getOldestGlobalSnapshotId() throws IOException
      Get oldest of global snapshot in snapshot chain.
      Throws:
      IOException
    • iterator

      public Iterator<UUID> iterator(boolean reverse) throws IOException
      Throws:
      IOException
    • getLatestPathSnapshotId

      public UUID getLatestPathSnapshotId(String snapshotPath) throws IOException
      Get latest path snapshot in snapshot chain.
      Throws:
      IOException
    • hasNextGlobalSnapshot

      public boolean hasNextGlobalSnapshot(UUID snapshotId) throws IOException
      Returns true if snapshot from given snapshotId has a next snapshot entry in the global snapshot chain.
      Throws:
      IOException
    • nextGlobalSnapshot

      public UUID nextGlobalSnapshot(UUID snapshotId) throws IOException
      Get next global snapshot in snapshot chain from given snapshot.
      Throws:
      IOException
    • hasPreviousGlobalSnapshot

      public boolean hasPreviousGlobalSnapshot(UUID snapshotId) throws IOException
      Returns true if snapshot from given snapshotId has a previous snapshot entry in the global snapshot chain.
      Throws:
      IOException
    • previousGlobalSnapshot

      public UUID previousGlobalSnapshot(UUID snapshotId) throws IOException
      Get previous global snapshot in snapshot chain from given snapshot.
      Throws:
      IOException
    • hasNextPathSnapshot

      public boolean hasNextPathSnapshot(String snapshotPath, UUID snapshotId) throws IOException
      Returns true if snapshot path from given snapshotId has a next snapshot entry in the path snapshot chain.
      Throws:
      IOException
    • nextPathSnapshot

      public UUID nextPathSnapshot(String snapshotPath, UUID snapshotId) throws IOException
      Get next path snapshot in snapshot chain from given snapshot.
      Throws:
      IOException
    • hasPreviousPathSnapshot

      public boolean hasPreviousPathSnapshot(String snapshotPath, UUID snapshotId) throws IOException
      Returns true if snapshot path from given snapshotId has a previous snapshot entry in the path snapshot chain.
      Throws:
      IOException
    • previousPathSnapshot

      public UUID previousPathSnapshot(String snapshotPath, UUID snapshotId) throws IOException
      Get previous path snapshot in snapshot chain from given snapshot.
      Throws:
      IOException
    • getTableKey

      public String getTableKey(UUID snapshotId)
    • getSnapshotChainPath

      public LinkedHashMap<UUID,SnapshotChainInfo> getSnapshotChainPath(String path) throws IOException
      Throws:
      IOException
    • getGlobalSnapshotChain

      public Map<UUID,SnapshotChainInfo> getGlobalSnapshotChain() throws IOException
      Throws:
      IOException
    • getSnapshotChainByPath

      public Map<String,LinkedHashMap<UUID,SnapshotChainInfo>> getSnapshotChainByPath() throws IOException
      Throws:
      IOException
    • isSnapshotChainCorrupted

      public boolean isSnapshotChainCorrupted()