hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Yu <yuzhih...@gmail.com>
Subject Re: How to create HTableInterface object per thread in REST API?
Date Fri, 05 Jun 2015 13:44:54 GMT
Which hbase release are you using ?

bq. but this isn't helping

Can you tell us more what problem you encountered using below code ?

You may have read
http://hbase.apache.org/book.html#client.connection.pooling

Cheers

On Thu, Jun 4, 2015 at 11:01 PM, Chandrashekhar Kotekar <
shekhar.kotekar@gmail.com> wrote:

> 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