HDFS-5360. Improvement of usage message of renameSnapshot and deleteSnapshot. Contributed by Shinichi Yamashita.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1532930 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b838776163
commit
e432b4fe5e
@ -68,7 +68,7 @@ protected void processOptions(LinkedList<String> args) throws IOException {
|
||||
throw new IllegalArgumentException("<snapshotDir> is missing.");
|
||||
}
|
||||
if (args.size() > 2) {
|
||||
throw new IllegalArgumentException("Too many arguements.");
|
||||
throw new IllegalArgumentException("Too many arguments.");
|
||||
}
|
||||
if (args.size() == 2) {
|
||||
snapshotName = args.removeLast();
|
||||
@ -110,7 +110,7 @@ protected void processPath(PathData item) throws IOException {
|
||||
@Override
|
||||
protected void processOptions(LinkedList<String> args) throws IOException {
|
||||
if (args.size() != 2) {
|
||||
throw new IOException("args number not 2: " + args.size());
|
||||
throw new IllegalArgumentException("Incorrect number of arguments.");
|
||||
}
|
||||
snapshotName = args.removeLast();
|
||||
}
|
||||
@ -150,7 +150,7 @@ protected void processPath(PathData item) throws IOException {
|
||||
@Override
|
||||
protected void processOptions(LinkedList<String> args) throws IOException {
|
||||
if (args.size() != 3) {
|
||||
throw new IOException("args number not 3: " + args.size());
|
||||
throw new IllegalArgumentException("Incorrect number of arguments.");
|
||||
}
|
||||
newName = args.removeLast();
|
||||
oldName = args.removeLast();
|
||||
|
@ -319,6 +319,9 @@ Release 2.3.0 - UNRELEASED
|
||||
HDFS-5130. Add test for snapshot related FsShell and DFSAdmin commands.
|
||||
(Binglin Chang via jing9)
|
||||
|
||||
HDFS-5360. Improvement of usage message of renameSnapshot and
|
||||
deleteSnapshot. (Shinichi Yamashita via wang)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
HDFS-5239. Allow FSNamesystem lock fairness to be configurable (daryn)
|
||||
|
@ -23,12 +23,15 @@
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.FileStatus;
|
||||
import org.apache.hadoop.fs.FsShell;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
||||
import org.apache.hadoop.hdfs.DFSTestUtil;
|
||||
@ -921,4 +924,29 @@ public void testRenameSnapshotDiff() throws Exception {
|
||||
subFile1Status = hdfs.getFileStatus(subFile1SCopy);
|
||||
assertEquals(REPLICATION_1, subFile1Status.getReplication());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteSnapshotCommandWithIllegalArguments() throws Exception {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
PrintStream psOut = new PrintStream(out);
|
||||
System.setOut(psOut);
|
||||
System.setErr(psOut);
|
||||
FsShell shell = new FsShell();
|
||||
shell.setConf(conf);
|
||||
|
||||
String[] argv1 = {"-deleteSnapshot", "/tmp"};
|
||||
int val = shell.run(argv1);
|
||||
assertTrue(val == -1);
|
||||
assertTrue(out.toString().contains(
|
||||
argv1[0] + ": Incorrect number of arguments."));
|
||||
out.reset();
|
||||
|
||||
String[] argv2 = {"-deleteSnapshot", "/tmp", "s1", "s2"};
|
||||
val = shell.run(argv2);
|
||||
assertTrue(val == -1);
|
||||
assertTrue(out.toString().contains(
|
||||
argv2[0] + ": Incorrect number of arguments."));
|
||||
psOut.close();
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
@ -22,10 +22,13 @@
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.FileStatus;
|
||||
import org.apache.hadoop.fs.FsShell;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.hdfs.DFSTestUtil;
|
||||
import org.apache.hadoop.hdfs.DistributedFileSystem;
|
||||
@ -226,4 +229,29 @@ public void testRenameWithIllegalName() throws Exception {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRenameSnapshotCommandWithIllegalArguments() throws Exception {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
PrintStream psOut = new PrintStream(out);
|
||||
System.setOut(psOut);
|
||||
System.setErr(psOut);
|
||||
FsShell shell = new FsShell();
|
||||
shell.setConf(conf);
|
||||
|
||||
String[] argv1 = {"-renameSnapshot", "/tmp", "s1"};
|
||||
int val = shell.run(argv1);
|
||||
assertTrue(val == -1);
|
||||
assertTrue(out.toString().contains(
|
||||
argv1[0] + ": Incorrect number of arguments."));
|
||||
out.reset();
|
||||
|
||||
String[] argv2 = {"-renameSnapshot", "/tmp", "s1", "s2", "s3"};
|
||||
val = shell.run(argv2);
|
||||
assertTrue(val == -1);
|
||||
assertTrue(out.toString().contains(
|
||||
argv2[0] + ": Incorrect number of arguments."));
|
||||
psOut.close();
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user