You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ns...@apache.org on 2011/12/06 03:34:00 UTC
svn commit: r1210752 -
/hbase/trunk/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java
Author: nspiegelberg
Date: Tue Dec 6 02:34:00 2011
New Revision: 1210752
URL: http://svn.apache.org/viewvc?rev=1210752&view=rev
Log:
HBASE-4440 add an option to presplit table to PerformanceEvaluation
Modified:
hbase/trunk/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java
Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java?rev=1210752&r1=1210751&r2=1210752&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java Tue Dec 6 02:34:00 2011
@@ -121,6 +121,7 @@ public class PerformanceEvaluation {
private int R = ROWS_PER_GB;
private boolean flushCommits = true;
private boolean writeToWAL = true;
+ private int presplitRegions = 0;
private static final Path PERF_EVAL_DIR = new Path("performance_evaluation");
/**
@@ -465,18 +466,53 @@ public class PerformanceEvaluation {
*/
private boolean checkTable(HBaseAdmin admin) throws IOException {
HTableDescriptor tableDescriptor = getTableDescriptor();
- boolean tableExists = admin.tableExists(tableDescriptor.getName());
- if (!tableExists) {
- admin.createTable(tableDescriptor);
- LOG.info("Table " + tableDescriptor + " created");
+ if (this.presplitRegions > 0) {
+ // presplit requested
+ if (admin.tableExists(tableDescriptor.getName())) {
+ admin.disableTable(tableDescriptor.getName());
+ admin.deleteTable(tableDescriptor.getName());
+ }
+
+ byte[][] splits = getSplits();
+ for (int i=0; i < splits.length; i++) {
+ LOG.debug(" split " + i + ": " + Bytes.toStringBinary(splits[i]));
+ }
+ admin.createTable(tableDescriptor, splits);
+ LOG.info ("Table created with " + this.presplitRegions + " splits");
+ }
+ else {
+ boolean tableExists = admin.tableExists(tableDescriptor.getName());
+ if (!tableExists) {
+ admin.createTable(tableDescriptor);
+ LOG.info("Table " + tableDescriptor + " created");
+ }
}
- return !tableExists;
+ boolean tableExists = admin.tableExists(tableDescriptor.getName());
+ return tableExists;
}
protected HTableDescriptor getTableDescriptor() {
return TABLE_DESCRIPTOR;
}
+ /**
+ * generates splits based on total number of rows and specified split regions
+ *
+ * @return splits : array of byte []
+ */
+ protected byte[][] getSplits() {
+ if (this.presplitRegions == 0)
+ return new byte [0][];
+
+ byte[][] splits = new byte[this.presplitRegions][];
+ int jump = this.R / this.presplitRegions;
+ for (int i=0; i <this.presplitRegions; i++) {
+ int rowkey = jump * i;
+ splits[i] = format(rowkey);
+ }
+ return splits;
+ }
+
/*
* We're to run multiple clients concurrently. Setup a mapreduce job. Run
* one map per client. Then run a single reduce to sum the elapsed times.
@@ -1184,6 +1220,7 @@ public class PerformanceEvaluation {
System.err.println(" rows Rows each client runs. Default: One million");
System.err.println(" flushCommits Used to determine if the test should flush the table. Default: false");
System.err.println(" writeToWAL Set writeToWAL on puts. Default: True");
+ System.err.println(" presplit Create presplit table. Recommended for accurate perf analysis (see guide). Default: disabled");
System.err.println();
System.err.println("Command:");
for (CmdDescriptor command : commands.values()) {
@@ -1260,6 +1297,12 @@ public class PerformanceEvaluation {
continue;
}
+ final String presplit = "--presplit=";
+ if (cmd.startsWith(presplit)) {
+ this.presplitRegions = Integer.parseInt(cmd.substring(presplit.length()));
+ continue;
+ }
+
Class<? extends Test> cmdClass = determineCommandClass(cmd);
if (cmdClass != null) {
getArgs(i + 1, args);