Class DirectorySnapshottableFeature
java.lang.Object
org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature
org.apache.hadoop.hdfs.server.namenode.snapshot.DirectorySnapshottableFeature
- All Implemented Interfaces:
INode.Feature
A directory with this feature is a snapshottable directory, where snapshots
can be taken. This feature extends
DirectoryWithSnapshotFeature, and
maintains extra information about all the snapshots taken on this directory.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature
DirectoryWithSnapshotFeature.DirectoryDiff, DirectoryWithSnapshotFeature.DirectoryDiffList -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddSnapshot(INodeDirectory snapshotRoot, SnapshotManager snapshotManager, String name, LeaseManager leaseManager, long now) Add a snapshot.voidvoiddumpTreeRecursively(INodeDirectory snapshotRoot, PrintWriter out, StringBuilder prefix, int snapshot) byte[][]findRenameTargetPath(INodeDirectory snapshotRoot, INodeReference.WithName wn, int snapshotId) We just found a deleted WithName node as the source of a rename operation.intgetSnapshot(byte[] snapshotName) getSnapshotById(int sid) getSnapshotByName(INodeDirectory snapshotRoot, String snapshotName) Find the snapshot matching the given name.intremoveSnapshot(INode.ReclaimContext reclaimContext, INodeDirectory snapshotRoot, String snapshotName, long now, SnapshotManager snapshotManager) Remove the snapshot with the given name fromsnapshotsByNames, and delete all the corresponding DirectoryDiff.voidrenameSnapshot(String path, String oldName, String newName, long mtime) Rename a snapshotvoidsetSnapshotQuota(int snapshotQuota) toString()Methods inherited from class org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature
addChild, cleanDirectory, clear, computeQuotaUsage4CurrentDirectory, destroyDstSubtree, getChild, getChildrenList, getDiffs, getLastSnapshotId, getSnapshotDirectory, removeChild, saveChild2Snapshot
-
Constructor Details
-
DirectorySnapshottableFeature
-
-
Method Details
-
getNumSnapshots
public int getNumSnapshots()- Returns:
- the number of existing snapshots.
-
getSnapshot
- Returns:
- the snapshot with the given name.
-
getSnapshotById
-
getSnapshotList
- Returns:
snapshotsByNamesas aReadOnlyList
-
renameSnapshot
public void renameSnapshot(String path, String oldName, String newName, long mtime) throws SnapshotException Rename a snapshot- Parameters:
path- The directory path where the snapshot was taken. Used for generating exception message.oldName- Old name of the snapshotnewName- New name the snapshot will be renamed tomtime- The snapshot modification time set by Time.now().- Throws:
SnapshotException- Throw SnapshotException when either the snapshot with the old name does not exist or a snapshot with the new name already exists
-
getSnapshotQuota
public int getSnapshotQuota() -
setSnapshotQuota
public void setSnapshotQuota(int snapshotQuota) -
addSnapshot
public Snapshot addSnapshot(INodeDirectory snapshotRoot, SnapshotManager snapshotManager, String name, LeaseManager leaseManager, long now) throws SnapshotException Add a snapshot.- Parameters:
snapshotRoot- Root of the snapshot.snapshotManager- SnapshotManager Instance.name- Name of the snapshot.leaseManager-- Throws:
SnapshotException- Throw SnapshotException when there is a snapshot with the same name already exists or snapshot quota exceeds
-
removeSnapshot
public Snapshot removeSnapshot(INode.ReclaimContext reclaimContext, INodeDirectory snapshotRoot, String snapshotName, long now, SnapshotManager snapshotManager) throws SnapshotException Remove the snapshot with the given name fromsnapshotsByNames, and delete all the corresponding DirectoryDiff.- Parameters:
reclaimContext- records blocks and inodes that need to be reclaimedsnapshotRoot- The directory where we take snapshotssnapshotName- The name of the snapshot to be removednow- The snapshot deletion time set by Time.now().- Returns:
- The removed snapshot. Null if no snapshot with the given name exists.
- Throws:
SnapshotException
-
computeContentSummary4Snapshot
public void computeContentSummary4Snapshot(BlockStoragePolicySuite bsps, ContentCounts counts) throws org.apache.hadoop.security.AccessControlException - Overrides:
computeContentSummary4Snapshotin classDirectoryWithSnapshotFeature- Throws:
org.apache.hadoop.security.AccessControlException
-
getSnapshotByName
public Snapshot getSnapshotByName(INodeDirectory snapshotRoot, String snapshotName) throws SnapshotException Find the snapshot matching the given name.- Parameters:
snapshotRoot- The directory where snapshots were taken.snapshotName- The name of the snapshot.- Returns:
- The corresponding snapshot. Null if snapshotName is null or empty.
- Throws:
SnapshotException- If snapshotName is not null or empty, but there is no snapshot matching the name.
-
findRenameTargetPath
public byte[][] findRenameTargetPath(INodeDirectory snapshotRoot, INodeReference.WithName wn, int snapshotId) We just found a deleted WithName node as the source of a rename operation. However, we should include it in our snapshot diff report as rename only if the rename target is also under the same snapshottable directory. -
toString
- Overrides:
toStringin classDirectoryWithSnapshotFeature
-
dumpTreeRecursively
@VisibleForTesting public void dumpTreeRecursively(INodeDirectory snapshotRoot, PrintWriter out, StringBuilder prefix, int snapshot)
-