Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Accumulo, mail # dev - Double Synchronization in TabletServer Class?


+
David Medinets 2013-01-02, 15:44
Copy link to this message
-
Re: Double Synchronization in TabletServer Class?
Keith Turner 2013-01-02, 16:31
On Wed, Jan 2, 2013 at 10:44 AM, David Medinets
<[EMAIL PROTECTED]> 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?