HBASE-9672 LoadTestTool NPE's when -num_tables is given, but -tn is not
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1527067 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4ae82009f4
commit
a7bae17b16
|
@ -98,7 +98,7 @@ public class LoadTestTool extends AbstractHBaseTool {
|
|||
public static final String OPT_ENCODE_IN_CACHE_ONLY_USAGE =
|
||||
"If this is specified, data blocks will only be encoded in block " +
|
||||
"cache but not on disk";
|
||||
|
||||
|
||||
public static final String OPT_INMEMORY = "in_memory";
|
||||
public static final String OPT_USAGE_IN_MEMORY = "Tries to keep the HFiles of the CF " +
|
||||
"inmemory as far as possible. Not guaranteed that reads are always served from inmemory";
|
||||
|
@ -107,7 +107,7 @@ public class LoadTestTool extends AbstractHBaseTool {
|
|||
" only if the HFileV3 version is used";
|
||||
|
||||
public static final String OPT_NUM_TAGS = "num_tags";
|
||||
public static final String OPT_USAGE_NUM_TAGS = "Specifies the minimum and number of tags to be"
|
||||
public static final String OPT_USAGE_NUM_TAGS = "Specifies the minimum and number of tags to be"
|
||||
+ " added per KV";
|
||||
|
||||
protected static final String OPT_KEY_WINDOW = "key_window";
|
||||
|
@ -163,7 +163,7 @@ public class LoadTestTool extends AbstractHBaseTool {
|
|||
private int keyWindow = MultiThreadedReader.DEFAULT_KEY_WINDOW;
|
||||
private int maxReadErrors = MultiThreadedReader.DEFAULT_MAX_ERRORS;
|
||||
private int verifyPercent;
|
||||
|
||||
|
||||
private int numTables = 1;
|
||||
|
||||
// TODO: refactor LoadTestToolImpl somewhere to make the usage from tests less bad,
|
||||
|
@ -261,7 +261,7 @@ public class LoadTestTool extends AbstractHBaseTool {
|
|||
DEFAULT_START_KEY + ".");
|
||||
addOptNoArg(OPT_SKIP_INIT, "Skip the initialization; assume test table "
|
||||
+ "already exists");
|
||||
|
||||
|
||||
addOptWithArg(NUM_TABLES,
|
||||
"A positive integer number. When a number n is speicfied, load test "
|
||||
+ "tool will load n table parallely. -tn parameter value becomes "
|
||||
|
@ -367,7 +367,7 @@ public class LoadTestTool extends AbstractHBaseTool {
|
|||
System.out.println("Percent of keys to verify: " + verifyPercent);
|
||||
System.out.println("Reader threads: " + numReaderThreads);
|
||||
}
|
||||
|
||||
|
||||
numTables = 1;
|
||||
if(cmd.hasOption(NUM_TABLES)) {
|
||||
numTables = parseInt(cmd.getOptionValue(NUM_TABLES), 1, Short.MAX_VALUE);
|
||||
|
@ -390,7 +390,7 @@ public class LoadTestTool extends AbstractHBaseTool {
|
|||
String bloomStr = cmd.getOptionValue(OPT_BLOOM);
|
||||
bloomType = bloomStr == null ? null :
|
||||
BloomType.valueOf(bloomStr);
|
||||
|
||||
|
||||
inMemoryCF = cmd.hasOption(OPT_INMEMORY);
|
||||
useTags = cmd.hasOption(OPT_USETAGS);
|
||||
if (useTags) {
|
||||
|
@ -405,7 +405,7 @@ public class LoadTestTool extends AbstractHBaseTool {
|
|||
System.out.println("Using tags, number of tags per KV: min=" + minNumTags + ", max="
|
||||
+ maxNumTags);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void initTestTable() throws IOException {
|
||||
|
@ -539,14 +539,14 @@ public class LoadTestTool extends AbstractHBaseTool {
|
|||
}
|
||||
|
||||
/**
|
||||
* When NUM_TABLES is specified, the function starts multiple worker threads
|
||||
* which individually start a LoadTestTool instance to load a table. Each
|
||||
* When NUM_TABLES is specified, the function starts multiple worker threads
|
||||
* which individually start a LoadTestTool instance to load a table. Each
|
||||
* table name is in format <tn>_<index>. For example, "-tn test -num_tables 2"
|
||||
* , table names will be "test_1", "test_2"
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private int parallelLoadTables()
|
||||
private int parallelLoadTables()
|
||||
throws IOException {
|
||||
// create new command args
|
||||
String tableName = cmd.getOptionValue(OPT_TABLE_NAME, DEFAULT_TABLE_NAME);
|
||||
|
@ -554,6 +554,7 @@ public class LoadTestTool extends AbstractHBaseTool {
|
|||
if (!cmd.hasOption(LoadTestTool.OPT_TABLE_NAME)) {
|
||||
newArgs = new String[cmdLineArgs.length + 2];
|
||||
newArgs[0] = "-" + LoadTestTool.OPT_TABLE_NAME;
|
||||
newArgs[1] = LoadTestTool.DEFAULT_TABLE_NAME;
|
||||
for (int i = 0; i < cmdLineArgs.length; i++) {
|
||||
newArgs[i + 2] = cmdLineArgs[i];
|
||||
}
|
||||
|
@ -567,7 +568,7 @@ public class LoadTestTool extends AbstractHBaseTool {
|
|||
tableNameValueIndex = j + 1;
|
||||
} else if (newArgs[j].endsWith(NUM_TABLES)) {
|
||||
// change NUM_TABLES to 1 so that each worker loads one table
|
||||
newArgs[j + 1] = "1";
|
||||
newArgs[j + 1] = "1";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -594,7 +595,7 @@ public class LoadTestTool extends AbstractHBaseTool {
|
|||
}
|
||||
checkForErrors();
|
||||
}
|
||||
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -627,6 +628,7 @@ public class LoadTestTool extends AbstractHBaseTool {
|
|||
workerArgs = args;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
int ret = ToolRunner.run(HBaseConfiguration.create(), new LoadTestTool(), workerArgs);
|
||||
|
|
Loading…
Reference in New Issue