You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Shushant Arora <sh...@gmail.com> on 2016/03/13 11:12:36 UTC
use of hbase client in application server
I have a requirement to use long running hbase client in application server.
1.Do I need to create multiple HConnections or single Hconnection will work?
2. DO I need to check whether Hconnection is still active before using it
to create Htable instance.
3.DO I need to handle region split and regionserver changes while using
Hconnection or are they handled automatically.
4.Whats the use of thread pool in Htable instance.
ExecutorService threadPool;
HTable h = new HTable(conf, Bytes.toBytes("tablename"), threadPool);
Thanks!
Re: use of hbase client in application server
Posted by Shushant Arora <sh...@gmail.com>.
2.DO I need to check whether Hconnection is still active before using it to
create Htable instance.
By still valid I meant that say I created Hconnection object and after 3-4
minutes when request came for any crud operation for some table and before
getting Htable using from
HConnection say Hconnection object or TCP/IP connection to cluster dropped.
Does now if I create Htable using HConnection will it recrete the TCP
connection to cluster automatically?
1.And will increasing no of HConnectoions will improve the performance?
Thanks!
On Sun, Mar 13, 2016 at 7:47 PM, Ted Yu <yu...@gmail.com> wrote:
> For #1, single Hconnection should work.
>
> For #2, can you clarify ? As long as the hbase-site.xml used to create
> the Hconnection
> is still valid, you can continue using the connection.
>
> For #3, they're handled by the connection automatically.
>
> For #4, the HTable ctor you cited doesn't exist in master branch.
> You can control the following parameters for the ThreadPoolExecutor - see
> HTable#getDefaultExecutor():
>
> int maxThreads = conf.getInt("hbase.htable.threads.max", Integer.
> MAX_VALUE);
>
> if (maxThreads == 0) {
>
> maxThreads = 1; // is there a better default?
>
> }
>
> int corePoolSize = conf.getInt("hbase.htable.threads.coresize", 1);
>
> long keepAliveTime = conf.getLong("hbase.htable.threads.keepalivetime",
> 60);
>
> On Sun, Mar 13, 2016 at 3:12 AM, Shushant Arora <shushantarora09@gmail.com
> >
> wrote:
>
> > I have a requirement to use long running hbase client in application
> > server.
> >
> > 1.Do I need to create multiple HConnections or single Hconnection will
> > work?
> > 2. DO I need to check whether Hconnection is still active before using it
> > to create Htable instance.
> > 3.DO I need to handle region split and regionserver changes while using
> > Hconnection or are they handled automatically.
> > 4.Whats the use of thread pool in Htable instance.
> > ExecutorService threadPool;
> > HTable h = new HTable(conf, Bytes.toBytes("tablename"), threadPool);
> >
> >
> > Thanks!
> >
>
Re: use of hbase client in application server
Posted by Ted Yu <yu...@gmail.com>.
For #1, single Hconnection should work.
For #2, can you clarify ? As long as the hbase-site.xml used to create
the Hconnection
is still valid, you can continue using the connection.
For #3, they're handled by the connection automatically.
For #4, the HTable ctor you cited doesn't exist in master branch.
You can control the following parameters for the ThreadPoolExecutor - see
HTable#getDefaultExecutor():
int maxThreads = conf.getInt("hbase.htable.threads.max", Integer.
MAX_VALUE);
if (maxThreads == 0) {
maxThreads = 1; // is there a better default?
}
int corePoolSize = conf.getInt("hbase.htable.threads.coresize", 1);
long keepAliveTime = conf.getLong("hbase.htable.threads.keepalivetime",
60);
On Sun, Mar 13, 2016 at 3:12 AM, Shushant Arora <sh...@gmail.com>
wrote:
> I have a requirement to use long running hbase client in application
> server.
>
> 1.Do I need to create multiple HConnections or single Hconnection will
> work?
> 2. DO I need to check whether Hconnection is still active before using it
> to create Htable instance.
> 3.DO I need to handle region split and regionserver changes while using
> Hconnection or are they handled automatically.
> 4.Whats the use of thread pool in Htable instance.
> ExecutorService threadPool;
> HTable h = new HTable(conf, Bytes.toBytes("tablename"), threadPool);
>
>
> Thanks!
>