hbase-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stack <st...@duboce.net>
Subject Re: Why doesn't HConnectionManager implement double checked locking ?
Date Wed, 24 Aug 2011 22:12:27 GMT
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 <thehellmaker@gmail.com> wrote:
> Hi,
>     I have pasted the code below for HConnectionManager.getConnection
>
>  public static HConnection getConnection(Configuration conf)
>  throws ZooKeeperConnectionException {
>    HConnectionKey connectionKey = new HConnectionKey(conf);
>    synchronized (HBASE_INSTANCES) {
>      HConnectionImplementation connection =
> HBASE_INSTANCES.get(connectionKey);
>      if (connection == null) {
>        connection = new HConnectionImplementation(conf);
>        HBASE_INSTANCES.put(connectionKey, connection);
>      }
>      connection.incCount();
>      return connection;
>    }
>  }
>
> 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 simultaneouly.
> ?
>
> Cheers,
> Akash A
>

Mime
View raw message