public class SnapshotManager extends Object implements SnapshotStatsMXBean
FSNamesystem
lock in FSNamesystem
before calling
into SnapshotManager
methods.FSDirectory
lock for the SnapshotManager
methods
if necessary.Modifier and Type | Field and Description |
---|---|
static org.slf4j.Logger |
LOG |
Constructor and Description |
---|
SnapshotManager(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.hdfs.server.namenode.FSDirectory fsdir) |
Modifier and Type | Method and Description |
---|---|
void |
addSnapshottable(INodeDirectory dir)
Add the given snapshottable directory to
snapshottables . |
void |
assertMarkedAsDeleted(INodesInPath iip,
String snapshotName) |
static org.apache.hadoop.fs.XAttr |
buildXAttr() |
INodeDirectory |
checkAndGetSnapshottableAncestorDir(INodesInPath iip)
Get the snapshot root directory for the given directory.
|
void |
clearSnapshottableDirs() |
String |
createSnapshot(org.apache.hadoop.hdfs.server.namenode.LeaseManager leaseManager,
INodesInPath iip,
String snapshotRoot,
String snapshotName,
long mtime)
Create a snapshot of the given path.
|
void |
deleteSnapshot(INodesInPath iip,
String snapshotName,
INode.ReclaimContext reclaimContext,
long now)
Delete a snapshot for a snapshottable directory
|
org.apache.hadoop.hdfs.protocol.SnapshotDiffReport |
diff(INodesInPath iip,
String snapshotPath,
String from,
String to)
Compute the difference between two snapshots of a directory, or between a
snapshot of the directory and its current tree.
|
org.apache.hadoop.hdfs.protocol.SnapshotDiffReportListing |
diff(INodesInPath iip,
String snapshotPath,
String from,
String to,
byte[] startPath,
int index,
int snapshotDiffReportLimit)
Compute the partial difference between two snapshots of a directory,
or between a snapshot of the directory and its current tree.
|
int |
getMaxSnapshotID()
Returns the maximum allowable snapshot ID based on the bit width of the
snapshot ID.
|
int |
getNumSnapshots() |
int |
getNumSnapshottableDirs() |
boolean |
getSkipCaptureAccessTimeOnlyChange() |
org.apache.hadoop.hdfs.protocol.SnapshotStatus[] |
getSnapshotListing(INodesInPath iip)
List all the snapshots under a snapshottable directory.
|
SnapshotInfo.Bean[] |
getSnapshots()
Return the list of snapshots
|
INodeDirectory |
getSnapshottableAncestorDir(INodesInPath iip) |
org.apache.hadoop.hdfs.protocol.SnapshottableDirectoryStatus.Bean[] |
getSnapshottableDirectories()
Return the list of snapshottable directories
|
org.apache.hadoop.hdfs.protocol.SnapshottableDirectoryStatus[] |
getSnapshottableDirListing(String userName)
List all the snapshottable directories that are owned by the current user.
|
INodeDirectory |
getSnapshottableRoot(INodesInPath iip)
Find the source root directory where the snapshot will be taken
for a given path.
|
void |
initThreadLocals() |
boolean |
isAllowNestedSnapshots() |
boolean |
isDescendantOfSnapshotRoot(INodeDirectory dir) |
boolean |
isSnapshotDeletionOrdered() |
Map<Integer,org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot> |
read(DataInput in,
FSImageFormat.Loader loader)
Read values of
snapshotCounter , numSnapshots , and
all snapshots from the DataInput |
void |
registerMXBean() |
void |
removeSnapshottable(List<INodeDirectory> toRemove)
Remove snapshottable directories from
snapshottables |
void |
renameSnapshot(INodesInPath iip,
String snapshotRoot,
String oldSnapshotName,
String newSnapshotName,
long now)
Rename the given snapshot
|
void |
resetSnapshottable(String path)
Set the given snapshottable directory to non-snapshottable.
|
void |
setSnapshottable(String path,
boolean checkNestedSnapshottable)
Set the given directory as a snapshottable directory.
|
void |
shutdown() |
static org.apache.hadoop.hdfs.protocol.SnapshottableDirectoryStatus.Bean |
toBean(INodeDirectory d) |
static SnapshotInfo.Bean |
toBean(org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot s) |
void |
write(DataOutput out)
Write
snapshotCounter , numSnapshots ,
and all snapshots to the DataOutput. |
public SnapshotManager(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.hdfs.server.namenode.FSDirectory fsdir) throws SnapshotException
SnapshotException
public void initThreadLocals()
public boolean isSnapshotDeletionOrdered()
public boolean getSkipCaptureAccessTimeOnlyChange()
public boolean isAllowNestedSnapshots()
public void setSnapshottable(String path, boolean checkNestedSnapshottable) throws IOException
IOException
public void addSnapshottable(INodeDirectory dir)
snapshottables
.public void removeSnapshottable(List<INodeDirectory> toRemove)
snapshottables
public void resetSnapshottable(String path) throws IOException
SnapshotException
- if there are snapshots in the directory.IOException
public INodeDirectory getSnapshottableRoot(INodesInPath iip) throws IOException
IOException
- Throw IOException when the given path does not lead to an
existing snapshottable directory.public void assertMarkedAsDeleted(INodesInPath iip, String snapshotName) throws IOException
IOException
public INodeDirectory checkAndGetSnapshottableAncestorDir(INodesInPath iip) throws IOException
iip
- INodesInPath for the directory to get snapshot root.IOException
public INodeDirectory getSnapshottableAncestorDir(INodesInPath iip) throws IOException
IOException
public boolean isDescendantOfSnapshotRoot(INodeDirectory dir)
public String createSnapshot(org.apache.hadoop.hdfs.server.namenode.LeaseManager leaseManager, INodesInPath iip, String snapshotRoot, String snapshotName, long mtime) throws IOException
iip
- the INodes resolved from the snapshottable directory's pathsnapshotName
- The name of the snapshot.mtime
- is the snapshot creation time set by Time.now().IOException
- Throw IOException when 1) the given path does not lead to an
existing snapshottable directory, and/or 2) there exists a
snapshot with the given name for the directory, and/or 3)
snapshot number exceeds quotapublic void deleteSnapshot(INodesInPath iip, String snapshotName, INode.ReclaimContext reclaimContext, long now) throws IOException
snapshotName
- Name of the snapshot to be deletednow
- is the snapshot deletion time set by Time.now().reclaimContext
- Used to collect information to reclaim blocks
and inodesIOException
public void renameSnapshot(INodesInPath iip, String snapshotRoot, String oldSnapshotName, String newSnapshotName, long now) throws IOException
oldSnapshotName
- Old name of the snapshotnewSnapshotName
- New name of the snapshotnow
- is the snapshot modification time set by Time.now().IOException
- Throw IOException when 1) the given path does not lead to an
existing snapshottable directory, and/or 2) the snapshot with the
old name does not exist for the directory, and/or 3) there exists
a snapshot with the new name for the directorypublic int getNumSnapshottableDirs()
public int getNumSnapshots()
public void write(DataOutput out) throws IOException
snapshotCounter
, numSnapshots
,
and all snapshots to the DataOutput.IOException
public Map<Integer,org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot> read(DataInput in, FSImageFormat.Loader loader) throws IOException
snapshotCounter
, numSnapshots
, and
all snapshots from the DataInputIOException
public org.apache.hadoop.hdfs.protocol.SnapshottableDirectoryStatus[] getSnapshottableDirListing(String userName)
userName
- Current user name.SnapshottableDirectoryStatus
. If
userName
is null, return all the snapshottable dirs.public org.apache.hadoop.hdfs.protocol.SnapshotStatus[] getSnapshotListing(INodesInPath iip) throws IOException
IOException
public org.apache.hadoop.hdfs.protocol.SnapshotDiffReport diff(INodesInPath iip, String snapshotPath, String from, String to) throws IOException
IOException
public org.apache.hadoop.hdfs.protocol.SnapshotDiffReportListing diff(INodesInPath iip, String snapshotPath, String from, String to, byte[] startPath, int index, int snapshotDiffReportLimit) throws IOException
IOException
public void clearSnapshottableDirs()
public int getMaxSnapshotID()
public static org.apache.hadoop.fs.XAttr buildXAttr()
public void registerMXBean()
public void shutdown()
public org.apache.hadoop.hdfs.protocol.SnapshottableDirectoryStatus.Bean[] getSnapshottableDirectories()
SnapshotStatsMXBean
getSnapshottableDirectories
in interface SnapshotStatsMXBean
public SnapshotInfo.Bean[] getSnapshots()
SnapshotStatsMXBean
getSnapshots
in interface SnapshotStatsMXBean
public static org.apache.hadoop.hdfs.protocol.SnapshottableDirectoryStatus.Bean toBean(INodeDirectory d)
public static SnapshotInfo.Bean toBean(org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot s)
Copyright © 2008–2024 Apache Software Foundation. All rights reserved.