You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ae...@apache.org on 2016/05/13 18:00:48 UTC
[11/41] hadoop git commit: HDFS-10172. hdfs erasurecode command
should remove the redundant -usage option. Contributed by Yuanbo Liu.
HDFS-10172. hdfs erasurecode command should remove the redundant -usage option. Contributed by Yuanbo Liu.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/307db61a
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/307db61a
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/307db61a
Branch: refs/heads/HDFS-1312
Commit: 307db61aac9f4b51301ab9d4e74be7632c42d62f
Parents: 6b1c1cb
Author: Zhe Zhang <zh...@apache.org>
Authored: Tue May 10 15:20:17 2016 -0700
Committer: Zhe Zhang <zh...@apache.org>
Committed: Tue May 10 15:20:17 2016 -0700
----------------------------------------------------------------------
.../src/main/java/org/apache/hadoop/fs/FsShell.java | 15 +++++++++++----
.../apache/hadoop/hdfs/tools/erasurecode/ECCli.java | 14 +++++++++++++-
.../src/test/resources/testErasureCodingConf.xml | 16 ++++++++++++++++
3 files changed, 40 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/307db61a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java
index c0a3bea..1de9374 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java
@@ -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 @@ public class FsShell extends Configured implements Tool {
}
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 @@ public class FsShell extends Configured implements Tool {
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 @@ public class FsShell extends Configured implements Tool {
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);
http://git-wip-us.apache.org/repos/asf/hadoop/blob/307db61a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/erasurecode/ECCli.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/erasurecode/ECCli.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/erasurecode/ECCli.java
index c7ce714..48574d3 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/erasurecode/ECCli.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/erasurecode/ECCli.java
@@ -23,6 +23,8 @@ import org.apache.hadoop.fs.shell.CommandFactory;
import org.apache.hadoop.hdfs.HdfsConfiguration;
import org.apache.hadoop.util.ToolRunner;
+import java.io.IOException;
+
/**
* CLI for the erasure code encoding operations.
*/
@@ -38,6 +40,16 @@ public class ECCli extends FsShell {
}
@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 class ECCli extends FsShell {
int res = ToolRunner.run(conf, new ECCli(), args);
System.exit(res);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/307db61a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testErasureCodingConf.xml
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testErasureCodingConf.xml b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testErasureCodingConf.xml
index 1c782c3..f8ee973 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testErasureCodingConf.xml
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testErasureCodingConf.xml
@@ -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>
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org