HDFS-4650. When passing two non-existing snapshot names to snapshotDiff, it returns success if the names are the same. Contributed by Jing Zhao

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-2802@1476408 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tsz-wo Sze 2013-04-26 21:30:53 +00:00
parent 9da3865841
commit a5ae562d70
4 changed files with 18 additions and 5 deletions

View File

@ -312,3 +312,6 @@ Branch-2802 Snapshot (Unreleased)
HDFS-4650. Fix a bug in FSDirectory and add more unit tests for rename with
existence of snapshottable directories and snapshots. (Jing Zhao via
szetszwo)
HDFS-4650. When passing two non-existing snapshot names to snapshotDiff, it
returns success if the names are the same. (Jing Zhao via szetszwo)

View File

@ -371,7 +371,11 @@ public class INodeDirectorySnapshottable extends INodeDirectoryWithSnapshot {
SnapshotDiffInfo computeDiff(final String from, final String to)
throws SnapshotException {
Snapshot fromSnapshot = getSnapshotByName(from);
Snapshot toSnapshot = getSnapshotByName(to);
Snapshot toSnapshot = getSnapshotByName(to);
// if the start point is equal to the end point, return null
if (from.equals(to)) {
return null;
}
SnapshotDiffInfo diffs = new SnapshotDiffInfo(this, fromSnapshot,
toSnapshot);
computeDiffRecursively(this, new ArrayList<byte[]>(), diffs);

View File

@ -289,10 +289,6 @@ public class SnapshotManager implements SnapshotStats {
// both fromSnapshot and toSnapshot indicate the current tree
return null;
}
// if the start point is equal to the end point, return null
if (from.equals(to)) {
return null;
}
// Find the source root directory path where the snapshots were taken.
// All the check for path has been included in the valueOf method.

View File

@ -186,6 +186,16 @@ public class TestSnapshotDiffReport {
"Directory is not a snapshottable directory: " + subsub1, e);
}
final String invalidName = "invalid";
try {
hdfs.getSnapshotDiffReport(sub1, invalidName, invalidName);
fail("Expect exception when providing invalid snapshot name for diff report");
} catch (IOException e) {
GenericTestUtils.assertExceptionContains(
"Cannot find the snapshot of directory " + sub1 + " with name "
+ invalidName, e);
}
// diff between the same snapshot
SnapshotDiffReport report = hdfs.getSnapshotDiffReport(sub1, "s0", "s0");
System.out.println(report);