hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chandrashekhar Kotekar <shekhar.kote...@gmail.com>
Subject How to create HTableInterface object per thread in REST API?
Date Fri, 05 Jun 2015 06:01:12 GMT
Hello everyone,

We have a REST API which communicates with HBase for CRUD operations.
During load testing we saw that REST API throws "String index out of range"
exception if multiple parallel requests try to insert hundreds of cells in
HBase.

After looking at HBase code and after reading HBase API document, I came to
know that HTableInterface objects are not thread safe and it is recommended
to create separate HTableInterface object per thread.

As REST APIs are nothing but servlets and thread management is done by web
server (we are using tomcat and jersey for this project) I would like to
know what is the way to ensure that web server/servlets create
HTableInterface object for each thread.

I have created connection object as shown below :

return HConnectionManager.createConnection(config,
Executors.newCachedThreadPool());

and create HTableInterface object as below:

protected HTableInterface hTableInterface;

public insertRecord(String recordDetails) {
  this.hTableInterface = connection.getTable("readings_table",
Executors.newCachedThreadPool());
  // rest of the operations regarding parsing record
  try {
       this.hTableInterface.put(recod);
  } catch(Exception ex) {
       // log exception
  } finally {
       this.hTableInterface.flushCommits();
       this.hTableInterface.close();
  }


}

Here hTableInterface object is member of the class.

but this isn't helping. Is there any other way to ensure that separate
HTableInterface object is created for each thread?

Regards,
Chandrash3khar Kotekar
Mobile - +91 8600011455

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message