HDFS-6068. Disallow snapshot names that are also invalid directory names. Contributed by sathish
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1579004 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bd98fa152d
commit
02b25ce4ef
|
@ -415,6 +415,9 @@ Release 2.4.0 - UNRELEASED
|
||||||
HDFS-6090. Use MiniDFSCluster.Builder instead of deprecated constructors.
|
HDFS-6090. Use MiniDFSCluster.Builder instead of deprecated constructors.
|
||||||
(Akira AJISAKA via jing9)
|
(Akira AJISAKA via jing9)
|
||||||
|
|
||||||
|
HDFS-6068. Disallow snapshot names that are also invalid directory names.
|
||||||
|
(sathish via szetszwo)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HDFS-5790. LeaseManager.findPath is very slow when many leases need recovery
|
HDFS-5790. LeaseManager.findPath is very slow when many leases need recovery
|
||||||
|
|
|
@ -6933,6 +6933,12 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
if (snapshotName == null || snapshotName.isEmpty()) {
|
if (snapshotName == null || snapshotName.isEmpty()) {
|
||||||
snapshotName = Snapshot.generateDefaultSnapshotName();
|
snapshotName = Snapshot.generateDefaultSnapshotName();
|
||||||
}
|
}
|
||||||
|
if(snapshotName != null){
|
||||||
|
if (!DFSUtil.isValidNameForComponent(snapshotName)) {
|
||||||
|
throw new InvalidPathException("Invalid snapshot name: "
|
||||||
|
+ snapshotName);
|
||||||
|
}
|
||||||
|
}
|
||||||
dir.verifySnapshotName(snapshotName, snapshotRoot);
|
dir.verifySnapshotName(snapshotName, snapshotRoot);
|
||||||
dir.writeLock();
|
dir.writeLock();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -337,12 +337,11 @@ public class TestSnapshot {
|
||||||
hdfs.createSnapshot(dir, name1);
|
hdfs.createSnapshot(dir, name1);
|
||||||
fail("Exception expected when an illegal name is given");
|
fail("Exception expected when an illegal name is given");
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
String errorMsg = "\"" + HdfsConstants.DOT_SNAPSHOT_DIR
|
String errorMsg = "Invalid path name Invalid snapshot name: " + name1;
|
||||||
+ "\" is a reserved name.";
|
|
||||||
GenericTestUtils.assertExceptionContains(errorMsg, e);
|
GenericTestUtils.assertExceptionContains(errorMsg, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
String errorMsg = "Snapshot name cannot contain \"" + Path.SEPARATOR + "\"";
|
|
||||||
final String[] badNames = new String[] { "foo" + Path.SEPARATOR,
|
final String[] badNames = new String[] { "foo" + Path.SEPARATOR,
|
||||||
Path.SEPARATOR + "foo", Path.SEPARATOR, "foo" + Path.SEPARATOR + "bar" };
|
Path.SEPARATOR + "foo", Path.SEPARATOR, "foo" + Path.SEPARATOR + "bar" };
|
||||||
for (String badName : badNames) {
|
for (String badName : badNames) {
|
||||||
|
@ -350,6 +349,7 @@ public class TestSnapshot {
|
||||||
hdfs.createSnapshot(dir, badName);
|
hdfs.createSnapshot(dir, badName);
|
||||||
fail("Exception expected when an illegal name is given");
|
fail("Exception expected when an illegal name is given");
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
|
String errorMsg = "Invalid path name Invalid snapshot name: " + badName ;
|
||||||
GenericTestUtils.assertExceptionContains(errorMsg, e);
|
GenericTestUtils.assertExceptionContains(errorMsg, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue