Return-Path: X-Original-To: apmail-hbase-user-archive@www.apache.org Delivered-To: apmail-hbase-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D4DA56738 for ; Sat, 23 Jul 2011 12:33:38 +0000 (UTC) Received: (qmail 92309 invoked by uid 500); 23 Jul 2011 12:33:37 -0000 Delivered-To: apmail-hbase-user-archive@hbase.apache.org Received: (qmail 92277 invoked by uid 500); 23 Jul 2011 12:33:35 -0000 Mailing-List: contact user-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hbase.apache.org Delivered-To: mailing list user@hbase.apache.org Received: (qmail 92269 invoked by uid 99); 23 Jul 2011 12:33:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 23 Jul 2011 12:33:35 +0000 X-ASF-Spam-Status: No, hits=4.0 required=5.0 tests=FREEMAIL_FROM,FREEMAIL_REPLY,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of cjjvictory@gmail.com designates 209.85.213.169 as permitted sender) Received: from [209.85.213.169] (HELO mail-yx0-f169.google.com) (209.85.213.169) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 23 Jul 2011 12:33:30 +0000 Received: by yxn22 with SMTP id 22so1998328yxn.14 for ; Sat, 23 Jul 2011 05:33:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=7tu76SjfzMb/kU8oTdr9GAFnc7S0PW9RCEH9xmEO91w=; b=WSNDwxJrPyrmybSLBHoltKsM45jnkjMzwOwLhMDMOXubmE4KReUWbJKjK0WsmJp8HC PyefQ4JAtOBECru7f9g61TwZTZ7Zlv0tmVm3PlWk3xJGthMmrNswhob2texopjDjqa2b miax7jpjoYmJdpWbRa3yPIjxcFc1IzmJUZACk= MIME-Version: 1.0 Received: by 10.90.198.3 with SMTP id v3mr2958796agf.23.1311424388772; Sat, 23 Jul 2011 05:33:08 -0700 (PDT) Received: by 10.90.31.16 with HTTP; Sat, 23 Jul 2011 05:33:08 -0700 (PDT) In-Reply-To: References: <8AB9FD35-4A9D-4628-B264-87E5E1BFF380@gmail.com> Date: Sat, 23 Jul 2011 20:33:08 +0800 Message-ID: Subject: Re: thread safety of incrementColumnValue From: =?UTF-8?B?6ZmI5Yqg5L+K?= To: user@hbase.apache.org Content-Type: multipart/alternative; boundary=0016364ecfeed7b38a04a8bbc836 --0016364ecfeed7b38a04a8bbc836 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 wrote: > thanks ted.. > > Are there any best practices around usage of HTablePool? For a code > structure like this > > HTablePool pool =3D new HTablePool(); > String tableName=3D"table"; > > public void log(query) throws Exception { > > HTable table =3D 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 wrote: > > > Please reuse HTable instances through HTablePool. > > > > > > > > On Jul 21, 2011, at 10:08 AM, large data 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 =3D new HTable(); > > > htable.incrementColumnValue(key,columnFamily,columnQualifier,1L); > > > } > > > > > > > > > On Thu, Jul 21, 2011 at 10:01 AM, Doug Meil > > > wrote: > > > > > >> > > >> re: "Now creating an instance of an Htable is quite expensive on a > per > > >> thread basis." > > >> > > >> Connection/metadata is managed statically. Creating Htables instanc= es > > >> isn't that heavyweight. > > >> > > >> > > >> > > >> > > >> > > >> On 7/21/11 11:30 AM, "large data" 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 > > >>> 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" 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 sing= le > > >>>> HTable > > >>>>> instance for updates, if it's true how can incrementColumnValue > > provide > > >>>>> thread safety? > > >>>>> > > >>>>> thanks > > >>>> > > >>>> > > >> > > >> > > > --=20 =E9=99=88=E5=8A=A0=E4=BF=8A =E9=A1=B9=E7=9B=AE=E7=BB=8F=E7=90=86 =E4=BC=98=E8=AE=AF=E6=97=B6=E4=BB=A3=EF=BC=88=E5=8C=97=E4=BA=AC=EF=BC=89=E7= =BD=91=E7=BB=9C=E6=8A=80=E6=9C=AF=E6=9C=89=E9=99=90=E5=85=AC=E5=8F=B8 =E4=BC=98=E8=AE=AF=E7=BD=91 www.uuwatch.com =E5=9C=B0=E5=9D=80=EF=BC=9A=E5=8C=97=E4=BA=AC=E5=B8=82=E6=B5=B7=E6=B7=80=E5= =8C=BA=E4=B8=8A=E5=9C=B0=E4=BF=A1=E6=81=AF=E8=B7=AF2=E5=8F=B7D=E6=A0=8B412 =E7=94=B5=E8=AF=9D=EF=BC=9A010-82895510 =E4=BC=A0=E7=9C=9F=EF=BC=9A010-82896636 =E6=89=8B=E6=9C=BA=EF=BC=9A15110038983 =E7=94=B5=E9=82=AE=EF=BC=9A*cjjvictory@gmail.com* --0016364ecfeed7b38a04a8bbc836--