Repository: hbase Updated Branches: refs/heads/0.98 7caceb23c -> c93ceed29 refs/heads/master b168b8b2d -> fd94fcde5
HBASE-11211 LoadTestTool option for specifying number of regions per server Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/fd94fcde Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/fd94fcde Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/fd94fcde Branch: refs/heads/master Commit: fd94fcde583c66e9f231342948c3e677a99a6d3b Parents: b168b8b Author: Andrew Purtell <[email protected]> Authored: Thu May 22 18:49:14 2014 -0700 Committer: Andrew Purtell <[email protected]> Committed: Thu May 22 18:49:14 2014 -0700 ---------------------------------------------------------------------- .../apache/hadoop/hbase/HBaseTestingUtility.java | 8 +++++--- .../org/apache/hadoop/hbase/util/LoadTestTool.java | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/fd94fcde/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java index 2ddfcd5..e9e5eb6 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java @@ -132,11 +132,12 @@ import org.apache.zookeeper.ZooKeeper.States; public class HBaseTestingUtility extends HBaseCommonTestingUtility { private MiniZooKeeperCluster zkCluster = null; + public static final String REGIONS_PER_SERVER_KEY = "hbase.test.regions-per-server"; /** * The default number of regions per regionserver when creating a pre-split * table. */ - private static int DEFAULT_REGIONS_PER_SERVER = 5; + public static final int DEFAULT_REGIONS_PER_SERVER = 5; /** * Set if we were passed a zkCluster. If so, we won't shutdown zk as @@ -3196,10 +3197,11 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { throw new IllegalStateException("No live regionservers"); } - totalNumberOfRegions = numberOfServers * DEFAULT_REGIONS_PER_SERVER; + int regionsPerServer = conf.getInt(REGIONS_PER_SERVER_KEY, DEFAULT_REGIONS_PER_SERVER); + totalNumberOfRegions = numberOfServers * regionsPerServer; LOG.info("Number of live regionservers: " + numberOfServers + ", " + "pre-splitting table into " + totalNumberOfRegions + " regions " + - "(default regions per server: " + DEFAULT_REGIONS_PER_SERVER + ")"); + "(default regions per server: " + regionsPerServer + ")"); byte[][] splits = new RegionSplitter.HexStringSplit().split( totalNumberOfRegions); http://git-wip-us.apache.org/repos/asf/hbase/blob/fd94fcde/hbase-server/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java index d0357fa..da15707 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java @@ -130,7 +130,8 @@ public class LoadTestTool extends AbstractHBaseTool { protected static final String OPT_ZK_PARENT_NODE = "zk_root"; protected static final String OPT_SKIP_INIT = "skip_init"; protected static final String OPT_INIT_ONLY = "init_only"; - private static final String NUM_TABLES = "num_tables"; + protected static final String NUM_TABLES = "num_tables"; + protected static final String OPT_REGIONS_PER_SERVER = "regions_per_server"; protected static final String OPT_BATCHUPDATE = "batchupdate"; protected static final String OPT_UPDATE = "update"; @@ -178,6 +179,7 @@ public class LoadTestTool extends AbstractHBaseTool { private int verifyPercent; private int numTables = 1; + private int regionsPerServer = HBaseTestingUtility.DEFAULT_REGIONS_PER_SERVER; private String superUser; @@ -292,6 +294,10 @@ public class LoadTestTool extends AbstractHBaseTool { + "tool will load n table parallely. -tn parameter value becomes " + "table name prefix. Each table name is in format <tn>_1...<tn>_n"); + addOptWithArg(OPT_REGIONS_PER_SERVER, + "A positive integer number. When a number n is specified, load test " + + "tool will create the test table with n regions per server"); + addOptWithArg(OPT_ENCRYPTION, OPT_ENCRYPTION_USAGE); } @@ -399,9 +405,16 @@ public class LoadTestTool extends AbstractHBaseTool { } numTables = 1; - if(cmd.hasOption(NUM_TABLES)) { + if (cmd.hasOption(NUM_TABLES)) { numTables = parseInt(cmd.getOptionValue(NUM_TABLES), 1, Short.MAX_VALUE); } + regionsPerServer = HBaseTestingUtility.DEFAULT_REGIONS_PER_SERVER; + if (cmd.hasOption(OPT_REGIONS_PER_SERVER)) { + regionsPerServer = parseInt(cmd.getOptionValue(OPT_REGIONS_PER_SERVER), 1, + Integer.MAX_VALUE); + conf.setInt(HBaseTestingUtility.REGIONS_PER_SERVER_KEY, regionsPerServer); + } + System.out.println("Regions per server: " + regionsPerServer); } private void parseColumnFamilyOptions(CommandLine cmd) {
