@InterfaceAudience.Private public class ReadPointCalculationLock extends Object
RegionScanner
and
HRegion.getSmallestReadPoint()
. We need to ensure that while we are calculating the
smallest read point, no new scanners can modify the scannerReadPoints Map. We used to achieve
this by synchronizing on the scannerReadPoints object. But this may block the read thread and
reduce the read performance. Since the scannerReadPoints object is a
ConcurrentHashMap
, which is thread-safe, so the
RegionScanner
can record their read points concurrently, what it needs to do is just
acquiring a shared lock. When we calculate the smallest read point, we need to acquire an
exclusive lock. This can improve read performance in most scenarios, only not when we have a lot
of delta operations, like Append
or
Increment
. So we introduce a flag to enable/disable this
feature.Modifier and Type | Class and Description |
---|---|
static class |
ReadPointCalculationLock.LockType |
Modifier and Type | Field and Description |
---|---|
private Lock |
lock |
private ReadWriteLock |
readWriteLock |
private boolean |
useReadWriteLockForReadPoints |
Constructor and Description |
---|
ReadPointCalculationLock(org.apache.hadoop.conf.Configuration conf) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
lock(ReadPointCalculationLock.LockType lockType) |
(package private) void |
unlock(ReadPointCalculationLock.LockType lockType) |
private final boolean useReadWriteLockForReadPoints
private ReadWriteLock readWriteLock
ReadPointCalculationLock(org.apache.hadoop.conf.Configuration conf)
void lock(ReadPointCalculationLock.LockType lockType)
void unlock(ReadPointCalculationLock.LockType lockType)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.