From 4308ddce4808a7e98212151412f680ae3aa26b4e Mon Sep 17 00:00:00 2001 From: mbertozzi Date: Mon, 30 Sep 2013 22:57:44 +0000 Subject: [PATCH] HBASE-9663 PerformanceEvaluation does not properly honor specified table name parameter git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1527817 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop/hbase/PerformanceEvaluation.java | 75 ++++++++++++------- 1 file changed, 46 insertions(+), 29 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 a06c7958105..db0d0d3b2f0 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 @@ -139,7 +139,8 @@ public class PerformanceEvaluation extends Configured implements Tool { * Regex to parse lines in input file passed to mapreduce task. */ public static final Pattern LINE_PATTERN = - Pattern.compile("startRow=(\\d+),\\s+" + + Pattern.compile("tableName=(\\w+),\\s+" + + "startRow=(\\d+),\\s+" + "perClientRunRows=(\\d+),\\s+" + "totalRows=(\\d+),\\s+" + "clients=(\\d+),\\s+" + @@ -216,6 +217,7 @@ public class PerformanceEvaluation extends Configured implements Tool { * the record value is the PeInputSplit itself. */ public static class PeInputSplit extends InputSplit implements Writable { + private TableName tableName = TABLE_NAME; private int startRow = 0; private int rows = 0; private int totalRows = 0; @@ -226,18 +228,11 @@ public class PerformanceEvaluation extends Configured implements Tool { private int noOfTags = 0; public PeInputSplit() { - this.startRow = 0; - this.rows = 0; - this.totalRows = 0; - this.clients = 0; - this.flushCommits = false; - this.writeToWAL = true; - this.useTags = false; - this.noOfTags = 0; } - public PeInputSplit(int startRow, int rows, int totalRows, int clients, + public PeInputSplit(TableName tableName, int startRow, int rows, int totalRows, int clients, boolean flushCommits, boolean writeToWAL, boolean useTags, int noOfTags) { + this.tableName = tableName; this.startRow = startRow; this.rows = rows; this.totalRows = totalRows; @@ -250,6 +245,11 @@ public class PerformanceEvaluation extends Configured implements Tool { @Override public void readFields(DataInput in) throws IOException { + int tableNameLen = in.readInt(); + byte[] name = new byte[tableNameLen]; + in.readFully(name); + this.tableName = TableName.valueOf(name); + this.startRow = in.readInt(); this.rows = in.readInt(); this.totalRows = in.readInt(); @@ -262,6 +262,9 @@ public class PerformanceEvaluation extends Configured implements Tool { @Override public void write(DataOutput out) throws IOException { + byte[] name = this.tableName.toBytes(); + out.writeInt(name.length); + out.write(name); out.writeInt(startRow); out.writeInt(rows); out.writeInt(totalRows); @@ -282,6 +285,10 @@ public class PerformanceEvaluation extends Configured implements Tool { return new String[0]; } + public TableName getTableName() { + return tableName; + } + public int getStartRow() { return startRow; } @@ -343,27 +350,29 @@ public class PerformanceEvaluation extends Configured implements Tool { } Matcher m = LINE_PATTERN.matcher(lineText.toString()); if((m != null) && m.matches()) { - int startRow = Integer.parseInt(m.group(1)); - int rows = Integer.parseInt(m.group(2)); - int totalRows = Integer.parseInt(m.group(3)); - int clients = Integer.parseInt(m.group(4)); - boolean flushCommits = Boolean.parseBoolean(m.group(5)); - boolean writeToWAL = Boolean.parseBoolean(m.group(6)); - boolean useTags = Boolean.parseBoolean(m.group(7)); - int noOfTags = Integer.parseInt(m.group(8)); + TableName tableName = TableName.valueOf(m.group(1)); + int startRow = Integer.parseInt(m.group(2)); + int rows = Integer.parseInt(m.group(3)); + int totalRows = Integer.parseInt(m.group(4)); + int clients = Integer.parseInt(m.group(5)); + boolean flushCommits = Boolean.parseBoolean(m.group(6)); + boolean writeToWAL = Boolean.parseBoolean(m.group(7)); + boolean useTags = Boolean.parseBoolean(m.group(8)); + int noOfTags = Integer.parseInt(m.group(9)); - LOG.debug("split["+ splitList.size() + "] " + - " startRow=" + startRow + - " rows=" + rows + - " totalRows=" + totalRows + - " clients=" + clients + - " flushCommits=" + flushCommits + - " writeToWAL=" + writeToWAL + - " useTags=" + useTags + - " noOfTags=" + noOfTags); + LOG.debug("tableName=" + tableName + + " split["+ splitList.size() + "] " + + " startRow=" + startRow + + " rows=" + rows + + " totalRows=" + totalRows + + " clients=" + clients + + " flushCommits=" + flushCommits + + " writeToWAL=" + writeToWAL + + " useTags=" + useTags + + " noOfTags=" + noOfTags); PeInputSplit newSplit = - new PeInputSplit(startRow, rows, totalRows, clients, + new PeInputSplit(tableName, startRow, rows, totalRows, clients, flushCommits, writeToWAL, useTags, noOfTags); splitList.add(newSplit); } @@ -483,6 +492,7 @@ public class PerformanceEvaluation extends Configured implements Tool { }; // Evaluation task + pe.tableName = value.getTableName(); long elapsedTime = this.pe.runOneClient(this.cmd, value.getStartRow(), value.getRows(), value.getTotalRows(), value.isFlushCommits(), value.isWriteToWAL(), @@ -722,7 +732,8 @@ public class PerformanceEvaluation extends Configured implements Tool { try { for (int i = 0; i < 10; i++) { for (int j = 0; j < N; j++) { - String s = "startRow=" + ((j * perClientRows) + (i * (perClientRows/10))) + + String s = "tableName=" + this.tableName + + ", startRow=" + ((j * perClientRows) + (i * (perClientRows/10))) + ", perClientRunRows=" + (perClientRows / 10) + ", totalRows=" + this.R + ", clients=" + this.N + @@ -1391,6 +1402,12 @@ public class PerformanceEvaluation extends Configured implements Tool { } try { + // MR-NOTE: if you are adding a property that is used to control an operation + // like put(), get(), scan(), ... you must also add it as part of the MR + // input, take a look at writeInputFile(). + // Then you must adapt the LINE_PATTERN input regex, + // and parse the argument, take a look at PEInputFormat.getSplits(). + for (int i = 0; i < args.length; i++) { String cmd = args[i]; if (cmd.equals("-h") || cmd.startsWith("--h")) {