hbase-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Kellerman <...@powerset.com>
Subject RE: HRegionServer ReentrantReadWriteLock lock
Date Fri, 07 Mar 2008 17:26:48 GMT
The lock is to control multiple threads that are modifying the state or reading the state in
HRegionServer.

In closeAllRegions, closeRegion, closeUserRegions and openRegion a writelock
is used to prevent any other writers from modifying onlineRegions or readers
from accessing the data in onlineRegions. These methods are primarily called
from the Worker thread, but also CompactSplitThread

getRegion, getRegionsToCheck take out a read lock to prevent writers from
modifying onlineRegions while they are accessing it. These methods are
called from multiple Server threads.

Even though onlineRegions is Collections.synchronizedSortedMap, the javadoc
says:

"It is imperative that the user manually synchronize on the returned sorted
map when iterating over any of its collection views, or the collections views
of any of its subMap, headMap or tailMap views."

However if we used synchronized (onlineRegions) that would only allow one
thread to access the structure. Since we want to support multiple readers
and a single writer, we use the ReentrantReadWriteLock to do this.

Make sense?

---
Jim Kellerman, Senior Engineer; Powerset


> -----Original Message-----
> From: Stefan Groschupf [mailto:sg@101tec.com]
> Sent: Thursday, March 06, 2008 11:41 PM
> To: hbase-dev@hadoop.apache.org
> Subject: HRegionServer ReentrantReadWriteLock lock
>
> Hi,
> just another newbie question:
> in HRegionServer is a ReentrantReadWriteLock (line 120) So
> far I can see it is only used in context of dealing with
> onlineRegions. Even the external usage (CompactSpiltThread)
> does onlineRegions operations.
> So I wonder what kind of advantage provides this lock to
> synchronize against onlineRegions?
> I guess I missing something - but what?
> Thanks for any clarification.
> Stefan
>
>
>
>
> No virus found in this incoming message.
> Checked by AVG.
> Version: 7.5.518 / Virus Database: 269.21.6/1318 - Release
> Date: 3/7/2008 2:01 PM
>
>

No virus found in this outgoing message.
Checked by AVG.
Version: 7.5.518 / Virus Database: 269.21.6/1318 - Release Date: 3/7/2008 2:01 PM


Mime
View raw message