hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 陈加俊 <cjjvict...@gmail.com>
Subject Re: thread safety of incrementColumnValue
Date Sat, 23 Jul 2011 12:33:08 GMT
Yes , executed under heavy loads by n-threads. Is there anything I need to
be
worried about?

On Fri, Jul 22, 2011 at 12:17 PM, large data <lrgdt29@gmail.com> wrote:

> thanks ted..
>
> Are there any best practices around usage of HTablePool? For a code
> structure like this
>
> HTablePool pool = new HTablePool();
> String tableName="table";
>
> public void log(query) throws Exception {
>
>   HTable table = pool.getTable(Bytes.toBytes(tableName);
>   ...
>   ...
>   //done
>   pool.putTable(Bytes.toBytes(tableName);
>
> }
>
> executed under heavy loads by n-threads. Is there anything I need to be
> worried about?
>
> On Thu, Jul 21, 2011 at 11:21 AM, Ted Yu <yuzhihong@gmail.com> wrote:
>
> > Please reuse HTable instances through HTablePool.
> >
> >
> >
> > On Jul 21, 2011, at 10:08 AM, large data <lrgdt29@gmail.com> wrote:
> >
> > > thanks Doug...so you saying something like this called from diff
> threads
> > in
> > > a fairly loaded system would not be much of a concern?
> > >
> > >    log(String something){
> > >     HTable htable = new HTable();
> > >     htable.incrementColumnValue(key,columnFamily,columnQualifier,1L);
> > >     }
> > >
> > >
> > > On Thu, Jul 21, 2011 at 10:01 AM, Doug Meil
> > > <doug.meil@explorysmedical.com>wrote:
> > >
> > >>
> > >> re:  "Now creating an instance of an Htable is quite expensive on a
> per
> > >> thread basis."
> > >>
> > >> Connection/metadata is managed statically.  Creating Htables instances
> > >> isn't that heavyweight.
> > >>
> > >>
> > >>
> > >>
> > >>
> > >> On 7/21/11 11:30 AM, "large data" <lrgdt29@gmail.com> wrote:
> > >>
> > >>> Thanks Doug! this is very informative. Now creating an instance of
an
> > >>> HTable
> > >>> is quite expensive on a per thread basis. Reading through the docs
I
> > found
> > >>> this
> > >>>
> > >>
> >
> http://hbase.apache.org/apidocs/index.html?org/apache/hadoop/hbase/client/
> > >>> HTablePool.html
> > >>>
> > >>> Are there any best practices using HTablePool? HTablePool
> > >>> sounds analogous to DB connection pools to me but I am not sure how
> > >>> HTablePool.get() would work under multithreaded environment.
> > >>>
> > >>> thanks
> > >>>
> > >>>
> > >>> On Wed, Jul 20, 2011 at 6:28 PM, Doug Meil
> > >>> <doug.meil@explorysmedical.com>wrote:
> > >>>
> > >>>>
> > >>>> Hi there-
> > >>>>
> > >>>> I think there are two subjects here:
> > >>>>
> > >>>>
> > >>>> 1)  the fact that HTable isn't thread-safe
> > >>>>
> > >>>> 2)  how counters work
> > >>>>
> > >>>> Even if you are incrementing counters, you shouldn't be sharing
> HTable
> > >>>> instances across threads.
> > >>>>
> > >>>> Counters get updated atomically on the RS, not on the client.
> > >>>>
> > >>>> Counter behavior isn't in the Hbase book and it needs to be.  I'll
> add
> > >>>> it
> > >>>> to the list.
> > >>>>
> > >>>>
> > >>>> On 7/20/11 7:44 PM, "large data" <lrgdt29@gmail.com> wrote:
> > >>>>
> > >>>>> I have an HTable instance instantiated as part of a singleton
> > service.
> > >>>>> This
> > >>>>> singleton service is called from different threads from different
> > >>>> parts of
> > >>>>> the app. Reading through the HTable docs suggests not to use
single
> > >>>> HTable
> > >>>>> instance for updates, if it's true how can incrementColumnValue
> > provide
> > >>>>> thread safety?
> > >>>>>
> > >>>>> thanks
> > >>>>
> > >>>>
> > >>
> > >>
> >
>



-- 

陈加俊  项目经理
优讯时代(北京)网络技术有限公司
优讯网 www.uuwatch.com

地址:北京市海淀区上地信息路2号D栋412

电话:010-82895510
传真:010-82896636
手机:15110038983
电邮:*cjjvictory@gmail.com*

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