hbase-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stack <st...@duboce.net>
Subject Re: svn commit: r703711 - in /hadoop/hbase/trunk: CHANGES.txt src/java/org/apache/hadoop/hbase/RegionHistorian.java src/java/org/apache/hadoop/hbase/master/RegionManager.java
Date Mon, 13 Oct 2008 15:19:21 GMT
Doğacan Güney wrote:
> On Mon, Oct 13, 2008 at 12:43 AM, Jim Kellerman (POWERSET)
> <Jim.Kellerman@microsoft.com> wrote:
>> No, the change to RegionHistorian was only to make the instantiation
>> of the singleton thread safe, which it was not before.
> IIRC what I read about java memory model, you do not need synchronized
> there if you make a few changes:
>   /** Singleton reference */
>   private static RegionHistorian historian = new RegionHistorian();
> I think if you do this, Java guarantees that historian won't be
> initialized until it is accessed
> (because static members are only initialized when a class is loaded)
> and it will be thread-safe.
> So you can get rid of "synchronized" in getInstance.

Agreed.  The above is more the idiom but for some reason, the 
RegionHistorian needs to be lazily instantiated (I looked into this 
before but don't remember why -- smile).  I tried changing it yesterday 
and ran unit tests.  They failed.   It seems the lazy-instantiation is 
still necessary.


View raw message