HDFS-4846. Clean up snapshot CLI commands output stacktrace for invalid arguments. Contributed by Jing Zhao
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1487647 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
973017cab7
commit
719034c12c
@ -607,6 +607,9 @@ Trunk (Unreleased)
|
|||||||
HDFS-4842. Identify the correct prior snapshot when deleting a
|
HDFS-4842. Identify the correct prior snapshot when deleting a
|
||||||
snapshot under a renamed subtree. (jing9)
|
snapshot under a renamed subtree. (jing9)
|
||||||
|
|
||||||
|
HDFS-4846. Clean up snapshot CLI commands output stacktrace for invalid
|
||||||
|
arguments. (Jing Zhao via brandonli)
|
||||||
|
|
||||||
Release 2.0.5-beta - UNRELEASED
|
Release 2.0.5-beta - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
@ -2125,11 +2125,7 @@ public SnapshottableDirectoryStatus[] getSnapshottableDirListing()
|
|||||||
*/
|
*/
|
||||||
public void allowSnapshot(String snapshotRoot) throws IOException {
|
public void allowSnapshot(String snapshotRoot) throws IOException {
|
||||||
checkOpen();
|
checkOpen();
|
||||||
try {
|
namenode.allowSnapshot(snapshotRoot);
|
||||||
namenode.allowSnapshot(snapshotRoot);
|
|
||||||
} catch(RemoteException re) {
|
|
||||||
throw re.unwrapRemoteException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2139,11 +2135,7 @@ public void allowSnapshot(String snapshotRoot) throws IOException {
|
|||||||
*/
|
*/
|
||||||
public void disallowSnapshot(String snapshotRoot) throws IOException {
|
public void disallowSnapshot(String snapshotRoot) throws IOException {
|
||||||
checkOpen();
|
checkOpen();
|
||||||
try {
|
namenode.disallowSnapshot(snapshotRoot);
|
||||||
namenode.disallowSnapshot(snapshotRoot);
|
|
||||||
} catch(RemoteException re) {
|
|
||||||
throw re.unwrapRemoteException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1433,7 +1433,7 @@ private static void checkSnapshot(INode target,
|
|||||||
INodeDirectorySnapshottable ssTargetDir =
|
INodeDirectorySnapshottable ssTargetDir =
|
||||||
(INodeDirectorySnapshottable) targetDir;
|
(INodeDirectorySnapshottable) targetDir;
|
||||||
if (ssTargetDir.getNumSnapshots() > 0) {
|
if (ssTargetDir.getNumSnapshots() > 0) {
|
||||||
throw new IOException("The direcotry " + ssTargetDir.getFullPathName()
|
throw new IOException("The directory " + ssTargetDir.getFullPathName()
|
||||||
+ " cannot be deleted since " + ssTargetDir.getFullPathName()
|
+ " cannot be deleted since " + ssTargetDir.getFullPathName()
|
||||||
+ " is snapshottable and already has snapshots");
|
+ " is snapshottable and already has snapshots");
|
||||||
} else {
|
} else {
|
||||||
|
@ -51,8 +51,13 @@ public static void main(String[] argv) throws IOException {
|
|||||||
}
|
}
|
||||||
DistributedFileSystem dfs = (DistributedFileSystem) fs;
|
DistributedFileSystem dfs = (DistributedFileSystem) fs;
|
||||||
|
|
||||||
SnapshottableDirectoryStatus[] stats = dfs.getSnapshottableDirListing();
|
try {
|
||||||
SnapshottableDirectoryStatus.print(stats, System.out);
|
SnapshottableDirectoryStatus[] stats = dfs.getSnapshottableDirListing();
|
||||||
|
SnapshottableDirectoryStatus.print(stats, System.out);
|
||||||
|
} catch (IOException e) {
|
||||||
|
String[] content = e.getLocalizedMessage().split("\n");
|
||||||
|
System.err.println("lsSnapshottableDir: " + content[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -82,9 +82,14 @@ public static void main(String[] argv) throws IOException {
|
|||||||
Path snapshotRoot = new Path(argv[0]);
|
Path snapshotRoot = new Path(argv[0]);
|
||||||
String fromSnapshot = getSnapshotName(argv[1]);
|
String fromSnapshot = getSnapshotName(argv[1]);
|
||||||
String toSnapshot = getSnapshotName(argv[2]);
|
String toSnapshot = getSnapshotName(argv[2]);
|
||||||
SnapshotDiffReport diffReport = dfs.getSnapshotDiffReport(snapshotRoot,
|
try {
|
||||||
fromSnapshot, toSnapshot);
|
SnapshotDiffReport diffReport = dfs.getSnapshotDiffReport(snapshotRoot,
|
||||||
System.out.println(diffReport.toString());
|
fromSnapshot, toSnapshot);
|
||||||
|
System.out.println(diffReport.toString());
|
||||||
|
} catch (IOException e) {
|
||||||
|
String[] content = e.getLocalizedMessage().split("\n");
|
||||||
|
System.err.println("snapshotDiff: " + content[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ public void testNestedSnapshots() throws Exception {
|
|||||||
try {
|
try {
|
||||||
hdfs.disallowSnapshot(rootPath);
|
hdfs.disallowSnapshot(rootPath);
|
||||||
fail("Expect snapshot exception when disallowing snapshot on root again");
|
fail("Expect snapshot exception when disallowing snapshot on root again");
|
||||||
} catch (SnapshotException e) {
|
} catch (RemoteException e) {
|
||||||
GenericTestUtils.assertExceptionContains(
|
GenericTestUtils.assertExceptionContains(
|
||||||
"Root is not a snapshottable directory", e);
|
"Root is not a snapshottable directory", e);
|
||||||
}
|
}
|
||||||
@ -149,14 +149,16 @@ public void testNestedSnapshots() throws Exception {
|
|||||||
try {
|
try {
|
||||||
hdfs.allowSnapshot(rootPath);
|
hdfs.allowSnapshot(rootPath);
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
} catch(SnapshotException se) {
|
} catch(RemoteException se) {
|
||||||
assertNestedSnapshotException(se, "subdirectory");
|
assertNestedSnapshotException(
|
||||||
|
(SnapshotException) se.unwrapRemoteException(), "subdirectory");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
hdfs.allowSnapshot(foo);
|
hdfs.allowSnapshot(foo);
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
} catch(SnapshotException se) {
|
} catch(RemoteException se) {
|
||||||
assertNestedSnapshotException(se, "subdirectory");
|
assertNestedSnapshotException(
|
||||||
|
(SnapshotException) se.unwrapRemoteException(), "subdirectory");
|
||||||
}
|
}
|
||||||
|
|
||||||
final Path sub1Bar = new Path(bar, "sub1");
|
final Path sub1Bar = new Path(bar, "sub1");
|
||||||
@ -165,14 +167,16 @@ public void testNestedSnapshots() throws Exception {
|
|||||||
try {
|
try {
|
||||||
hdfs.allowSnapshot(sub1Bar);
|
hdfs.allowSnapshot(sub1Bar);
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
} catch(SnapshotException se) {
|
} catch(RemoteException se) {
|
||||||
assertNestedSnapshotException(se, "ancestor");
|
assertNestedSnapshotException(
|
||||||
|
(SnapshotException) se.unwrapRemoteException(), "ancestor");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
hdfs.allowSnapshot(sub2Bar);
|
hdfs.allowSnapshot(sub2Bar);
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
} catch(SnapshotException se) {
|
} catch(RemoteException se) {
|
||||||
assertNestedSnapshotException(se, "ancestor");
|
assertNestedSnapshotException(
|
||||||
|
(SnapshotException) se.unwrapRemoteException(), "ancestor");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ public void testDeleteDirectoryWithSnapshot() throws Exception {
|
|||||||
|
|
||||||
// Deleting a snapshottable dir with snapshots should fail
|
// Deleting a snapshottable dir with snapshots should fail
|
||||||
exception.expect(RemoteException.class);
|
exception.expect(RemoteException.class);
|
||||||
String error = "The direcotry " + sub.toString()
|
String error = "The directory " + sub.toString()
|
||||||
+ " cannot be deleted since " + sub.toString()
|
+ " cannot be deleted since " + sub.toString()
|
||||||
+ " is snapshottable and already has snapshots";
|
+ " is snapshottable and already has snapshots";
|
||||||
exception.expectMessage(error);
|
exception.expectMessage(error);
|
||||||
|
Loading…
Reference in New Issue
Block a user