HDFS-10172. hdfs erasurecode command should remove the redundant -usage option. Contributed by Yuanbo Liu.

This commit is contained in:
Zhe Zhang 2016-05-10 15:20:17 -07:00
parent 6b1c1cb01c
commit 307db61aac
3 changed files with 40 additions and 5 deletions

View File

@ -50,12 +50,12 @@ public class FsShell extends Configured implements Tool {
private FileSystem fs;
private Trash trash;
private Help help;
protected CommandFactory commandFactory;
private final String usagePrefix =
"Usage: hadoop fs [generic options]";
private Tracer tracer;
static final String SHELL_HTRACE_PREFIX = "fs.shell.htrace.";
/**
@ -89,6 +89,13 @@ protected Trash getTrash() throws IOException {
}
return this.trash;
}
protected Help getHelp() throws IOException {
if (this.help == null){
this.help = new Help();
}
return this.help;
}
protected void init() throws IOException {
getConf().setQuietMode(true);
@ -98,9 +105,6 @@ protected void init() throws IOException {
commandFactory.addObject(new Usage(), "-usage");
registerCommands(commandFactory);
}
this.tracer = new Tracer.Builder("FsShell").
conf(TraceUtils.wrapHadoopConf(SHELL_HTRACE_PREFIX, getConf())).
build();
}
protected void registerCommands(CommandFactory factory) {
@ -296,6 +300,9 @@ private TableListing createOptionTableListing() {
public int run(String argv[]) throws Exception {
// initialize FsShell
init();
Tracer tracer = new Tracer.Builder("FsShell").
conf(TraceUtils.wrapHadoopConf(SHELL_HTRACE_PREFIX, getConf())).
build();
int exitCode = -1;
if (argv.length < 1) {
printUsage(System.err);

View File

@ -23,6 +23,8 @@
import org.apache.hadoop.hdfs.HdfsConfiguration;
import org.apache.hadoop.util.ToolRunner;
import java.io.IOException;
/**
* CLI for the erasure code encoding operations.
*/
@ -37,6 +39,16 @@ protected String getUsagePrefix() {
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
protected void registerCommands(CommandFactory factory) {
factory.registerCommands(ECCommand.class);
@ -47,4 +59,4 @@ public static void main(String[] args) throws Exception {
int res = ToolRunner.run(conf, new ECCli(), args);
System.exit(res);
}
}
}

View File

@ -31,6 +31,22 @@
-->
<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>
<description>help: help for erasure coding command</description>