From 91f3de89ab95f259dcf04f1cd427e21914ab720b Mon Sep 17 00:00:00 2001 From: Vasudevan Date: Mon, 7 May 2018 14:41:08 +0530 Subject: [PATCH] HBASE-20523 PE tool should support configuring client side buffering sizes (Ram) --- .../hadoop/hbase/PerformanceEvaluation.java | 22 ++++++++++++++++++- .../hbase/TestPerformanceEvaluation.java | 10 +++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) 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 d31e39f51bb..3c53389b211 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 @@ -57,6 +57,7 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Append; import org.apache.hadoop.hbase.client.BufferedMutator; +import org.apache.hadoop.hbase.client.BufferedMutatorParams; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.ConnectionFactory; import org.apache.hadoop.hbase.client.Consistency; @@ -622,6 +623,7 @@ public class PerformanceEvaluation extends Configured implements Tool { int columns = 1; int caching = 30; boolean addColumns = true; + long bufferSize = 2l * 1024l * 1024l; public TestOptions() {} @@ -665,6 +667,7 @@ public class PerformanceEvaluation extends Configured implements Tool { this.addColumns = that.addColumns; this.columns = that.columns; this.caching = that.caching; + this.bufferSize = that.bufferSize; } public int getCaching() { @@ -827,6 +830,14 @@ public class PerformanceEvaluation extends Configured implements Tool { this.valueSize = valueSize; } + public void setBufferSize(long bufferSize) { + this.bufferSize = bufferSize; + } + + public long getBufferSize() { + return this.bufferSize; + } + public void setPeriod(int period) { this.period = period; } @@ -1255,7 +1266,9 @@ public class PerformanceEvaluation extends Configured implements Tool { @Override void onStartup() throws IOException { - this.mutator = connection.getBufferedMutator(TableName.valueOf(opts.tableName)); + BufferedMutatorParams p = new BufferedMutatorParams(TableName.valueOf(opts.tableName)); + p.writeBufferSize(opts.bufferSize); + this.mutator = connection.getBufferedMutator(p); } @Override @@ -1964,6 +1977,7 @@ 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(" bufferSize Set the value of client side buffering. Default: 2MB"); System.err.println(); System.err.println(" Note: -D properties will be applied to the conf used. "); System.err.println(" For example: "); @@ -2199,6 +2213,12 @@ public class PerformanceEvaluation extends Configured implements Tool { continue; } + final String bufferSize = "--bufferSize="; + if (cmd.startsWith(bufferSize)) { + opts.bufferSize = Long.parseLong(cmd.substring(bufferSize.length())); + continue; + } + if (isCommandClass(cmd)) { opts.cmdName = cmd; try { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java index 37f8a783564..4658a9c3f31 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java @@ -87,4 +87,14 @@ public class TestPerformanceEvaluation { assertTrue(e.getCause() instanceof NoSuchElementException); } } + + @Test + public void testSetBufferSizeOption() { + PerformanceEvaluation.TestOptions opts = new PerformanceEvaluation.TestOptions(); + long bufferSize = opts.getBufferSize(); + assertEquals(bufferSize, 2l * 1024l * 1024l); + opts.setBufferSize(64l * 1024l); + bufferSize = opts.getBufferSize(); + assertEquals(bufferSize, 64l * 1024l); + } }