Return-Path: X-Original-To: apmail-hbase-dev-archive@www.apache.org Delivered-To: apmail-hbase-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 45748872D for ; Wed, 24 Aug 2011 22:13:26 +0000 (UTC) Received: (qmail 27104 invoked by uid 500); 24 Aug 2011 22:13:25 -0000 Delivered-To: apmail-hbase-dev-archive@hbase.apache.org Received: (qmail 26868 invoked by uid 500); 24 Aug 2011 22:13:24 -0000 Mailing-List: contact dev-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list dev@hbase.apache.org Received: (qmail 26859 invoked by uid 99); 24 Aug 2011 22:13:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Aug 2011 22:13:24 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of saint.ack@gmail.com designates 209.85.216.169 as permitted sender) Received: from [209.85.216.169] (HELO mail-qy0-f169.google.com) (209.85.216.169) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Aug 2011 22:13:18 +0000 Received: by qyk27 with SMTP id 27so3887019qyk.14 for ; Wed, 24 Aug 2011 15:12:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; bh=WZzeOHxnj+45YiIDVhl+OTSnJA17TMYEplQ3uQrPicE=; b=iccN2Tq2kOfgt1/mgdn3ClV47L0BaEplwx7jXNik12KIovDIzGdn7JdGQQ2jiiAbXx JqQX04HJagwrdV5jM8RDo2A5cgQwAMjXnxF0n/3HrzqNVodYCuXtz1ZSDG22yWLW01Wh +iEc5JjAO5kqPWCUJeHKPqz7Z0Xwx0xhsnVZw= MIME-Version: 1.0 Received: by 10.229.87.130 with SMTP id w2mr729846qcl.203.1314223977426; Wed, 24 Aug 2011 15:12:57 -0700 (PDT) Sender: saint.ack@gmail.com Received: by 10.224.61.18 with HTTP; Wed, 24 Aug 2011 15:12:27 -0700 (PDT) In-Reply-To: References: Date: Wed, 24 Aug 2011 15:12:27 -0700 X-Google-Sender-Auth: 9ipmdzMjNsnpAP4zzKpnQLD6VRY Message-ID: Subject: Re: Why doesn't HConnectionManager implement double checked locking ? From: Stack To: dev@hbase.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org How would double-checked -- a problematic pattern at the best of times in java (see http://en.wikipedia.org/wiki/Double-checked_locking) -- help here? What you thinking? We can't really do putIfAbsent w/ a connection instance? Good on you Akash, St.Ack On Tue, Aug 23, 2011 at 11:45 AM, Akash Ashok wrot= e: > Hi, > =A0 =A0 I have pasted the code below for HConnectionManager.getConnection > > =A0public static HConnection getConnection(Configuration conf) > =A0throws ZooKeeperConnectionException { > =A0 =A0HConnectionKey connectionKey =3D new HConnectionKey(conf); > =A0 =A0synchronized (HBASE_INSTANCES) { > =A0 =A0 =A0HConnectionImplementation connection =3D > HBASE_INSTANCES.get(connectionKey); > =A0 =A0 =A0if (connection =3D=3D null) { > =A0 =A0 =A0 =A0connection =3D new HConnectionImplementation(conf); > =A0 =A0 =A0 =A0HBASE_INSTANCES.put(connectionKey, connection); > =A0 =A0 =A0} > =A0 =A0 =A0connection.incCount(); > =A0 =A0 =A0return connection; > =A0 =A0} > =A0} > > just curious as to why double checked locking isn't implemented here ? Is= it > because there's won't be too many threads calling this method simultaneou= ly. > ? > > Cheers, > Akash A >