From 6e4c04143e909792f77c581ec57babd2c80c457f Mon Sep 17 00:00:00 2001 From: Matt Warhaftig Date: Sat, 20 Jun 2015 23:54:34 -0400 Subject: [PATCH] HBASE-13708 - Add range option to random read test in PE. --- .../apache/hadoop/hbase/PerformanceEvaluation.java | 38 +++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java index 569ef71..33aaf94 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java @@ -404,7 +404,7 @@ public class PerformanceEvaluation extends Configured implements Tool { @Override public RunResult call() throws Exception { TestOptions threadOpts = new TestOptions(opts); - if (threadOpts.startRow == 0) threadOpts.startRow = index * threadOpts.perClientRunRows; + if (threadOpts.startRow == 0) threadOpts.startRow = index * threadOpts.rowRangeSize; RunResult run = runOneClient(cmd, conf, con, threadOpts, new Status() { @Override public void setStatus(final String msg) throws IOException { @@ -527,7 +527,7 @@ public class PerformanceEvaluation extends Configured implements Tool { for (int j = 0; j < opts.numClientThreads; j++) { TestOptions next = new TestOptions(opts); next.startRow = (j * perClientRows) + (i * (perClientRows/10)); - next.perClientRunRows = perClientRows / 10; + next.perClientRunRows = opts.perClientRunRows / 10; String s = MAPPER.writeValueAsString(next); LOG.info("Client=" + j + ", maptask=" + i + ", input=" + s); int hash = h.hash(Bytes.toBytes(s)); @@ -613,6 +613,7 @@ public class PerformanceEvaluation extends Configured implements Tool { int cycles = 1; int columns = 1; int caching = 30; + int rowRangeSize = 0; boolean addColumns = true; public TestOptions() {} @@ -658,6 +659,7 @@ public class PerformanceEvaluation extends Configured implements Tool { this.addColumns = that.addColumns; this.columns = that.columns; this.caching = that.caching; + this.rowRangeSize = that.rowRangeSize; } public int getCaching() { @@ -947,6 +949,14 @@ public class PerformanceEvaluation extends Configured implements Tool { public void setAddColumns(boolean addColumns) { this.addColumns = addColumns; } + + public void setRowRangeSize(int rowRangeSize) { + this.rowRangeSize = rowRangeSize; + } + + public int getRowRangeSize() { + return rowRangeSize; + } } /* @@ -1350,7 +1360,7 @@ public class PerformanceEvaluation extends Configured implements Tool { if (opts.randomSleep > 0) { Thread.sleep(rd.nextInt(opts.randomSleep)); } - Get get = new Get(getRandomRow(this.rand, opts.totalRows)); + Get get = new Get(getRandomRow(this.rand, opts.rowRangeSize)); if (opts.addColumns) { get.addColumn(FAMILY_NAME, QUALIFIER_NAME); } else { @@ -1650,6 +1660,7 @@ public class PerformanceEvaluation extends Configured implements Tool { status.setStatus("Finished " + cmd + " in " + totalElapsedTime + "ms at offset " + opts.startRow + " for " + opts.perClientRunRows + " rows" + + (opts.cmdName.equals("randomRead") ? " from a range of " + opts.rowRangeSize+ " rows" : "") + " (" + calculateMbps((int)(opts.perClientRunRows * opts.sampleRate), totalElapsedTime, getAverageValueLength(opts), opts.columns) + ")"); @@ -1753,6 +1764,8 @@ public class PerformanceEvaluation extends Configured implements Tool { System.err.println(" randomSleep Do a random sleep before each get between 0 and entered value. Defaults: 0"); System.err.println(" columns Columns to write per row. Default: 1"); System.err.println(" caching Scan caching to use. Default: 30"); + System.err.println(" rowRangeSize When doing RandomRead, will only read rows within " + + "this range. Default: rows value"); System.err.println(); System.err.println(" Note: -D properties will be applied to the conf used. "); System.err.println(" For example: "); @@ -1995,6 +2008,14 @@ public class PerformanceEvaluation extends Configured implements Tool { continue; } + final String rowRangeSize = "--rowRangeSize="; + if (cmd.startsWith(rowRangeSize)) { + opts.rowRangeSize = Integer.parseInt(cmd.substring(rowRangeSize.length())); + if (opts.rowRangeSize <= 0) + throw new IllegalStateException("RowRangeSize must be > 0; i.e. 10"); + continue; + } + if (isCommandClass(cmd)) { opts.cmdName = cmd; opts.numClientThreads = Integer.parseInt(args.remove()); @@ -2023,9 +2044,18 @@ public class PerformanceEvaluation extends Configured implements Tool { // total size in GB specified opts.totalRows = (int) opts.size * rowsPerGB; opts.perClientRunRows = opts.totalRows / opts.numClientThreads; + if(!opts.cmdName.equals("randomRead") || opts.rowRangeSize == 0){ + opts.rowRangeSize = opts.perClientRunRows; + } } else if (opts.perClientRunRows != DEFAULT_OPTS.perClientRunRows) { // number of rows specified - opts.totalRows = opts.perClientRunRows * opts.numClientThreads; + if(!opts.cmdName.equals("randomRead") || opts.rowRangeSize == 0){ + opts.rowRangeSize = opts.perClientRunRows; + opts.totalRows = opts.rowRangeSize * opts.numClientThreads; + } else { + opts.totalRows = opts.rowRangeSize * opts.numClientThreads * (opts.nomapred ? 1 : + TASKS_PER_CLIENT); + } opts.size = opts.totalRows / rowsPerGB; } return opts; -- 2.3.2 (Apple Git-55)