accumulo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Keith Turner <ke...@deenlo.com>
Subject Re: Double Synchronization in TabletServer Class?
Date Wed, 02 Jan 2013 16:31:21 GMT
On Wed, Jan 2, 2013 at 10:44 AM, David Medinets
<david.medinets@gmail.com> wrote:
> I was poking around in
> accumulo/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java
> and noticed the following declaration:
>
>     private final SortedMap<KeyExtent,Tablet> onlineTablets =
> Collections.synchronizedSortedMap(new TreeMap<KeyExtent,Tablet>());
>
> Then I also noticed this code construct in the same file:
>
>   synchronized (openingTablets) {
>     openingTablets.remove(extentToOpen);
>     ...
>     openingTablets.notifyAll();
>   }

notifyAll() must be called within a sync block.

The javadoc for synchronizedSortedMap provides some other use cases
for syncronizing on a synchronized collection.  A synchronized map
makes a single operation on the map atomic.    If you want iterator or
perform multiple operations atomically you must sync.   Java locks are
reentrant so its ok.

>
> My understanding of concurrency is slight but to my untrained eye I am
> seeing a double synchronization. Am I missing something?

Mime
View raw message