You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by md...@apache.org on 2018/03/30 16:03:02 UTC
[1/3] hbase git commit: HBASE-20282 Clean up tooling docs/help
Repository: hbase
Updated Branches:
refs/heads/branch-2 4c9167a25 -> 468d4fcd7
refs/heads/branch-2.0 adcf0c066 -> 3ee8b0c75
refs/heads/master e60f34fdb -> d57001ee2
HBASE-20282 Clean up tooling docs/help
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/d57001ee
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/d57001ee
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/d57001ee
Branch: refs/heads/master
Commit: d57001ee2dcaae016822d34f101eb1b6fbb986ac
Parents: e60f34f
Author: Mike Drob <md...@apache.org>
Authored: Tue Mar 27 21:46:08 2018 -0700
Committer: Mike Drob <md...@apache.org>
Committed: Fri Mar 30 08:59:47 2018 -0700
----------------------------------------------------------------------
bin/hbase | 3 ++
.../hadoop/hbase/util/AbstractHBaseTool.java | 12 ++++-
.../apache/hadoop/hbase/util/LoadTestTool.java | 55 +++++++++++++++-----
.../org/apache/hadoop/hbase/tool/Canary.java | 5 +-
.../hadoop/hbase/util/RegionSplitter.java | 6 +--
src/main/asciidoc/_chapters/ops_mgt.adoc | 34 +++++++++++-
6 files changed, 92 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/d57001ee/bin/hbase
----------------------------------------------------------------------
diff --git a/bin/hbase b/bin/hbase
index 8dfa16a..8e37f5f 100755
--- a/bin/hbase
+++ b/bin/hbase
@@ -105,6 +105,7 @@ if [ $# = 0 ]; then
echo " version Print the version"
echo " backup Backup tables for recovery"
echo " restore Restore tables from existing backup image"
+ echo " regionsplitter Run RegionSplitter tool"
echo " CLASSNAME Run the class named CLASSNAME"
exit 1
fi
@@ -462,6 +463,8 @@ elif [ "$COMMAND" = "canary" ] ; then
HBASE_OPTS="$HBASE_OPTS $HBASE_CANARY_OPTS"
elif [ "$COMMAND" = "version" ] ; then
CLASS='org.apache.hadoop.hbase.util.VersionInfo'
+elif [ "$COMMAND" = "regionsplitter" ] ; then
+ CLASS='org.apache.hadoop.hbase.util.RegionSplitter'
else
CLASS=$COMMAND
fi
http://git-wip-us.apache.org/repos/asf/hbase/blob/d57001ee/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java
index d2d8dac..1dd7201 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java
@@ -137,7 +137,7 @@ public abstract class AbstractHBaseTool implements Tool, Configurable {
}
String[] remainingArgs = new String[argsList.size()];
argsList.toArray(remainingArgs);
- cmd = new DefaultParser().parse(options, remainingArgs);
+ cmd = newParser().parse(options, remainingArgs);
} catch (MissingOptionException e) {
LOG.error(e.getMessage());
LOG.error("Use -h or --help for usage instructions.");
@@ -160,6 +160,16 @@ public abstract class AbstractHBaseTool implements Tool, Configurable {
return ret;
}
+ /**
+ * Create the parser to use for parsing and validating the command line. Since commons-cli lacks
+ * the capability to validate arbitrary combination of options, it may be helpful to bake custom
+ * logic into a specialized parser implementation. See LoadTestTool for examples.
+ * @return a new parser specific to the current tool
+ */
+ protected CommandLineParser newParser() {
+ return new DefaultParser();
+ }
+
private boolean isHelpCommand(String[] args) throws ParseException {
Options helpOption = new Options().addOption(HELP_OPTION);
// this parses the command line but doesn't throw an exception on unknown options
http://git-wip-us.apache.org/repos/asf/hbase/blob/d57001ee/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java
----------------------------------------------------------------------
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java
index 51b2cf3..0f7c5c0 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java
@@ -58,7 +58,14 @@ import org.apache.hadoop.hbase.security.access.Permission;
import org.apache.hadoop.hbase.util.test.LoadTestDataGenerator;
import org.apache.hadoop.hbase.util.test.LoadTestDataGeneratorWithACL;
import org.apache.hadoop.util.ToolRunner;
+
+import org.apache.hbase.thirdparty.org.apache.commons.cli.AlreadySelectedException;
import org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine;
+import org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLineParser;
+import org.apache.hbase.thirdparty.org.apache.commons.cli.DefaultParser;
+import org.apache.hbase.thirdparty.org.apache.commons.cli.MissingOptionException;
+import org.apache.hbase.thirdparty.org.apache.commons.cli.Options;
+import org.apache.hbase.thirdparty.org.apache.commons.cli.ParseException;
/**
* A command-line utility that reads, writes, and verifies data. Unlike
@@ -359,6 +366,40 @@ public class LoadTestTool extends AbstractHBaseTool {
}
@Override
+ protected CommandLineParser newParser() {
+ // Commons-CLI lacks the capability to handle combinations of options, so we do it ourselves
+ // Validate in parse() to get helpful error messages instead of exploding in processOptions()
+ return new DefaultParser() {
+ @Override
+ public CommandLine parse(Options opts, String[] args, Properties props, boolean stop)
+ throws ParseException {
+ CommandLine cl = super.parse(opts, args, props, stop);
+
+ boolean isReadWriteUpdate = cmd.hasOption(OPT_READ)
+ || cmd.hasOption(OPT_WRITE)
+ || cmd.hasOption(OPT_UPDATE);
+ boolean isInitOnly = cmd.hasOption(OPT_INIT_ONLY);
+
+ if (!isInitOnly && !isReadWriteUpdate) {
+ throw new MissingOptionException("Must specify either -" + OPT_INIT_ONLY
+ + " or at least one of -" + OPT_READ + ", -" + OPT_WRITE + ", -" + OPT_UPDATE);
+ }
+
+ if (isInitOnly && isReadWriteUpdate) {
+ throw new AlreadySelectedException(OPT_INIT_ONLY + " cannot be specified with any of -"
+ + OPT_READ + ", -" + OPT_WRITE + ", -" + OPT_UPDATE);
+ }
+
+ if (isReadWriteUpdate && !cmd.hasOption(OPT_NUM_KEYS)) {
+ throw new MissingOptionException(OPT_NUM_KEYS + " must be specified in read/write mode.");
+ }
+
+ return cl;
+ }
+ };
+ }
+
+ @Override
protected void processOptions(CommandLine cmd) {
this.cmd = cmd;
@@ -381,21 +422,7 @@ public class LoadTestTool extends AbstractHBaseTool {
isInitOnly = cmd.hasOption(OPT_INIT_ONLY);
deferredLogFlush = cmd.hasOption(OPT_DEFERRED_LOG_FLUSH);
- if (!isWrite && !isRead && !isUpdate && !isInitOnly) {
- throw new IllegalArgumentException("Either -" + OPT_WRITE + " or " +
- "-" + OPT_UPDATE + " or -" + OPT_READ + " has to be specified");
- }
-
- if (isInitOnly && (isRead || isWrite || isUpdate)) {
- throw new IllegalArgumentException(OPT_INIT_ONLY + " cannot be specified with"
- + " either -" + OPT_WRITE + " or -" + OPT_UPDATE + " or -" + OPT_READ);
- }
-
if (!isInitOnly) {
- if (!cmd.hasOption(OPT_NUM_KEYS)) {
- throw new IllegalArgumentException(OPT_NUM_KEYS + " must be specified in "
- + "read or write mode");
- }
startKey = parseLong(cmd.getOptionValue(OPT_START_KEY,
String.valueOf(DEFAULT_START_KEY)), 0, Long.MAX_VALUE);
long numKeys = parseLong(cmd.getOptionValue(OPT_NUM_KEYS), 1,
http://git-wip-us.apache.org/repos/asf/hbase/blob/d57001ee/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java
index 31208c1..8875862 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java
@@ -837,9 +837,8 @@ public final class Canary implements Tool {
}
private void printUsageAndExit() {
- System.err.printf(
- "Usage: hbase %s [opts] [table1 [table2]...] | [regionserver1 [regionserver2]..]%n",
- getClass().getName());
+ System.err.println(
+ "Usage: hbase canary [opts] [table1 [table2]...] | [regionserver1 [regionserver2]..]");
System.err.println(" where [opts] are:");
System.err.println(" -help Show this help and exit.");
System.err.println(" -regionserver replace the table argument to regionserver,");
http://git-wip-us.apache.org/repos/asf/hbase/blob/d57001ee/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
index ff7e255..1b58634 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
@@ -331,7 +331,7 @@ public class RegionSplitter {
opt.addOption(null, "lastrow", true,
"Last Row in Table for Split Algorithm");
opt.addOption(null, "risky", false,
- "Skip verification steps to complete quickly."
+ "Skip verification steps to complete quickly. "
+ "STRONGLY DISCOURAGED for production systems. ");
CommandLine cmd = new GnuParser().parse(opt, args);
@@ -356,8 +356,8 @@ public class RegionSplitter {
boolean oneOperOnly = createTable ^ rollingSplit;
if (2 != cmd.getArgList().size() || !oneOperOnly || cmd.hasOption("h")) {
- new HelpFormatter().printHelp("RegionSplitter <TABLE> <SPLITALGORITHM>\n"+
- "SPLITALGORITHM is a java class name of a class implementing " +
+ new HelpFormatter().printHelp("bin/hbase regionsplitter <TABLE> <SPLITALGORITHM>\n"+
+ "SPLITALGORITHM is the java class name of a class implementing " +
"SplitAlgorithm, or one of the special strings HexStringSplit or " +
"DecimalStringSplit or UniformSplit, which are built-in split algorithms. " +
"HexStringSplit treats keys as hexadecimal ASCII, and " +
http://git-wip-us.apache.org/repos/asf/hbase/blob/d57001ee/src/main/asciidoc/_chapters/ops_mgt.adoc
----------------------------------------------------------------------
diff --git a/src/main/asciidoc/_chapters/ops_mgt.adoc b/src/main/asciidoc/_chapters/ops_mgt.adoc
index 928c377..bb2b41a 100644
--- a/src/main/asciidoc/_chapters/ops_mgt.adoc
+++ b/src/main/asciidoc/_chapters/ops_mgt.adoc
@@ -68,6 +68,7 @@ Some commands take arguments. Pass no args or -h for usage.
pe Run PerformanceEvaluation
ltt Run LoadTestTool
canary Run the Canary tool
+ regionsplitter Run the RegionSplitter tool
version Print the version
CLASSNAME Run the class named CLASSNAME
----
@@ -83,7 +84,7 @@ To see the usage, use the `--help` parameter.
----
$ ${HBASE_HOME}/bin/hbase canary -help
-Usage: hbase org.apache.hadoop.hbase.tool.Canary [opts] [table1 [table2]...] | [regionserver1 [regionserver2]..]
+Usage: hbase canary [opts] [table1 [table2]...] | [regionserver1 [regionserver2]..]
where [opts] are:
-help Show this help and exit.
-regionserver replace the table argument to regionserver,
@@ -276,6 +277,35 @@ property>
----
====
+=== RegionSplitter
+
+----
+usage: bin/hbase regionsplitter <TABLE> <SPLITALGORITHM>
+SPLITALGORITHM is the java class name of a class implementing
+ SplitAlgorithm, or one of the special strings
+ HexStringSplit or DecimalStringSplit or
+ UniformSplit, which are built-in split algorithms.
+ HexStringSplit treats keys as hexadecimal ASCII, and
+ DecimalStringSplit treats keys as decimal ASCII, and
+ UniformSplit treats keys as arbitrary bytes.
+ -c <region count> Create a new table with a pre-split number of
+ regions
+ -D <property=value> Override HBase Configuration Settings
+ -f <family:family:...> Column Families to create with new table.
+ Required with -c
+ --firstrow <arg> First Row in Table for Split Algorithm
+ -h Print this usage help
+ --lastrow <arg> Last Row in Table for Split Algorithm
+ -o <count> Max outstanding splits that have unfinished
+ major compactions
+ -r Perform a rolling split of an existing region
+ --risky Skip verification steps to complete
+ quickly. STRONGLY DISCOURAGED for production
+ systems.
+----
+
+For additional detail, see <<manual_region_splitting_decisions>>.
+
[[health.check]]
=== Health Checker
@@ -758,7 +788,7 @@ The PerformanceEvaluation tool has received many updates in recent HBase release
The `hbase ltt` command runs the LoadTestTool utility, which is used for testing.
-You must specify one of `-write`, `-update`, or `-read` as the first option.
+You must specify either `-init_only` or at least one of `-write`, `-update`, or `-read`.
For general usage instructions, pass the `-h` option.
The LoadTestTool has received many updates in recent HBase releases, including support for namespaces, support for tags, cell-level ACLS and visibility labels, testing security-related features, ability to specify the number of regions per server, tests for multi-get RPC calls, and tests relating to replication.
[3/3] hbase git commit: HBASE-20282 Clean up tooling docs/help
Posted by md...@apache.org.
HBASE-20282 Clean up tooling docs/help
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/3ee8b0c7
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/3ee8b0c7
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/3ee8b0c7
Branch: refs/heads/branch-2.0
Commit: 3ee8b0c75ba3060b36767a5ce2fe80af38e2018d
Parents: adcf0c0
Author: Mike Drob <md...@apache.org>
Authored: Tue Mar 27 21:46:08 2018 -0700
Committer: Mike Drob <md...@apache.org>
Committed: Fri Mar 30 09:02:44 2018 -0700
----------------------------------------------------------------------
bin/hbase | 3 ++
.../hadoop/hbase/util/AbstractHBaseTool.java | 12 ++++-
.../apache/hadoop/hbase/util/LoadTestTool.java | 55 +++++++++++++++-----
.../org/apache/hadoop/hbase/tool/Canary.java | 5 +-
.../hadoop/hbase/util/RegionSplitter.java | 6 +--
src/main/asciidoc/_chapters/ops_mgt.adoc | 35 ++++++++++++-
6 files changed, 93 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/3ee8b0c7/bin/hbase
----------------------------------------------------------------------
diff --git a/bin/hbase b/bin/hbase
index b371ffc..5087e59 100755
--- a/bin/hbase
+++ b/bin/hbase
@@ -103,6 +103,7 @@ if [ $# = 0 ]; then
echo " ltt Run LoadTestTool"
echo " canary Run the Canary tool"
echo " version Print the version"
+ echo " regionsplitter Run RegionSplitter tool"
echo " CLASSNAME Run the class named CLASSNAME"
exit 1
fi
@@ -456,6 +457,8 @@ elif [ "$COMMAND" = "canary" ] ; then
HBASE_OPTS="$HBASE_OPTS $HBASE_CANARY_OPTS"
elif [ "$COMMAND" = "version" ] ; then
CLASS='org.apache.hadoop.hbase.util.VersionInfo'
+elif [ "$COMMAND" = "regionsplitter" ] ; then
+ CLASS='org.apache.hadoop.hbase.util.RegionSplitter'
else
CLASS=$COMMAND
fi
http://git-wip-us.apache.org/repos/asf/hbase/blob/3ee8b0c7/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java
index d2d8dac..1dd7201 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java
@@ -137,7 +137,7 @@ public abstract class AbstractHBaseTool implements Tool, Configurable {
}
String[] remainingArgs = new String[argsList.size()];
argsList.toArray(remainingArgs);
- cmd = new DefaultParser().parse(options, remainingArgs);
+ cmd = newParser().parse(options, remainingArgs);
} catch (MissingOptionException e) {
LOG.error(e.getMessage());
LOG.error("Use -h or --help for usage instructions.");
@@ -160,6 +160,16 @@ public abstract class AbstractHBaseTool implements Tool, Configurable {
return ret;
}
+ /**
+ * Create the parser to use for parsing and validating the command line. Since commons-cli lacks
+ * the capability to validate arbitrary combination of options, it may be helpful to bake custom
+ * logic into a specialized parser implementation. See LoadTestTool for examples.
+ * @return a new parser specific to the current tool
+ */
+ protected CommandLineParser newParser() {
+ return new DefaultParser();
+ }
+
private boolean isHelpCommand(String[] args) throws ParseException {
Options helpOption = new Options().addOption(HELP_OPTION);
// this parses the command line but doesn't throw an exception on unknown options
http://git-wip-us.apache.org/repos/asf/hbase/blob/3ee8b0c7/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java
----------------------------------------------------------------------
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java
index 51b2cf3..0f7c5c0 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java
@@ -58,7 +58,14 @@ import org.apache.hadoop.hbase.security.access.Permission;
import org.apache.hadoop.hbase.util.test.LoadTestDataGenerator;
import org.apache.hadoop.hbase.util.test.LoadTestDataGeneratorWithACL;
import org.apache.hadoop.util.ToolRunner;
+
+import org.apache.hbase.thirdparty.org.apache.commons.cli.AlreadySelectedException;
import org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine;
+import org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLineParser;
+import org.apache.hbase.thirdparty.org.apache.commons.cli.DefaultParser;
+import org.apache.hbase.thirdparty.org.apache.commons.cli.MissingOptionException;
+import org.apache.hbase.thirdparty.org.apache.commons.cli.Options;
+import org.apache.hbase.thirdparty.org.apache.commons.cli.ParseException;
/**
* A command-line utility that reads, writes, and verifies data. Unlike
@@ -359,6 +366,40 @@ public class LoadTestTool extends AbstractHBaseTool {
}
@Override
+ protected CommandLineParser newParser() {
+ // Commons-CLI lacks the capability to handle combinations of options, so we do it ourselves
+ // Validate in parse() to get helpful error messages instead of exploding in processOptions()
+ return new DefaultParser() {
+ @Override
+ public CommandLine parse(Options opts, String[] args, Properties props, boolean stop)
+ throws ParseException {
+ CommandLine cl = super.parse(opts, args, props, stop);
+
+ boolean isReadWriteUpdate = cmd.hasOption(OPT_READ)
+ || cmd.hasOption(OPT_WRITE)
+ || cmd.hasOption(OPT_UPDATE);
+ boolean isInitOnly = cmd.hasOption(OPT_INIT_ONLY);
+
+ if (!isInitOnly && !isReadWriteUpdate) {
+ throw new MissingOptionException("Must specify either -" + OPT_INIT_ONLY
+ + " or at least one of -" + OPT_READ + ", -" + OPT_WRITE + ", -" + OPT_UPDATE);
+ }
+
+ if (isInitOnly && isReadWriteUpdate) {
+ throw new AlreadySelectedException(OPT_INIT_ONLY + " cannot be specified with any of -"
+ + OPT_READ + ", -" + OPT_WRITE + ", -" + OPT_UPDATE);
+ }
+
+ if (isReadWriteUpdate && !cmd.hasOption(OPT_NUM_KEYS)) {
+ throw new MissingOptionException(OPT_NUM_KEYS + " must be specified in read/write mode.");
+ }
+
+ return cl;
+ }
+ };
+ }
+
+ @Override
protected void processOptions(CommandLine cmd) {
this.cmd = cmd;
@@ -381,21 +422,7 @@ public class LoadTestTool extends AbstractHBaseTool {
isInitOnly = cmd.hasOption(OPT_INIT_ONLY);
deferredLogFlush = cmd.hasOption(OPT_DEFERRED_LOG_FLUSH);
- if (!isWrite && !isRead && !isUpdate && !isInitOnly) {
- throw new IllegalArgumentException("Either -" + OPT_WRITE + " or " +
- "-" + OPT_UPDATE + " or -" + OPT_READ + " has to be specified");
- }
-
- if (isInitOnly && (isRead || isWrite || isUpdate)) {
- throw new IllegalArgumentException(OPT_INIT_ONLY + " cannot be specified with"
- + " either -" + OPT_WRITE + " or -" + OPT_UPDATE + " or -" + OPT_READ);
- }
-
if (!isInitOnly) {
- if (!cmd.hasOption(OPT_NUM_KEYS)) {
- throw new IllegalArgumentException(OPT_NUM_KEYS + " must be specified in "
- + "read or write mode");
- }
startKey = parseLong(cmd.getOptionValue(OPT_START_KEY,
String.valueOf(DEFAULT_START_KEY)), 0, Long.MAX_VALUE);
long numKeys = parseLong(cmd.getOptionValue(OPT_NUM_KEYS), 1,
http://git-wip-us.apache.org/repos/asf/hbase/blob/3ee8b0c7/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java
index 31208c1..8875862 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java
@@ -837,9 +837,8 @@ public final class Canary implements Tool {
}
private void printUsageAndExit() {
- System.err.printf(
- "Usage: hbase %s [opts] [table1 [table2]...] | [regionserver1 [regionserver2]..]%n",
- getClass().getName());
+ System.err.println(
+ "Usage: hbase canary [opts] [table1 [table2]...] | [regionserver1 [regionserver2]..]");
System.err.println(" where [opts] are:");
System.err.println(" -help Show this help and exit.");
System.err.println(" -regionserver replace the table argument to regionserver,");
http://git-wip-us.apache.org/repos/asf/hbase/blob/3ee8b0c7/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
index ff7e255..1b58634 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
@@ -331,7 +331,7 @@ public class RegionSplitter {
opt.addOption(null, "lastrow", true,
"Last Row in Table for Split Algorithm");
opt.addOption(null, "risky", false,
- "Skip verification steps to complete quickly."
+ "Skip verification steps to complete quickly. "
+ "STRONGLY DISCOURAGED for production systems. ");
CommandLine cmd = new GnuParser().parse(opt, args);
@@ -356,8 +356,8 @@ public class RegionSplitter {
boolean oneOperOnly = createTable ^ rollingSplit;
if (2 != cmd.getArgList().size() || !oneOperOnly || cmd.hasOption("h")) {
- new HelpFormatter().printHelp("RegionSplitter <TABLE> <SPLITALGORITHM>\n"+
- "SPLITALGORITHM is a java class name of a class implementing " +
+ new HelpFormatter().printHelp("bin/hbase regionsplitter <TABLE> <SPLITALGORITHM>\n"+
+ "SPLITALGORITHM is the java class name of a class implementing " +
"SplitAlgorithm, or one of the special strings HexStringSplit or " +
"DecimalStringSplit or UniformSplit, which are built-in split algorithms. " +
"HexStringSplit treats keys as hexadecimal ASCII, and " +
http://git-wip-us.apache.org/repos/asf/hbase/blob/3ee8b0c7/src/main/asciidoc/_chapters/ops_mgt.adoc
----------------------------------------------------------------------
diff --git a/src/main/asciidoc/_chapters/ops_mgt.adoc b/src/main/asciidoc/_chapters/ops_mgt.adoc
index 3cb26fa..2767a77 100644
--- a/src/main/asciidoc/_chapters/ops_mgt.adoc
+++ b/src/main/asciidoc/_chapters/ops_mgt.adoc
@@ -66,6 +66,8 @@ Some commands take arguments. Pass no args or -h for usage.
mapredcp Dump CLASSPATH entries required by mapreduce
pe Run PerformanceEvaluation
ltt Run LoadTestTool
+ canary Run the Canary tool
+ regionsplitter Run the RegionSplitter tool
version Print the version
CLASSNAME Run the class named CLASSNAME
----
@@ -81,7 +83,7 @@ To see the usage, use the `--help` parameter.
----
$ ${HBASE_HOME}/bin/hbase canary -help
-Usage: bin/hbase org.apache.hadoop.hbase.tool.Canary [opts] [table1 [table2]...] | [regionserver1 [regionserver2]..]
+Usage: hbase canary [opts] [table1 [table2]...] | [regionserver1 [regionserver2]..]
where [opts] are:
-help Show this help and exit.
-regionserver replace the table argument to regionserver,
@@ -266,6 +268,35 @@ property>
----
====
+=== RegionSplitter
+
+----
+usage: bin/hbase regionsplitter <TABLE> <SPLITALGORITHM>
+SPLITALGORITHM is the java class name of a class implementing
+ SplitAlgorithm, or one of the special strings
+ HexStringSplit or DecimalStringSplit or
+ UniformSplit, which are built-in split algorithms.
+ HexStringSplit treats keys as hexadecimal ASCII, and
+ DecimalStringSplit treats keys as decimal ASCII, and
+ UniformSplit treats keys as arbitrary bytes.
+ -c <region count> Create a new table with a pre-split number of
+ regions
+ -D <property=value> Override HBase Configuration Settings
+ -f <family:family:...> Column Families to create with new table.
+ Required with -c
+ --firstrow <arg> First Row in Table for Split Algorithm
+ -h Print this usage help
+ --lastrow <arg> Last Row in Table for Split Algorithm
+ -o <count> Max outstanding splits that have unfinished
+ major compactions
+ -r Perform a rolling split of an existing region
+ --risky Skip verification steps to complete
+ quickly. STRONGLY DISCOURAGED for production
+ systems.
+----
+
+For additional detail, see <<manual_region_splitting_decisions>>.
+
[[health.check]]
=== Health Checker
@@ -752,7 +783,7 @@ The PerformanceEvaluation tool has received many updates in recent HBase release
The `hbase ltt` command is a shortcut provided to run the `org.apache.hadoop.hbase.util.LoadTestTool` utility, which is used for testing.
The `hbase ltt` command was introduced in HBase 0.98.4.
-You must specify either `-write` or `-update-read` as the first option.
+You must specify either `-init_only` or at least one of `-write`, `-update`, or `-read`.
For general usage instructions, pass the `-h` option.
To run LoadTestTool prior to HBase 0.98.4, issue the command +hbase
[2/3] hbase git commit: HBASE-20282 Clean up tooling docs/help
Posted by md...@apache.org.
HBASE-20282 Clean up tooling docs/help
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/468d4fcd
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/468d4fcd
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/468d4fcd
Branch: refs/heads/branch-2
Commit: 468d4fcd737bd70cea0de43215e680e0ac9d5e0c
Parents: 4c9167a
Author: Mike Drob <md...@apache.org>
Authored: Tue Mar 27 21:46:08 2018 -0700
Committer: Mike Drob <md...@apache.org>
Committed: Fri Mar 30 09:00:46 2018 -0700
----------------------------------------------------------------------
bin/hbase | 3 ++
.../hadoop/hbase/util/AbstractHBaseTool.java | 12 ++++-
.../apache/hadoop/hbase/util/LoadTestTool.java | 55 +++++++++++++++-----
.../org/apache/hadoop/hbase/tool/Canary.java | 5 +-
.../hadoop/hbase/util/RegionSplitter.java | 6 +--
src/main/asciidoc/_chapters/ops_mgt.adoc | 34 +++++++++++-
6 files changed, 92 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/468d4fcd/bin/hbase
----------------------------------------------------------------------
diff --git a/bin/hbase b/bin/hbase
index b371ffc..5087e59 100755
--- a/bin/hbase
+++ b/bin/hbase
@@ -103,6 +103,7 @@ if [ $# = 0 ]; then
echo " ltt Run LoadTestTool"
echo " canary Run the Canary tool"
echo " version Print the version"
+ echo " regionsplitter Run RegionSplitter tool"
echo " CLASSNAME Run the class named CLASSNAME"
exit 1
fi
@@ -456,6 +457,8 @@ elif [ "$COMMAND" = "canary" ] ; then
HBASE_OPTS="$HBASE_OPTS $HBASE_CANARY_OPTS"
elif [ "$COMMAND" = "version" ] ; then
CLASS='org.apache.hadoop.hbase.util.VersionInfo'
+elif [ "$COMMAND" = "regionsplitter" ] ; then
+ CLASS='org.apache.hadoop.hbase.util.RegionSplitter'
else
CLASS=$COMMAND
fi
http://git-wip-us.apache.org/repos/asf/hbase/blob/468d4fcd/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java
index d2d8dac..1dd7201 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java
@@ -137,7 +137,7 @@ public abstract class AbstractHBaseTool implements Tool, Configurable {
}
String[] remainingArgs = new String[argsList.size()];
argsList.toArray(remainingArgs);
- cmd = new DefaultParser().parse(options, remainingArgs);
+ cmd = newParser().parse(options, remainingArgs);
} catch (MissingOptionException e) {
LOG.error(e.getMessage());
LOG.error("Use -h or --help for usage instructions.");
@@ -160,6 +160,16 @@ public abstract class AbstractHBaseTool implements Tool, Configurable {
return ret;
}
+ /**
+ * Create the parser to use for parsing and validating the command line. Since commons-cli lacks
+ * the capability to validate arbitrary combination of options, it may be helpful to bake custom
+ * logic into a specialized parser implementation. See LoadTestTool for examples.
+ * @return a new parser specific to the current tool
+ */
+ protected CommandLineParser newParser() {
+ return new DefaultParser();
+ }
+
private boolean isHelpCommand(String[] args) throws ParseException {
Options helpOption = new Options().addOption(HELP_OPTION);
// this parses the command line but doesn't throw an exception on unknown options
http://git-wip-us.apache.org/repos/asf/hbase/blob/468d4fcd/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java
----------------------------------------------------------------------
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java
index 51b2cf3..0f7c5c0 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java
@@ -58,7 +58,14 @@ import org.apache.hadoop.hbase.security.access.Permission;
import org.apache.hadoop.hbase.util.test.LoadTestDataGenerator;
import org.apache.hadoop.hbase.util.test.LoadTestDataGeneratorWithACL;
import org.apache.hadoop.util.ToolRunner;
+
+import org.apache.hbase.thirdparty.org.apache.commons.cli.AlreadySelectedException;
import org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine;
+import org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLineParser;
+import org.apache.hbase.thirdparty.org.apache.commons.cli.DefaultParser;
+import org.apache.hbase.thirdparty.org.apache.commons.cli.MissingOptionException;
+import org.apache.hbase.thirdparty.org.apache.commons.cli.Options;
+import org.apache.hbase.thirdparty.org.apache.commons.cli.ParseException;
/**
* A command-line utility that reads, writes, and verifies data. Unlike
@@ -359,6 +366,40 @@ public class LoadTestTool extends AbstractHBaseTool {
}
@Override
+ protected CommandLineParser newParser() {
+ // Commons-CLI lacks the capability to handle combinations of options, so we do it ourselves
+ // Validate in parse() to get helpful error messages instead of exploding in processOptions()
+ return new DefaultParser() {
+ @Override
+ public CommandLine parse(Options opts, String[] args, Properties props, boolean stop)
+ throws ParseException {
+ CommandLine cl = super.parse(opts, args, props, stop);
+
+ boolean isReadWriteUpdate = cmd.hasOption(OPT_READ)
+ || cmd.hasOption(OPT_WRITE)
+ || cmd.hasOption(OPT_UPDATE);
+ boolean isInitOnly = cmd.hasOption(OPT_INIT_ONLY);
+
+ if (!isInitOnly && !isReadWriteUpdate) {
+ throw new MissingOptionException("Must specify either -" + OPT_INIT_ONLY
+ + " or at least one of -" + OPT_READ + ", -" + OPT_WRITE + ", -" + OPT_UPDATE);
+ }
+
+ if (isInitOnly && isReadWriteUpdate) {
+ throw new AlreadySelectedException(OPT_INIT_ONLY + " cannot be specified with any of -"
+ + OPT_READ + ", -" + OPT_WRITE + ", -" + OPT_UPDATE);
+ }
+
+ if (isReadWriteUpdate && !cmd.hasOption(OPT_NUM_KEYS)) {
+ throw new MissingOptionException(OPT_NUM_KEYS + " must be specified in read/write mode.");
+ }
+
+ return cl;
+ }
+ };
+ }
+
+ @Override
protected void processOptions(CommandLine cmd) {
this.cmd = cmd;
@@ -381,21 +422,7 @@ public class LoadTestTool extends AbstractHBaseTool {
isInitOnly = cmd.hasOption(OPT_INIT_ONLY);
deferredLogFlush = cmd.hasOption(OPT_DEFERRED_LOG_FLUSH);
- if (!isWrite && !isRead && !isUpdate && !isInitOnly) {
- throw new IllegalArgumentException("Either -" + OPT_WRITE + " or " +
- "-" + OPT_UPDATE + " or -" + OPT_READ + " has to be specified");
- }
-
- if (isInitOnly && (isRead || isWrite || isUpdate)) {
- throw new IllegalArgumentException(OPT_INIT_ONLY + " cannot be specified with"
- + " either -" + OPT_WRITE + " or -" + OPT_UPDATE + " or -" + OPT_READ);
- }
-
if (!isInitOnly) {
- if (!cmd.hasOption(OPT_NUM_KEYS)) {
- throw new IllegalArgumentException(OPT_NUM_KEYS + " must be specified in "
- + "read or write mode");
- }
startKey = parseLong(cmd.getOptionValue(OPT_START_KEY,
String.valueOf(DEFAULT_START_KEY)), 0, Long.MAX_VALUE);
long numKeys = parseLong(cmd.getOptionValue(OPT_NUM_KEYS), 1,
http://git-wip-us.apache.org/repos/asf/hbase/blob/468d4fcd/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java
index 31208c1..8875862 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java
@@ -837,9 +837,8 @@ public final class Canary implements Tool {
}
private void printUsageAndExit() {
- System.err.printf(
- "Usage: hbase %s [opts] [table1 [table2]...] | [regionserver1 [regionserver2]..]%n",
- getClass().getName());
+ System.err.println(
+ "Usage: hbase canary [opts] [table1 [table2]...] | [regionserver1 [regionserver2]..]");
System.err.println(" where [opts] are:");
System.err.println(" -help Show this help and exit.");
System.err.println(" -regionserver replace the table argument to regionserver,");
http://git-wip-us.apache.org/repos/asf/hbase/blob/468d4fcd/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
index ff7e255..1b58634 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
@@ -331,7 +331,7 @@ public class RegionSplitter {
opt.addOption(null, "lastrow", true,
"Last Row in Table for Split Algorithm");
opt.addOption(null, "risky", false,
- "Skip verification steps to complete quickly."
+ "Skip verification steps to complete quickly. "
+ "STRONGLY DISCOURAGED for production systems. ");
CommandLine cmd = new GnuParser().parse(opt, args);
@@ -356,8 +356,8 @@ public class RegionSplitter {
boolean oneOperOnly = createTable ^ rollingSplit;
if (2 != cmd.getArgList().size() || !oneOperOnly || cmd.hasOption("h")) {
- new HelpFormatter().printHelp("RegionSplitter <TABLE> <SPLITALGORITHM>\n"+
- "SPLITALGORITHM is a java class name of a class implementing " +
+ new HelpFormatter().printHelp("bin/hbase regionsplitter <TABLE> <SPLITALGORITHM>\n"+
+ "SPLITALGORITHM is the java class name of a class implementing " +
"SplitAlgorithm, or one of the special strings HexStringSplit or " +
"DecimalStringSplit or UniformSplit, which are built-in split algorithms. " +
"HexStringSplit treats keys as hexadecimal ASCII, and " +
http://git-wip-us.apache.org/repos/asf/hbase/blob/468d4fcd/src/main/asciidoc/_chapters/ops_mgt.adoc
----------------------------------------------------------------------
diff --git a/src/main/asciidoc/_chapters/ops_mgt.adoc b/src/main/asciidoc/_chapters/ops_mgt.adoc
index 33b6c5e..23d1485 100644
--- a/src/main/asciidoc/_chapters/ops_mgt.adoc
+++ b/src/main/asciidoc/_chapters/ops_mgt.adoc
@@ -68,6 +68,7 @@ Some commands take arguments. Pass no args or -h for usage.
pe Run PerformanceEvaluation
ltt Run LoadTestTool
canary Run the Canary tool
+ regionsplitter Run the RegionSplitter tool
version Print the version
CLASSNAME Run the class named CLASSNAME
----
@@ -83,7 +84,7 @@ To see the usage, use the `--help` parameter.
----
$ ${HBASE_HOME}/bin/hbase canary -help
-Usage: hbase org.apache.hadoop.hbase.tool.Canary [opts] [table1 [table2]...] | [regionserver1 [regionserver2]..]
+Usage: hbase canary [opts] [table1 [table2]...] | [regionserver1 [regionserver2]..]
where [opts] are:
-help Show this help and exit.
-regionserver replace the table argument to regionserver,
@@ -276,6 +277,35 @@ property>
----
====
+=== RegionSplitter
+
+----
+usage: bin/hbase regionsplitter <TABLE> <SPLITALGORITHM>
+SPLITALGORITHM is the java class name of a class implementing
+ SplitAlgorithm, or one of the special strings
+ HexStringSplit or DecimalStringSplit or
+ UniformSplit, which are built-in split algorithms.
+ HexStringSplit treats keys as hexadecimal ASCII, and
+ DecimalStringSplit treats keys as decimal ASCII, and
+ UniformSplit treats keys as arbitrary bytes.
+ -c <region count> Create a new table with a pre-split number of
+ regions
+ -D <property=value> Override HBase Configuration Settings
+ -f <family:family:...> Column Families to create with new table.
+ Required with -c
+ --firstrow <arg> First Row in Table for Split Algorithm
+ -h Print this usage help
+ --lastrow <arg> Last Row in Table for Split Algorithm
+ -o <count> Max outstanding splits that have unfinished
+ major compactions
+ -r Perform a rolling split of an existing region
+ --risky Skip verification steps to complete
+ quickly. STRONGLY DISCOURAGED for production
+ systems.
+----
+
+For additional detail, see <<manual_region_splitting_decisions>>.
+
[[health.check]]
=== Health Checker
@@ -758,7 +788,7 @@ The PerformanceEvaluation tool has received many updates in recent HBase release
The `hbase ltt` command runs the LoadTestTool utility, which is used for testing.
-You must specify one of `-write`, `-update`, or `-read` as the first option.
+You must specify either `-init_only` or at least one of `-write`, `-update`, or `-read`.
For general usage instructions, pass the `-h` option.
The LoadTestTool has received many updates in recent HBase releases, including support for namespaces, support for tags, cell-level ACLS and visibility labels, testing security-related features, ability to specify the number of regions per server, tests for multi-get RPC calls, and tests relating to replication.