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 ww...@apache.org on 2017/09/24 01:39:41 UTC
hadoop git commit: HDFS-12503. Ozone: some UX improvements to
oz_debug. Contributed by Weiwei Yang.
Repository: hadoop
Updated Branches:
refs/heads/HDFS-7240 ee4f021fb -> 97ff55eab
HDFS-12503. Ozone: some UX improvements to oz_debug. Contributed by Weiwei Yang.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/97ff55ea
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/97ff55ea
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/97ff55ea
Branch: refs/heads/HDFS-7240
Commit: 97ff55eab1c20c1266075c6a7505b5cf3098bfff
Parents: ee4f021
Author: Weiwei Yang <ww...@apache.org>
Authored: Sun Sep 24 09:39:23 2017 +0800
Committer: Weiwei Yang <ww...@apache.org>
Committed: Sun Sep 24 09:39:23 2017 +0800
----------------------------------------------------------------------
.../org/apache/hadoop/ozone/scm/cli/SQLCLI.java | 44 ++++++++++++++++----
1 file changed, 36 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/97ff55ea/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/SQLCLI.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/SQLCLI.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/SQLCLI.java
index 4a8121d..849efdd 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/SQLCLI.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/SQLCLI.java
@@ -23,6 +23,7 @@ import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
+import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.ParseException;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.hdfs.DFSUtil;
@@ -67,11 +68,12 @@ import static org.apache.hadoop.ozone.OzoneConsts.NODEPOOL_DB;
import static org.apache.hadoop.ozone.OzoneConsts.OPEN_CONTAINERS_DB;
/**
- * This is the CLI that can be use to convert a levelDB into a sqlite DB file.
+ * This is the CLI that can be use to convert an ozone metadata DB into
+ * a sqlite DB file.
*
* NOTE: user should use this CLI in an offline fashion. Namely, this should not
- * be used to convert a levelDB that is currently being used by Ozone. Instead,
- * this should be used to debug and diagnosis closed levelDB instances.
+ * be used to convert a DB that is currently being used by Ozone. Instead,
+ * this should be used to debug and diagnosis closed DB instances.
*
*/
public class SQLCLI extends Configured implements Tool {
@@ -213,11 +215,18 @@ public class SQLCLI extends Configured implements Tool {
@SuppressWarnings("static-access")
private Options getOptions() {
Options allOptions = new Options();
+ Option helpOpt = OptionBuilder
+ .hasArg(false)
+ .withLongOpt("help")
+ .withDescription("display help message")
+ .create("h");
+ allOptions.addOption(helpOpt);
+
Option dbPathOption = OptionBuilder
- .withArgName("levelDB path")
+ .withArgName("DB path")
.withLongOpt("dbPath")
.hasArgs(1)
- .withDescription("specify levelDB path")
+ .withDescription("specify DB path")
.create("p");
allOptions.addOption(dbPathOption);
@@ -225,22 +234,33 @@ public class SQLCLI extends Configured implements Tool {
.withArgName("output path")
.withLongOpt("outPath")
.hasArgs(1)
- .withDescription("specify output path")
+ .withDescription("specify output DB file path")
.create("o");
allOptions.addOption(outPathOption);
return allOptions;
}
+ public void displayHelp() {
+ HelpFormatter helpFormatter = new HelpFormatter();
+ Options allOpts = getOptions();
+ helpFormatter.printHelp("hdfs oz_debug -p <DB path>"
+ + " -o <Output DB file path>", allOpts);
+ }
+
@Override
public int run(String[] args) throws Exception {
CommandLine commandLine = parseArgs(args);
+ if (commandLine.hasOption("help")) {
+ displayHelp();
+ return 0;
+ }
if (!commandLine.hasOption("p") || !commandLine.hasOption("o")) {
- LOG.error("Require dbPath option(-p) AND outPath option (-o)");
+ displayHelp();
return -1;
}
String value = commandLine.getOptionValue("p");
- LOG.info("levelDB path {}", value);
+ LOG.info("DB path {}", value);
// the value is supposed to be an absolute path to a container file
Path dbPath = Paths.get(value);
if (!Files.exists(dbPath)) {
@@ -260,6 +280,11 @@ public class SQLCLI extends Configured implements Tool {
return -1;
}
+ if (outPath.toFile().isDirectory()) {
+ LOG.error("The db output path should be a file instead of a directory");
+ return -1;
+ }
+
Path outParentPath = outPath.getParent();
if (outParentPath != null) {
if (!Files.exists(outParentPath)) {
@@ -689,6 +714,9 @@ public class SQLCLI extends Configured implements Tool {
ToolRunner.run(shell, args);
} catch (Exception ex) {
LOG.error(ex.toString());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Command execution failed", ex);
+ }
res = 1;
}
System.exit(res);
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org