Skip to content

Commit

Permalink
Merge pull request brianfrankcooper#274 from takebayashi/hbase-writeb…
Browse files Browse the repository at this point in the history
…uffersize

[hbase] Make write buffer size of HBase client configurable
  • Loading branch information
busbey committed Jun 3, 2015
2 parents 7d53bb0 + f070afa commit c5fc808
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion hbase/src/main/java/com/yahoo/ycsb/db/HBaseClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class HBaseClient extends com.yahoo.ycsb.DB
public String _columnFamily="";
public byte _columnFamilyBytes[];
public boolean _clientSideBuffering = false;
public long _writeBufferSize = 1024 * 1024 * 12;

public static final int Ok=0;
public static final int ServerError=-1;
Expand All @@ -85,6 +86,10 @@ public void init() throws DBException
{
_clientSideBuffering = Boolean.parseBoolean(getProperties().getProperty("clientbuffering"));
}
if (getProperties().containsKey("writebuffersize"))
{
_writeBufferSize = Long.parseLong(getProperties().getProperty("writebuffersize"));
}

_columnFamily = getProperties().getProperty("columnfamily");
if (_columnFamily == null)
Expand Down Expand Up @@ -123,7 +128,7 @@ public void getHTable(String table) throws IOException
_hTable = new HTable(config, table);
//2 suggestions from http://ryantwopointoh.blogspot.com/2009/01/performance-of-hbase-importing.html
_hTable.setAutoFlush(!_clientSideBuffering, true);
_hTable.setWriteBufferSize(1024*1024*12);
_hTable.setWriteBufferSize(_writeBufferSize);
//return hTable;
}

Expand Down
6 changes: 5 additions & 1 deletion hbase/src/main/java/com/yahoo/ycsb/db/HBaseClient10.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public class HBaseClient10 extends com.yahoo.ycsb.DB
* insert/update/delete latencies, client side buffering should be disabled.
*/
public boolean _clientSideBuffering = false;
public long _writeBufferSize = 1024 * 1024 * 12;

public static final int Ok=0;
public static final int ServerError=-1;
Expand All @@ -105,6 +106,9 @@ public void init() throws DBException
if ("true".equals(getProperties().getProperty("clientbuffering", "false"))) {
this._clientSideBuffering = true;
}
if (getProperties().containsKey("writebuffersize")) {
_writeBufferSize = Long.parseLong(getProperties().getProperty("writebuffersize"));
}

if (getProperties().getProperty("durability") != null) {
this._durability = Durability.valueOf(getProperties().getProperty("durability"));
Expand Down Expand Up @@ -166,7 +170,7 @@ public void getHTable(String table) throws IOException
//suggestions from http://ryantwopointoh.blogspot.com/2009/01/performance-of-hbase-importing.html
if (_clientSideBuffering) {
final BufferedMutatorParams p = new BufferedMutatorParams(tableName);
p.writeBufferSize(1024*1024*12);
p.writeBufferSize(_writeBufferSize);
this._bufferedMutator = this._connection.getBufferedMutator(p);
}
}
Expand Down

0 comments on commit c5fc808

Please sign in to comment.