You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2014/05/23 03:53:52 UTC

[1/2] git commit: HBASE-11211 LoadTestTool option for specifying number of regions per server

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 <ap...@apache.org>
Authored: Thu May 22 18:49:14 2014 -0700
Committer: Andrew Purtell <ap...@apache.org>
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) {


[2/2] git commit: HBASE-11211 LoadTestTool option for specifying number of regions per server

Posted by ap...@apache.org.
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 <ap...@apache.org>
Authored: Thu May 22 18:49:14 2014 -0700
Committer: Andrew Purtell <ap...@apache.org>
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) {