public class SnapshotManager extends Object implements SnapshotStats
FSNamesystem
lock in FSNamesystem
before calling
into SnapshotManager
methods.FSDirectory
lock for the SnapshotManager
methods
if necessary.Constructor and Description |
---|
SnapshotManager(FSDirectory fsdir) |
Modifier and Type | Method and Description |
---|---|
void |
addSnapshottable(INodeDirectorySnapshottable dir)
Add the given snapshottable directory to
snapshottables . |
String |
createSnapshot(String path,
String snapshotName)
Create a snapshot of the given path.
|
void |
deleteSnapshot(String path,
String snapshotName,
INode.BlocksMapUpdateInfo collectedBlocks,
List<INode> removedINodes)
Delete a snapshot for a snapshottable directory
|
INodeDirectorySnapshottable.SnapshotDiffInfo |
diff(String path,
String from,
String to)
Compute the 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() |
SnapshottableDirectoryStatus[] |
getSnapshottableDirListing(String userName)
List all the snapshottable directories that are owned by the current user.
|
INodeDirectorySnapshottable |
getSnapshottableRoot(String path)
Find the source root directory where the snapshot will be taken
for a given path.
|
Map<Integer,Snapshot> |
read(DataInput in,
FSImageFormat.Loader loader)
Read values of
snapshotCounter , numSnapshots , and
all snapshots from the DataInput |
void |
removeSnapshottable(List<INodeDirectorySnapshottable> toRemove)
Remove snapshottable directories from
snapshottables |
void |
renameSnapshot(String path,
String oldSnapshotName,
String newSnapshotName)
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 |
write(DataOutput out)
Write
snapshotCounter , numSnapshots ,
and all snapshots to the DataOutput. |
public SnapshotManager(FSDirectory fsdir)
public void setSnapshottable(String path, boolean checkNestedSnapshottable) throws IOException
IOException
public void addSnapshottable(INodeDirectorySnapshottable dir)
snapshottables
.public void removeSnapshottable(List<INodeDirectorySnapshottable> toRemove)
snapshottables
public void resetSnapshottable(String path) throws IOException
SnapshotException
- if there are snapshots in the directory.IOException
public INodeDirectorySnapshottable getSnapshottableRoot(String path) throws IOException
path
- The directory path where the snapshot will be taken.IOException
- Throw IOException when the given path does not lead to an
existing snapshottable directory.public String createSnapshot(String path, String snapshotName) throws IOException
path
- The directory path where the snapshot will be taken.snapshotName
- The name of the snapshot.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(String path, String snapshotName, INode.BlocksMapUpdateInfo collectedBlocks, List<INode> removedINodes) throws IOException
path
- Path to the directory where the snapshot was takensnapshotName
- Name of the snapshot to be deletedcollectedBlocks
- Used to collect information to update blocksMapIOException
public void renameSnapshot(String path, String oldSnapshotName, String newSnapshotName) throws IOException
path
- The directory path where the snapshot was takenoldSnapshotName
- Old name of the snapshotnewSnapshotName
- New name of the snapshotIOException
- 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()
getNumSnapshottableDirs
in interface SnapshotStats
public int getNumSnapshots()
getNumSnapshots
in interface SnapshotStats
public void write(DataOutput out) throws IOException
snapshotCounter
, numSnapshots
,
and all snapshots to the DataOutput.IOException
public Map<Integer,Snapshot> read(DataInput in, FSImageFormat.Loader loader) throws IOException
snapshotCounter
, numSnapshots
, and
all snapshots from the DataInputIOException
public SnapshottableDirectoryStatus[] getSnapshottableDirListing(String userName)
userName
- Current user name.SnapshottableDirectoryStatus
. If
userName
is null, return all the snapshottable dirs.public INodeDirectorySnapshottable.SnapshotDiffInfo diff(String path, String from, String to) throws IOException
IOException
public int getMaxSnapshotID()
Copyright © 2013 Apache Software Foundation. All rights reserved.