HBASE-12304 CellCounter will throw AIOBE when output directory is not specified. (Ashish Singhi)

This commit is contained in:
anoopsjohn 2014-10-28 17:27:47 +05:30
parent 7587d99b62
commit f2f21000fb
2 changed files with 11 additions and 2 deletions

View File

@ -242,7 +242,7 @@ public class CellCounter extends Configured implements Tool {
@Override
public int run(String[] args) throws Exception {
String[] otherArgs = new GenericOptionsParser(getConf(), args).getRemainingArgs();
if (otherArgs.length < 1) {
if (otherArgs.length < 2) {
System.err.println("ERROR: Wrong number of parameters: " + args.length);
System.err.println("Usage: CellCounter <tablename> <outputDir> <reportSeparator> " +
"[^[regex pattern] or [Prefix] for row filter]] ");

View File

@ -23,6 +23,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.fs.LocalFileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Table;
@ -32,6 +33,7 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.LauncherSecurityManager;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.util.GenericOptionsParser;
import org.apache.hadoop.util.ToolRunner;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@ -201,4 +203,11 @@ public class TestCellCounter {
FileUtil.fullyDelete(new File(outputPath));
}
}
}
@Test
public void TestCellCounterWithoutOutputDir() throws Exception {
String[] args = new String[] { "tableName" };
assertEquals("CellCounter should exit with -1 as output directory is not specified.", -1,
ToolRunner.run(HBaseConfiguration.create(), new CellCounter(), args));
}
}