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/c93ceed2
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/c93ceed2
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/c93ceed2

Branch: refs/heads/0.98
Commit: c93ceed290ed5b79c72dafa4252be0d5ca88ff79
Parents: 7caceb2
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:24 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/c93ceed2/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 28a60d9..2984fe3 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
@@ -127,11 +127,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
@@ -3166,10 +3167,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/c93ceed2/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 f3139c3..ead7a19 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
@@ -131,7 +131,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";
 
@@ -179,6 +180,7 @@ public class LoadTestTool extends AbstractHBaseTool {
   private int verifyPercent;
 
   private int numTables = 1;
+  private int regionsPerServer = 
HBaseTestingUtility.DEFAULT_REGIONS_PER_SERVER;
 
   private String superUser;
 
@@ -293,6 +295,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);
   }
 
@@ -400,9 +406,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) {

Reply via email to