HBASE-20523 PE tool should support configuring client side buffering sizes (Ram)

Conflicts:
        
hbase-server/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/017cb75b
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/017cb75b
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/017cb75b

Branch: refs/heads/branch-1.3
Commit: 017cb75bd306226dbae7904b6181b99c7576be22
Parents: be4915e
Author: Vasudevan <ramkrishna.s.vasude...@intel.com>
Authored: Mon May 7 14:42:29 2018 +0530
Committer: Andrew Purtell <apurt...@apache.org>
Committed: Wed Dec 12 18:08:19 2018 -0800

----------------------------------------------------------------------
 .../hadoop/hbase/PerformanceEvaluation.java     | 22 +++++++++++++++++++-
 .../hadoop/hbase/TestPerformanceEvaluation.java | 13 +++++++++++-
 2 files changed, 33 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/017cb75b/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java
----------------------------------------------------------------------
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 66a2dce..c2418e8 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
@@ -55,6 +55,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;
@@ -621,6 +622,7 @@ public class PerformanceEvaluation extends Configured 
implements Tool {
     int families = 1;
     int caching = 30;
     boolean addColumns = true;
+    long bufferSize = 2l * 1024l * 1024l;
 
     public TestOptions() {}
 
@@ -664,6 +666,7 @@ public class PerformanceEvaluation extends Configured 
implements Tool {
       this.columns = that.columns;
       this.families = that.families;
       this.caching = that.caching;
+      this.bufferSize = that.bufferSize;
     }
 
     public int getCaching() {
@@ -830,6 +833,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;
     }
@@ -1251,7 +1262,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
@@ -2004,6 +2017,7 @@ public class PerformanceEvaluation extends Configured 
implements Tool {
     System.err.println(" columns         Columns to write per row. Default: 
1");
     System.err.println(" families        Specify number of column families for 
the table. 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: ");
@@ -2240,6 +2254,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;
         opts.numClientThreads = Integer.parseInt(args.remove());

http://git-wip-us.apache.org/repos/asf/hbase/blob/017cb75b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java
----------------------------------------------------------------------
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 3414e0a..cade7a4 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
@@ -17,6 +17,7 @@
  */
 package org.apache.hadoop.hbase;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
@@ -42,4 +43,14 @@ public class TestPerformanceEvaluation {
         mapper.readValue(optionsString, 
PerformanceEvaluation.TestOptions.class);
     assertTrue(optionsDeserialized.isAutoFlush());
   }
-}
\ No newline at end of file
+
+  @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);
+  }
+}

Reply via email to