@InterfaceAudience.Private 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 FlushType |
flushType |
private ReentrantReadWriteLock |
lock |
private static org.slf4j.Logger |
LOG |
private 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) |
Modifier and Type | Method and Description |
---|---|
String |
dumpQueue() |
private boolean |
flushOneForGlobalPressure()
The memstore across all regions has exceeded the low water mark.
|
private boolean |
flushRegion(HRegion region,
boolean emergencyFlush,
boolean forceFlushAllStores,
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) |
private static long |
getMemStoreHeapSize(HRegion r) |
private static long |
getMemStoreOffHeapSize(HRegion r) |
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 true if global memory usage is above the high watermark
|
private FlushType |
isAboveLowWaterMark()
Return true 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
|
boolean |
requestDelayedFlush(HRegion r,
long delay,
boolean forceFlushAllStores)
Tell the listener the cache needs to be flushed after a delay
|
boolean |
requestFlush(HRegion r,
boolean forceFlushAllStores,
FlushLifeCycleTracker tracker)
Tell the listener the cache needs to be flushed.
|
void |
setFlushType(FlushType flushType) |
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
|
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
private 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)
conf
- server
- public LongAdder getUpdatesBlockedMsHighWater()
public void setFlushType(FlushType flushType)
private boolean flushOneForGlobalPressure()
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, boolean forceFlushAllStores, FlushLifeCycleTracker tracker)
FlushRequester
requestFlush
in interface FlushRequester
r
- the Region requesting the cache flushforceFlushAllStores
- whether we want to flush all stores. e.g., when request from log
rolling.public boolean requestDelayedFlush(HRegion r, long delay, boolean forceFlushAllStores)
FlushRequester
requestDelayedFlush
in interface FlushRequester
r
- the Region requesting the cache flushdelay
- after how much time should the flush happenforceFlushAllStores
- whether we want to flush all stores. e.g., when request from log
rolling.public int getFlushQueueSize()
void interruptIfNecessary()
void start(Thread.UncaughtExceptionHandler eh)
boolean isAlive()
void join()
private boolean flushRegion(MemStoreFlusher.FlushRegionEntry fqe)
fqe
- private boolean flushRegion(HRegion region, boolean emergencyFlush, boolean forceFlushAllStores, 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).forceFlushAllStores
- whether we want to flush all store.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
listener
- public boolean unregisterFlushRequestListener(FlushRequestListener listener)
unregisterFlushRequestListener
in interface FlushRequester
listener
- public void setGlobalMemStoreLimit(long globalMemStoreSize)
setGlobalMemStoreLimit
in interface FlushRequester
globalMemStoreSize
- Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.