Class FileDiffList
java.lang.Object
org.apache.hadoop.hdfs.server.namenode.snapshot.FileDiffList
A list of FileDiffs for storing snapshot data.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasList()voidclear()Clear the list.final voiddeleteSnapshotDiff(INode.ReclaimContext reclaimContext, int snapshot, int prior, INodeFile currentINode) Delete a snapshot.voiddestroyAndCollectSnapshotBlocks(INode.BlocksMapUpdateInfo collectedBlocks) findEarlierSnapshotBlocks(int snapshotId) findLaterSnapshotBlocks(int snapshotId) final FileDiffgetDiffById(int snapshotId) final intgetDiffIndexById(int snapshotId) final FileDiffgetLast()final intfinal intgetPrior(int snapshotId) final intgetPrior(int anchorId, boolean exclusive) Find the latest snapshot before a given snapshot.final intgetSnapshotById(int snapshotId) Search for the snapshot whose id is 1) no less than the given id, and 2) most close to the given id.getSnapshotINode(int snapshotId, INodeFileAttributes currentINode) booleanisEmpty()iterator()saveSelf2Snapshot(int latestSnapshotId, INodeFile currentINode, INodeFileAttributes snapshotCopy) Save the snapshot copy to the latest snapshot.voidsaveSelf2Snapshot(int latestSnapshotId, INodeFile iNodeFile, INodeFileAttributes snapshotCopy, boolean withBlocks) toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
FileDiffList
public FileDiffList()
-
-
Method Details
-
destroyAndCollectSnapshotBlocks
-
saveSelf2Snapshot
public void saveSelf2Snapshot(int latestSnapshotId, INodeFile iNodeFile, INodeFileAttributes snapshotCopy, boolean withBlocks) -
findEarlierSnapshotBlocks
-
findLaterSnapshotBlocks
-
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, INodeFile 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 reclaimedsnapshot- The id of the snapshot to be deletedprior- The id of the snapshot taken before the to-be-deleted snapshotcurrentINode- the inode where the snapshot diff is deleted
-
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
-
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
- 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 FileDiff saveSelf2Snapshot(int latestSnapshotId, INodeFile currentINode, INodeFileAttributes snapshotCopy) Save the snapshot copy to the latest snapshot. -
iterator
-
toString
-