@InterfaceAudience.Private public class MemStoreFlusher extends Object implements FlushRequester
FlushRequester
Modifier and Type | Class and Description |
---|---|
private class |
MemStoreFlusher.FlushHandler |
(package private) static interface |
MemStoreFlusher.FlushQueueEntry |
(package private) static class |
MemStoreFlusher.FlushRegionEntry
Datastructure used in the flush queue.
|
Modifier and Type | Field and Description |
---|---|
private long |
blockingWaitTime |
private Object |
blockSignal |
private org.apache.hadoop.conf.Configuration |
conf |
private MemStoreFlusher.FlushHandler[] |
flushHandlers |
private BlockingQueue<MemStoreFlusher.FlushQueueEntry> |
flushQueue |
private List<FlushRequestListener> |
flushRequestListeners |
private ReentrantReadWriteLock |
lock |
private static org.slf4j.Logger |
LOG |
protected Map<Region,MemStoreFlusher.FlushRegionEntry> |
regionsInQueue |
private HRegionServer |
server |
private long |
threadWakeFrequency |
private LongAdder |
updatesBlockedMsHighWater |
private static MemStoreFlusher.FlushQueueEntry |
WAKEUPFLUSH_INSTANCE
Singleton instance inserted into flush queue used for signaling.
|
private AtomicBoolean |
wakeupPending |
Constructor and Description |
---|
MemStoreFlusher(org.apache.hadoop.conf.Configuration conf,
HRegionServer server)
nn
|
Modifier and Type | Method and Description |
---|---|
String |
dumpQueue() |
private boolean |
flushOneForGlobalPressure(FlushType flushType)
The memstore across all regions has exceeded the low water mark.
|
private boolean |
flushRegion(HRegion region,
boolean emergencyFlush,
List<byte[]> families,
FlushLifeCycleTracker tracker)
Flush a region.
|
private boolean |
flushRegion(MemStoreFlusher.FlushRegionEntry fqe)
A flushRegion that checks store file count.
|
private HRegion |
getBiggestMemStoreOfRegionReplica(SortedMap<Long,HRegion> regionsBySize,
Set<HRegion> excludedRegions) |
private HRegion |
getBiggestMemStoreRegion(SortedMap<Long,HRegion> regionsBySize,
Set<HRegion> excludedRegions,
boolean checkStoreFileCount) |
int |
getFlushQueueSize() |
private static long |
getMemStoreDataSize(HRegion r)
Returns Return memstore data size or null if
r is null |
private static long |
getMemStoreHeapSize(HRegion r)
Returns Return memstore heap size or null if
r is null |
private static long |
getMemStoreOffHeapSize(HRegion r)
Returns Return memstore offheap size or null if
r is null |
private int |
getStoreFileCount(Region region) |
LongAdder |
getUpdatesBlockedMsHighWater() |
(package private) void |
interruptIfNecessary()
Only interrupt once it's done with a run through the work loop.
|
private FlushType |
isAboveHighWaterMark()
Return the FlushType if global memory usage is above the high watermark
|
private FlushType |
isAboveLowWaterMark()
Return the FlushType if we're above the low watermark
|
(package private) boolean |
isAlive() |
private boolean |
isTooManyStoreFiles(Region region) |
(package private) void |
join() |
private void |
logMsg(String type,
long val,
long max) |
private void |
notifyFlushRequest(Region region,
boolean emergencyFlush) |
void |
reclaimMemStoreMemory()
Check if the regionserver's memstore memory usage is greater than the limit.
|
private boolean |
refreshStoreFilesAndReclaimMemory(Region region) |
void |
registerFlushRequestListener(FlushRequestListener listener)
Register a MemstoreFlushListener n
|
boolean |
requestDelayedFlush(HRegion r,
long delay)
Tell the listener the cache needs to be flushed after a delay
|
boolean |
requestFlush(HRegion r,
FlushLifeCycleTracker tracker)
Tell the listener the cache needs to be flushed.
|
boolean |
requestFlush(HRegion r,
List<byte[]> families,
FlushLifeCycleTracker tracker)
Tell the listener the cache needs to be flushed.
|
void |
setGlobalMemStoreLimit(long globalMemStoreSize)
Sets the global memstore limit to a new size.
|
(package private) void |
start(Thread.UncaughtExceptionHandler eh) |
String |
toString() |
boolean |
unregisterFlushRequestListener(FlushRequestListener listener)
Unregister the listener from MemstoreFlushListeners n * @return true when passed listener is
unregistered successfully.
|
private void |
wakeupFlushThread() |
private void |
wakeUpIfBlocking() |
private static final org.slf4j.Logger LOG
private org.apache.hadoop.conf.Configuration conf
private final BlockingQueue<MemStoreFlusher.FlushQueueEntry> flushQueue
protected final Map<Region,MemStoreFlusher.FlushRegionEntry> regionsInQueue
private AtomicBoolean wakeupPending
private final long threadWakeFrequency
private final HRegionServer server
private final ReentrantReadWriteLock lock
private final Object blockSignal
private long blockingWaitTime
private final LongAdder updatesBlockedMsHighWater
private final MemStoreFlusher.FlushHandler[] flushHandlers
private List<FlushRequestListener> flushRequestListeners
private static final MemStoreFlusher.FlushQueueEntry WAKEUPFLUSH_INSTANCE
public MemStoreFlusher(org.apache.hadoop.conf.Configuration conf, HRegionServer server)
public LongAdder getUpdatesBlockedMsHighWater()
private boolean flushOneForGlobalPressure(FlushType flushType)
private static long getMemStoreOffHeapSize(HRegion r)
r
is nullprivate static long getMemStoreHeapSize(HRegion r)
r
is nullprivate static long getMemStoreDataSize(HRegion r)
r
is nullprivate void wakeupFlushThread()
private HRegion getBiggestMemStoreRegion(SortedMap<Long,HRegion> regionsBySize, Set<HRegion> excludedRegions, boolean checkStoreFileCount)
private HRegion getBiggestMemStoreOfRegionReplica(SortedMap<Long,HRegion> regionsBySize, Set<HRegion> excludedRegions)
private boolean refreshStoreFilesAndReclaimMemory(Region region)
private FlushType isAboveHighWaterMark()
private FlushType isAboveLowWaterMark()
public boolean requestFlush(HRegion r, FlushLifeCycleTracker tracker)
FlushRequester
requestFlush
in interface FlushRequester
r
- the Region requesting the cache flushpublic boolean requestFlush(HRegion r, List<byte[]> families, FlushLifeCycleTracker tracker)
FlushRequester
requestFlush
in interface FlushRequester
r
- the Region requesting the cache flushfamilies
- stores of region to flush, if null then use flush policypublic boolean requestDelayedFlush(HRegion r, long delay)
FlushRequester
requestDelayedFlush
in interface FlushRequester
r
- the Region requesting the cache flushdelay
- after how much time should the flush happenpublic int getFlushQueueSize()
void interruptIfNecessary()
void start(Thread.UncaughtExceptionHandler eh)
boolean isAlive()
void join()
private boolean flushRegion(MemStoreFlusher.FlushRegionEntry fqe)
private boolean flushRegion(HRegion region, boolean emergencyFlush, List<byte[]> families, FlushLifeCycleTracker tracker)
region
- Region to flush.emergencyFlush
- Set if we are being force flushed. If true the region needs to be removed
from the flush queue. If false, when we were called from the main flusher
run loop and we got the entry to flush by calling poll on the flush queue
(which removed it).families
- stores of region to flush.private void notifyFlushRequest(Region region, boolean emergencyFlush)
private void wakeUpIfBlocking()
private boolean isTooManyStoreFiles(Region region)
private int getStoreFileCount(Region region)
public void reclaimMemStoreMemory()
public void registerFlushRequestListener(FlushRequestListener listener)
registerFlushRequestListener
in interface FlushRequester
public boolean unregisterFlushRequestListener(FlushRequestListener listener)
unregisterFlushRequestListener
in interface FlushRequester
public void setGlobalMemStoreLimit(long globalMemStoreSize)
setGlobalMemStoreLimit
in interface FlushRequester
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.