HADOOP-7216. Add FsCommand.runAll() with deprecated annotation for the transition of Command base class improvement. Contributed by Daryn Sharp
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1090485 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a65753ddac
commit
7568e9c88c
@ -130,6 +130,9 @@ Trunk (unreleased changes)
|
||||
HADOOP-7019. Refactor build targets to enable faster cross project dev
|
||||
cycles. (Luke Lu via cos)
|
||||
|
||||
HADOOP-7216. Add FsCommand.runAll() with deprecated annotation for the
|
||||
transition of Command base class improvement. (Daryn Sharp via szetszwo)
|
||||
|
||||
Release 0.22.0 - Unreleased
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
@ -1954,11 +1954,9 @@ public int run(String argv[]) throws Exception {
|
||||
} else if ("-count".equals(cmd)) {
|
||||
// TODO: next two lines are a temporary crutch until this entire
|
||||
// block is overhauled
|
||||
LinkedList<String> args = new LinkedList<String>(Arrays.asList(argv));
|
||||
String cmdName = args.removeFirst();
|
||||
Count runner = ReflectionUtils.newInstance(Count.class, getConf());
|
||||
runner.setCommandName(cmdName); // TODO: will change with factory
|
||||
exitCode = runner.run(args);
|
||||
runner.setCommandName(cmd); // TODO: will change with factory
|
||||
exitCode = runner.run(Arrays.copyOfRange(argv, 1, argv.length));
|
||||
} else if ("-mkdir".equals(cmd)) {
|
||||
exitCode = doall(cmd, argv, i);
|
||||
} else if ("-touchz".equals(cmd)) {
|
||||
|
@ -21,6 +21,7 @@
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@ -124,11 +125,12 @@ public int runAll() {
|
||||
* Most commands will chose to implement just
|
||||
* {@link #processOptions(LinkedList)} and {@link #processPath(PathData)}
|
||||
*
|
||||
* @param args the list of command line arguments
|
||||
* @param argv the list of command line arguments
|
||||
* @return the exit code for the command
|
||||
* @throws IllegalArgumentException if called with invalid arguments
|
||||
*/
|
||||
public int run(LinkedList<String> args) {
|
||||
public int run(String...argv) {
|
||||
LinkedList<String> args = new LinkedList<String>(Arrays.asList(argv));
|
||||
try {
|
||||
processOptions(args);
|
||||
processArguments(expandArguments(args));
|
||||
|
@ -60,10 +60,7 @@ public Count() {
|
||||
public Count(String[] cmd, int pos, Configuration conf) {
|
||||
super(conf);
|
||||
setCommandName(NAME);
|
||||
LinkedList<String> parameters = new LinkedList<String>(Arrays.asList(cmd));
|
||||
parameters.subList(0, pos).clear();
|
||||
processOptions(parameters);
|
||||
this.args = parameters.toArray(new String[0]);
|
||||
this.args = Arrays.copyOfRange(cmd, pos, cmd.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,7 +47,16 @@ public String getCommandName() {
|
||||
return name.startsWith("-") ? name.substring(1) : name;
|
||||
}
|
||||
|
||||
// abstract method that normally is invoked by runall() which is
|
||||
// overridden below
|
||||
protected void run(Path path) throws IOException {
|
||||
throw new RuntimeException("not supposed to get here");
|
||||
}
|
||||
|
||||
/** @deprecated use {@link #run(String...argv)} */
|
||||
@Deprecated
|
||||
@Override
|
||||
public int runAll() {
|
||||
return run(args);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user