HBASE-20376 RowCounter and CellCounter documentations are incorrect

This commit is contained in:
Peter Somogyi 2018-04-12 10:05:17 +02:00
parent b0701434e3
commit e51ced4f17
4 changed files with 45 additions and 36 deletions

View File

@ -104,6 +104,8 @@ if [ $# = 0 ]; then
echo " canary Run the Canary tool" echo " canary Run the Canary tool"
echo " version Print the version" echo " version Print the version"
echo " regionsplitter Run RegionSplitter tool" echo " regionsplitter Run RegionSplitter tool"
echo " rowcounter Run RowCounter tool"
echo " cellcounter Run CellCounter tool"
echo " CLASSNAME Run the class named CLASSNAME" echo " CLASSNAME Run the class named CLASSNAME"
exit 1 exit 1
fi fi
@ -459,6 +461,10 @@ elif [ "$COMMAND" = "version" ] ; then
CLASS='org.apache.hadoop.hbase.util.VersionInfo' CLASS='org.apache.hadoop.hbase.util.VersionInfo'
elif [ "$COMMAND" = "regionsplitter" ] ; then elif [ "$COMMAND" = "regionsplitter" ] ; then
CLASS='org.apache.hadoop.hbase.util.RegionSplitter' CLASS='org.apache.hadoop.hbase.util.RegionSplitter'
elif [ "$COMMAND" = "rowcounter" ] ; then
CLASS='org.apache.hadoop.hbase.mapreduce.RowCounter'
elif [ "$COMMAND" = "cellcounter" ] ; then
CLASS='org.apache.hadoop.hbase.mapreduce.CellCounter'
else else
CLASS=$COMMAND CLASS=$COMMAND
fi fi

View File

@ -292,31 +292,36 @@ public class CellCounter extends Configured implements Tool {
@Override @Override
public int run(String[] args) throws Exception { public int run(String[] args) throws Exception {
if (args.length < 2) { if (args.length < 2) {
System.err.println("ERROR: Wrong number of parameters: " + args.length); printUsage(args.length);
System.err.println("Usage: CellCounter "); return -1;
System.err.println(" <tablename> <outputDir> <reportSeparator> [^[regex pattern] or " + }
"[Prefix] for row filter]] --starttime=[starttime] --endtime=[endtime]"); Job job = createSubmittableJob(getConf(), args);
return (job.waitForCompletion(true) ? 0 : 1);
}
private void printUsage(int parameterCount) {
System.err.println("ERROR: Wrong number of parameters: " + parameterCount);
System.err.println("Usage: hbase cellcounter <tablename> <outputDir> [reportSeparator] "
+ "[^[regex pattern] or [Prefix]] [--starttime=<starttime> --endtime=<endtime>]");
System.err.println(" Note: -D properties will be applied to the conf used."); System.err.println(" Note: -D properties will be applied to the conf used.");
System.err.println(" Additionally, all of the SCAN properties from TableInputFormat"); System.err.println(" Additionally, all of the SCAN properties from TableInputFormat can be "
System.err.println(" can be specified to get fine grained control on what is counted.."); + "specified to get fine grained control on what is counted.");
System.err.println(" -D" + TableInputFormat.SCAN_ROW_START + "=<rowkey>"); System.err.println(" -D" + TableInputFormat.SCAN_ROW_START + "=<rowkey>");
System.err.println(" -D" + TableInputFormat.SCAN_ROW_STOP + "=<rowkey>"); System.err.println(" -D" + TableInputFormat.SCAN_ROW_STOP + "=<rowkey>");
System.err.println(" -D" + TableInputFormat.SCAN_COLUMNS + "=\"<col1> <col2>...\""); System.err.println(" -D" + TableInputFormat.SCAN_COLUMNS + "=\"<col1> <col2>...\"");
System.err.println(" -D " + TableInputFormat.SCAN_COLUMN_FAMILY + "=<family1>,<family2>, ..."); System.err.println(" -D" + TableInputFormat.SCAN_COLUMN_FAMILY
+ "=<family1>,<family2>, ...");
System.err.println(" -D" + TableInputFormat.SCAN_TIMESTAMP + "=<timestamp>"); System.err.println(" -D" + TableInputFormat.SCAN_TIMESTAMP + "=<timestamp>");
System.err.println(" -D" + TableInputFormat.SCAN_TIMERANGE_START + "=<timestamp>"); System.err.println(" -D" + TableInputFormat.SCAN_TIMERANGE_START + "=<timestamp>");
System.err.println(" -D" + TableInputFormat.SCAN_TIMERANGE_END + "=<timestamp>"); System.err.println(" -D" + TableInputFormat.SCAN_TIMERANGE_END + "=<timestamp>");
System.err.println(" -D" + TableInputFormat.SCAN_MAXVERSIONS + "=<count>"); System.err.println(" -D" + TableInputFormat.SCAN_MAXVERSIONS + "=<count>");
System.err.println(" -D" + TableInputFormat.SCAN_CACHEDROWS + "=<count>"); System.err.println(" -D" + TableInputFormat.SCAN_CACHEDROWS + "=<count>");
System.err.println(" -D" + TableInputFormat.SCAN_BATCHSIZE + "=<count>"); System.err.println(" -D" + TableInputFormat.SCAN_BATCHSIZE + "=<count>");
System.err.println(" <reportSeparator> parameter can be used to override the default report separator " + System.err.println(" <reportSeparator> parameter can be used to override the default report "
"string : used to separate the rowId/column family name and qualifier name."); + "separator string : used to separate the rowId/column family name and qualifier name.");
System.err.println(" [^[regex pattern] or [Prefix] parameter can be used to limit the cell counter count " + System.err.println(" [^[regex pattern] or [Prefix] parameter can be used to limit the cell "
"operation to a limited subset of rows from the table based on regex or prefix pattern."); + "counter count operation to a limited subset of rows from the table based on regex or "
return -1; + "prefix pattern.");
}
Job job = createSubmittableJob(getConf(), args);
return (job.waitForCompletion(true) ? 0 : 1);
} }
/** /**

View File

@ -221,9 +221,9 @@ public class RowCounter extends Configured implements Tool {
* Note that we don't document --expected-count, because it's intended for test. * Note that we don't document --expected-count, because it's intended for test.
*/ */
private static void printUsage() { private static void printUsage() {
System.err.println("Usage: RowCounter [options] <tablename> " + System.err.println("Usage: hbase rowcounter [options] <tablename> "
"[--starttime=[start] --endtime=[end] " + + "[--starttime=<start> --endtime=<end>] "
"[--range=[startKey],[endKey][;[startKey],[endKey]...]] [<column1> <column2>...]"); + "[--range=[startKey],[endKey][;[startKey],[endKey]...]] [<column1> <column2>...]");
System.err.println("For performance consider the following options:\n" System.err.println("For performance consider the following options:\n"
+ "-Dhbase.client.scanner.caching=100\n" + "-Dhbase.client.scanner.caching=100\n"
+ "-Dmapreduce.map.speculative=false"); + "-Dmapreduce.map.speculative=false");

View File

@ -363,13 +363,7 @@ public class TestRowCounter {
} catch (SecurityException e) { } catch (SecurityException e) {
assertEquals(-1, newSecurityManager.getExitCode()); assertEquals(-1, newSecurityManager.getExitCode());
assertTrue(data.toString().contains("Wrong number of parameters:")); assertTrue(data.toString().contains("Wrong number of parameters:"));
assertTrue(data.toString().contains( assertUsageContent(data.toString());
"Usage: RowCounter [options] <tablename> " +
"[--starttime=[start] --endtime=[end] " +
"[--range=[startKey],[endKey][;[startKey],[endKey]...]] " +
"[<column1> <column2>...]"));
assertTrue(data.toString().contains("-Dhbase.client.scanner.caching=100"));
assertTrue(data.toString().contains("-Dmapreduce.map.speculative=false"));
} }
data.reset(); data.reset();
try { try {
@ -383,18 +377,22 @@ public class TestRowCounter {
assertTrue(data.toString().contains( assertTrue(data.toString().contains(
"Please specify range in such format as \"--range=a,b\" or, with only one boundary," + "Please specify range in such format as \"--range=a,b\" or, with only one boundary," +
" \"--range=,b\" or \"--range=a,\"")); " \"--range=,b\" or \"--range=a,\""));
assertTrue(data.toString().contains( assertUsageContent(data.toString());
"Usage: RowCounter [options] <tablename> " +
"[--starttime=[start] --endtime=[end] " +
"[--range=[startKey],[endKey][;[startKey],[endKey]...]] " +
"[<column1> <column2>...]"));
} }
} finally { } finally {
System.setErr(oldPrintStream); System.setErr(oldPrintStream);
System.setSecurityManager(SECURITY_MANAGER); System.setSecurityManager(SECURITY_MANAGER);
} }
}
private void assertUsageContent(String usage) {
assertTrue(usage.contains("Usage: hbase rowcounter [options] <tablename> "
+ "[--starttime=<start> --endtime=<end>] "
+ "[--range=[startKey],[endKey][;[startKey],[endKey]...]] [<column1> <column2>...]"));
assertTrue(usage.contains("For performance consider the following options:"));
assertTrue(usage.contains("-Dhbase.client.scanner.caching=100"));
assertTrue(usage.contains("-Dmapreduce.map.speculative=false"));
} }
} }