Merge r1601199 from trunk: HDFS-6500. Snapshot shouldn't be removed silently after renaming to an existing snapshot. (Contributed by Nicholas SZE)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1601200 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d5379b29a2
commit
d678a9ecf9
|
@ -333,6 +333,9 @@ Release 2.5.0 - UNRELEASED
|
|||
HDFS-6497. Make TestAvailableSpaceVolumeChoosingPolicy deterministic
|
||||
(cmccabe)
|
||||
|
||||
HDFS-6500. Snapshot shouldn't be removed silently after renaming to an
|
||||
existing snapshot. (Nicholas SZE via junping_du)
|
||||
|
||||
Release 2.4.1 - UNRELEASED
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
|
|
@ -234,7 +234,7 @@ public class INodeDirectorySnapshottable extends INodeDirectory {
|
|||
* name does not exist or a snapshot with the new name already
|
||||
* exists
|
||||
*/
|
||||
public void renameSnapshot(String path, String oldName, String newName)
|
||||
void renameSnapshot(String path, String oldName, String newName)
|
||||
throws SnapshotException {
|
||||
if (newName.equals(oldName)) {
|
||||
return;
|
||||
|
@ -246,7 +246,7 @@ public class INodeDirectorySnapshottable extends INodeDirectory {
|
|||
} else {
|
||||
final byte[] newNameBytes = DFSUtil.string2Bytes(newName);
|
||||
int indexOfNew = searchSnapshot(newNameBytes);
|
||||
if (indexOfNew > 0) {
|
||||
if (indexOfNew >= 0) {
|
||||
throw new SnapshotException("The snapshot " + newName
|
||||
+ " already exists for directory " + path);
|
||||
}
|
||||
|
|
|
@ -186,6 +186,17 @@ public class TestSnapshotCommands {
|
|||
FsShellRun("-ls /sub1/.snapshot", 0, "/sub1/.snapshot/sn.rename");
|
||||
FsShellRun("-ls /sub1/.snapshot/sn.rename", 0, "/sub1/.snapshot/sn.rename/sub1sub1");
|
||||
FsShellRun("-ls /sub1/.snapshot/sn.rename", 0, "/sub1/.snapshot/sn.rename/sub1sub2");
|
||||
|
||||
//try renaming from a non-existing snapshot
|
||||
FsShellRun("-renameSnapshot /sub1 sn.nonexist sn.rename", 1,
|
||||
"renameSnapshot: The snapshot sn.nonexist does not exist for directory /sub1");
|
||||
|
||||
//try renaming to existing snapshots
|
||||
FsShellRun("-createSnapshot /sub1 sn.new");
|
||||
FsShellRun("-renameSnapshot /sub1 sn.new sn.rename", 1,
|
||||
"renameSnapshot: The snapshot sn.rename already exists for directory /sub1");
|
||||
FsShellRun("-renameSnapshot /sub1 sn.rename sn.new", 1,
|
||||
"renameSnapshot: The snapshot sn.new already exists for directory /sub1");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue