HDFS-10172. hdfs erasurecode command should remove the redundant -usage option. Contributed by Yuanbo Liu.
This commit is contained in:
parent
6b1c1cb01c
commit
307db61aac
|
@ -50,12 +50,12 @@ public class FsShell extends Configured implements Tool {
|
||||||
|
|
||||||
private FileSystem fs;
|
private FileSystem fs;
|
||||||
private Trash trash;
|
private Trash trash;
|
||||||
|
private Help help;
|
||||||
protected CommandFactory commandFactory;
|
protected CommandFactory commandFactory;
|
||||||
|
|
||||||
private final String usagePrefix =
|
private final String usagePrefix =
|
||||||
"Usage: hadoop fs [generic options]";
|
"Usage: hadoop fs [generic options]";
|
||||||
|
|
||||||
private Tracer tracer;
|
|
||||||
static final String SHELL_HTRACE_PREFIX = "fs.shell.htrace.";
|
static final String SHELL_HTRACE_PREFIX = "fs.shell.htrace.";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,6 +89,13 @@ public class FsShell extends Configured implements Tool {
|
||||||
}
|
}
|
||||||
return this.trash;
|
return this.trash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Help getHelp() throws IOException {
|
||||||
|
if (this.help == null){
|
||||||
|
this.help = new Help();
|
||||||
|
}
|
||||||
|
return this.help;
|
||||||
|
}
|
||||||
|
|
||||||
protected void init() throws IOException {
|
protected void init() throws IOException {
|
||||||
getConf().setQuietMode(true);
|
getConf().setQuietMode(true);
|
||||||
|
@ -98,9 +105,6 @@ public class FsShell extends Configured implements Tool {
|
||||||
commandFactory.addObject(new Usage(), "-usage");
|
commandFactory.addObject(new Usage(), "-usage");
|
||||||
registerCommands(commandFactory);
|
registerCommands(commandFactory);
|
||||||
}
|
}
|
||||||
this.tracer = new Tracer.Builder("FsShell").
|
|
||||||
conf(TraceUtils.wrapHadoopConf(SHELL_HTRACE_PREFIX, getConf())).
|
|
||||||
build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void registerCommands(CommandFactory factory) {
|
protected void registerCommands(CommandFactory factory) {
|
||||||
|
@ -296,6 +300,9 @@ public class FsShell extends Configured implements Tool {
|
||||||
public int run(String argv[]) throws Exception {
|
public int run(String argv[]) throws Exception {
|
||||||
// initialize FsShell
|
// initialize FsShell
|
||||||
init();
|
init();
|
||||||
|
Tracer tracer = new Tracer.Builder("FsShell").
|
||||||
|
conf(TraceUtils.wrapHadoopConf(SHELL_HTRACE_PREFIX, getConf())).
|
||||||
|
build();
|
||||||
int exitCode = -1;
|
int exitCode = -1;
|
||||||
if (argv.length < 1) {
|
if (argv.length < 1) {
|
||||||
printUsage(System.err);
|
printUsage(System.err);
|
||||||
|
|
|
@ -23,6 +23,8 @@ import org.apache.hadoop.fs.shell.CommandFactory;
|
||||||
import org.apache.hadoop.hdfs.HdfsConfiguration;
|
import org.apache.hadoop.hdfs.HdfsConfiguration;
|
||||||
import org.apache.hadoop.util.ToolRunner;
|
import org.apache.hadoop.util.ToolRunner;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CLI for the erasure code encoding operations.
|
* CLI for the erasure code encoding operations.
|
||||||
*/
|
*/
|
||||||
|
@ -37,6 +39,16 @@ public class ECCli extends FsShell {
|
||||||
return usagePrefix;
|
return usagePrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void init() throws IOException {
|
||||||
|
getConf().setQuietMode(true);
|
||||||
|
if (commandFactory == null) {
|
||||||
|
commandFactory = new CommandFactory(getConf());
|
||||||
|
commandFactory.addObject(getHelp(), "-help");
|
||||||
|
registerCommands(commandFactory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerCommands(CommandFactory factory) {
|
protected void registerCommands(CommandFactory factory) {
|
||||||
factory.registerCommands(ECCommand.class);
|
factory.registerCommands(ECCommand.class);
|
||||||
|
@ -47,4 +59,4 @@ public class ECCli extends FsShell {
|
||||||
int res = ToolRunner.run(conf, new ECCli(), args);
|
int res = ToolRunner.run(conf, new ECCli(), args);
|
||||||
System.exit(res);
|
System.exit(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,22 @@
|
||||||
-->
|
-->
|
||||||
<tests>
|
<tests>
|
||||||
|
|
||||||
|
<!-- Test usage options -->
|
||||||
|
<test>
|
||||||
|
<description>usage: help for erasure coding command</description>
|
||||||
|
<test-commands>
|
||||||
|
<ec-admin-command>-usage</ec-admin-command>
|
||||||
|
</test-commands>
|
||||||
|
<cleanup-commands>
|
||||||
|
</cleanup-commands>
|
||||||
|
<comparators>
|
||||||
|
<comparator>
|
||||||
|
<type>SubstringComparator</type>
|
||||||
|
<expected-output>-usage: Unknown command</expected-output>
|
||||||
|
</comparator>
|
||||||
|
</comparators>
|
||||||
|
</test>
|
||||||
|
|
||||||
<!-- Test help options -->
|
<!-- Test help options -->
|
||||||
<test>
|
<test>
|
||||||
<description>help: help for erasure coding command</description>
|
<description>help: help for erasure coding command</description>
|
||||||
|
|
Loading…
Reference in New Issue