Class DirectoryWithSnapshotFeature.DirectoryDiffList
java.lang.Object
org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature.DirectoryDiffList
- All Implemented Interfaces:
Iterable<DirectoryWithSnapshotFeature.DirectoryDiff>
- Enclosing class:
- DirectoryWithSnapshotFeature
A list of directory diffs.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasList()voidclear()Clear the list.final voiddeleteSnapshotDiff(INode.ReclaimContext reclaimContext, int snapshot, int prior, INodeDirectory currentINode) Delete a snapshot.intfindSnapshotDeleted(INode child) Find the corresponding snapshot whose deleted list contains the given inode.getDiffById(int snapshotId) final intgetDiffIndexById(int snapshotId) getLast()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, INodeDirectoryAttributes currentINode) booleanisEmpty()iterator()booleanremoveDeletedChild(INode child) Remove the given child from the deleted list, if there is any.booleanreplaceCreatedChild(INode oldChild, INode newChild) Replace the given child in the created/deleted list, if there is any.saveSelf2Snapshot(int latestSnapshotId, INodeDirectory currentINode, INodeDirectoryAttributes snapshotCopy) Save the snapshot copy to the latest snapshot.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
-
DirectoryDiffList
public DirectoryDiffList()
-
-
Method Details
-
replaceCreatedChild
Replace the given child in the created/deleted list, if there is any. -
removeDeletedChild
Remove the given child from the deleted list, if there is any. -
findSnapshotDeleted
Find the corresponding snapshot whose deleted list contains the given inode.- Returns:
- the id of the snapshot.
Snapshot.NO_SNAPSHOT_IDif the given inode is not in any of the snapshot.
-
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 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
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
-
toString
-