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
This commit is contained in:
mbertozzi 2013-09-30 22:57:44 +00:00
parent 5987ee67e1
commit 4308ddce48
1 changed files with 46 additions and 29 deletions

View File

@ -139,7 +139,8 @@ public class PerformanceEvaluation extends Configured implements Tool {
* Regex to parse lines in input file passed to mapreduce task. * Regex to parse lines in input file passed to mapreduce task.
*/ */
public static final Pattern LINE_PATTERN = public static final Pattern LINE_PATTERN =
Pattern.compile("startRow=(\\d+),\\s+" + Pattern.compile("tableName=(\\w+),\\s+" +
"startRow=(\\d+),\\s+" +
"perClientRunRows=(\\d+),\\s+" + "perClientRunRows=(\\d+),\\s+" +
"totalRows=(\\d+),\\s+" + "totalRows=(\\d+),\\s+" +
"clients=(\\d+),\\s+" + "clients=(\\d+),\\s+" +
@ -216,6 +217,7 @@ public class PerformanceEvaluation extends Configured implements Tool {
* the record value is the PeInputSplit itself. * the record value is the PeInputSplit itself.
*/ */
public static class PeInputSplit extends InputSplit implements Writable { public static class PeInputSplit extends InputSplit implements Writable {
private TableName tableName = TABLE_NAME;
private int startRow = 0; private int startRow = 0;
private int rows = 0; private int rows = 0;
private int totalRows = 0; private int totalRows = 0;
@ -226,18 +228,11 @@ public class PerformanceEvaluation extends Configured implements Tool {
private int noOfTags = 0; private int noOfTags = 0;
public PeInputSplit() { 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) { boolean flushCommits, boolean writeToWAL, boolean useTags, int noOfTags) {
this.tableName = tableName;
this.startRow = startRow; this.startRow = startRow;
this.rows = rows; this.rows = rows;
this.totalRows = totalRows; this.totalRows = totalRows;
@ -250,6 +245,11 @@ public class PerformanceEvaluation extends Configured implements Tool {
@Override @Override
public void readFields(DataInput in) throws IOException { 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.startRow = in.readInt();
this.rows = in.readInt(); this.rows = in.readInt();
this.totalRows = in.readInt(); this.totalRows = in.readInt();
@ -262,6 +262,9 @@ public class PerformanceEvaluation extends Configured implements Tool {
@Override @Override
public void write(DataOutput out) throws IOException { public void write(DataOutput out) throws IOException {
byte[] name = this.tableName.toBytes();
out.writeInt(name.length);
out.write(name);
out.writeInt(startRow); out.writeInt(startRow);
out.writeInt(rows); out.writeInt(rows);
out.writeInt(totalRows); out.writeInt(totalRows);
@ -282,6 +285,10 @@ public class PerformanceEvaluation extends Configured implements Tool {
return new String[0]; return new String[0];
} }
public TableName getTableName() {
return tableName;
}
public int getStartRow() { public int getStartRow() {
return startRow; return startRow;
} }
@ -343,16 +350,18 @@ public class PerformanceEvaluation extends Configured implements Tool {
} }
Matcher m = LINE_PATTERN.matcher(lineText.toString()); Matcher m = LINE_PATTERN.matcher(lineText.toString());
if((m != null) && m.matches()) { if((m != null) && m.matches()) {
int startRow = Integer.parseInt(m.group(1)); TableName tableName = TableName.valueOf(m.group(1));
int rows = Integer.parseInt(m.group(2)); int startRow = Integer.parseInt(m.group(2));
int totalRows = Integer.parseInt(m.group(3)); int rows = Integer.parseInt(m.group(3));
int clients = Integer.parseInt(m.group(4)); int totalRows = Integer.parseInt(m.group(4));
boolean flushCommits = Boolean.parseBoolean(m.group(5)); int clients = Integer.parseInt(m.group(5));
boolean writeToWAL = Boolean.parseBoolean(m.group(6)); boolean flushCommits = Boolean.parseBoolean(m.group(6));
boolean useTags = Boolean.parseBoolean(m.group(7)); boolean writeToWAL = Boolean.parseBoolean(m.group(7));
int noOfTags = Integer.parseInt(m.group(8)); boolean useTags = Boolean.parseBoolean(m.group(8));
int noOfTags = Integer.parseInt(m.group(9));
LOG.debug("split["+ splitList.size() + "] " + LOG.debug("tableName=" + tableName +
" split["+ splitList.size() + "] " +
" startRow=" + startRow + " startRow=" + startRow +
" rows=" + rows + " rows=" + rows +
" totalRows=" + totalRows + " totalRows=" + totalRows +
@ -363,7 +372,7 @@ public class PerformanceEvaluation extends Configured implements Tool {
" noOfTags=" + noOfTags); " noOfTags=" + noOfTags);
PeInputSplit newSplit = PeInputSplit newSplit =
new PeInputSplit(startRow, rows, totalRows, clients, new PeInputSplit(tableName, startRow, rows, totalRows, clients,
flushCommits, writeToWAL, useTags, noOfTags); flushCommits, writeToWAL, useTags, noOfTags);
splitList.add(newSplit); splitList.add(newSplit);
} }
@ -483,6 +492,7 @@ public class PerformanceEvaluation extends Configured implements Tool {
}; };
// Evaluation task // Evaluation task
pe.tableName = value.getTableName();
long elapsedTime = this.pe.runOneClient(this.cmd, value.getStartRow(), long elapsedTime = this.pe.runOneClient(this.cmd, value.getStartRow(),
value.getRows(), value.getTotalRows(), value.getRows(), value.getTotalRows(),
value.isFlushCommits(), value.isWriteToWAL(), value.isFlushCommits(), value.isWriteToWAL(),
@ -722,7 +732,8 @@ public class PerformanceEvaluation extends Configured implements Tool {
try { try {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
for (int j = 0; j < N; j++) { 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) + ", perClientRunRows=" + (perClientRows / 10) +
", totalRows=" + this.R + ", totalRows=" + this.R +
", clients=" + this.N + ", clients=" + this.N +
@ -1391,6 +1402,12 @@ public class PerformanceEvaluation extends Configured implements Tool {
} }
try { 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++) { for (int i = 0; i < args.length; i++) {
String cmd = args[i]; String cmd = args[i];
if (cmd.equals("-h") || cmd.startsWith("--h")) { if (cmd.equals("-h") || cmd.startsWith("--h")) {