Class MemStoreFlusher
java.lang.Object
org.apache.hadoop.hbase.regionserver.MemStoreFlusher
- All Implemented Interfaces:
ConfigurationObserver,FlushRequester
@Private
public class MemStoreFlusher
extends Object
implements FlushRequester, ConfigurationObserver
Thread that flushes cache on request NOTE: This class extends Thread rather than Chore because
the sleep time can be interrupted when there is something to do, rather than the Chore sleep time
which is invariant.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class(package private) static interface(package private) static classDatastructure used in the flush queue. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longprivate final Objectprivate org.apache.hadoop.conf.Configurationprivate final AtomicIntegerprivate ThreadFactoryprivate MemStoreFlusher.FlushHandler[]private final BlockingQueue<MemStoreFlusher.FlushQueueEntry>private List<FlushRequestListener>private final ReentrantReadWriteLockprivate static final org.slf4j.Loggerprotected final Map<Region,MemStoreFlusher.FlushRegionEntry> private final HRegionServerprivate final longprivate final LongAdderprivate static final MemStoreFlusher.FlushQueueEntrySingleton instance inserted into flush queue used for signaling.private AtomicBoolean -
Constructor Summary
ConstructorsConstructorDescriptionMemStoreFlusher(org.apache.hadoop.conf.Configuration conf, HRegionServer server) -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanflushOneForGlobalPressure(FlushType flushType) The memstore across all regions has exceeded the low water mark.private booleanflushRegion(HRegion region, boolean emergencyFlush, List<byte[]> families, FlushLifeCycleTracker tracker) Flush a region.private booleanA flushRegion that checks store file count.private HRegiongetBiggestMemStoreOfRegionReplica(SortedMap<Long, HRegion> regionsBySize, Set<HRegion> excludedRegions) private HRegiongetBiggestMemStoreRegion(SortedMap<Long, HRegion> regionsBySize, Set<HRegion> excludedRegions, boolean checkStoreFileCount) intintprivate intgetHandlerCount(org.apache.hadoop.conf.Configuration conf) private static longReturns Return memstore data size or null ifris nullprivate static longReturns Return memstore heap size or null ifris nullprivate static longReturns Return memstore offheap size or null ifris nullprivate intgetStoreFileCount(Region region) (package private) voidOnly interrupt once it's done with a run through the work loop.private FlushTypeReturn the FlushType if global memory usage is above the high watermarkprivate FlushTypeReturn the FlushType if we're above the low watermark(package private) booleanisAlive()private booleanisTooManyStoreFiles(Region region) private voidprivate voidnotifyFlushRequest(Region region, boolean emergencyFlush) voidonConfigurationChange(org.apache.hadoop.conf.Configuration newConf) This method would be called by theConfigurationManagerobject when theConfigurationobject is reloaded from disk.voidCheck if the regionserver's memstore memory usage is greater than the limit.private booleanvoidRegister a MemstoreFlushListenerbooleanrequestDelayedFlush(HRegion r, long delay) Tell the listener the cache needs to be flushed after a delaybooleanrequestFlush(HRegion r, List<byte[]> families, FlushLifeCycleTracker tracker) Tell the listener the cache needs to be flushed.booleanrequestFlush(HRegion r, FlushLifeCycleTracker tracker) Tell the listener the cache needs to be flushed.voidsetGlobalMemStoreLimit(long globalMemStoreSize) Sets the global memstore limit to a new size.(package private) voidshutdown()(package private) voidprivate voidstartFlushHandlerThreads(MemStoreFlusher.FlushHandler[] flushHandlers, int start, int end) private voidstopFlushHandlerThreads(MemStoreFlusher.FlushHandler[] flushHandlers, int start, int end) toString()booleanUnregister the listener from MemstoreFlushListenersprivate voidprivate void
-
Field Details
-
LOG
-
conf
-
flushQueue
-
regionsInQueue
-
wakeupPending
-
threadWakeFrequency
-
server
-
lock
-
blockSignal
-
blockingWaitTime
-
updatesBlockedMsHighWater
-
flushHandlers
-
flusherIdGen
-
flusherThreadFactory
-
flushRequestListeners
-
WAKEUPFLUSH_INSTANCE
Singleton instance inserted into flush queue used for signaling.
-
-
Constructor Details
-
MemStoreFlusher
-
-
Method Details
-
getUpdatesBlockedMsHighWater
-
flushOneForGlobalPressure
The memstore across all regions has exceeded the low water mark. Pick one region to flush and flush it synchronously (this is called from the flush thread)- Returns:
- true if successful
-
getMemStoreOffHeapSize
Returns Return memstore offheap size or null ifris null -
getMemStoreHeapSize
Returns Return memstore heap size or null ifris null -
getMemStoreDataSize
Returns Return memstore data size or null ifris null -
wakeupFlushThread
-
getBiggestMemStoreRegion
-
getBiggestMemStoreOfRegionReplica
-
refreshStoreFilesAndReclaimMemory
-
isAboveHighWaterMark
Return the FlushType if global memory usage is above the high watermark -
isAboveLowWaterMark
Return the FlushType if we're above the low watermark -
requestFlush
Description copied from interface:FlushRequesterTell the listener the cache needs to be flushed.- Specified by:
requestFlushin interfaceFlushRequester- Parameters:
r- the Region requesting the cache flush- Returns:
- true if our region is added into the queue, false otherwise
-
requestFlush
Description copied from interface:FlushRequesterTell the listener the cache needs to be flushed.- Specified by:
requestFlushin interfaceFlushRequester- Parameters:
r- the Region requesting the cache flushfamilies- stores of region to flush, if null then use flush policy- Returns:
- true if our region is added into the queue, false otherwise
-
requestDelayedFlush
Description copied from interface:FlushRequesterTell the listener the cache needs to be flushed after a delay- Specified by:
requestDelayedFlushin interfaceFlushRequester- Parameters:
r- the Region requesting the cache flushdelay- after how much time should the flush happen- Returns:
- true if our region is added into the queue, false otherwise
-
getFlushQueueSize
-
interruptIfNecessary
void interruptIfNecessary()Only interrupt once it's done with a run through the work loop. -
start
-
isAlive
boolean isAlive() -
shutdown
void shutdown() -
flushRegion
A flushRegion that checks store file count. If too many, puts the flush on delay queue to retry later.- Returns:
- true if the region was successfully flushed, false otherwise. If false, there will be accompanying log messages explaining why the region was not flushed.
-
flushRegion
private boolean flushRegion(HRegion region, boolean emergencyFlush, List<byte[]> families, FlushLifeCycleTracker tracker) Flush a region.- Parameters:
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.- Returns:
- true if the region was successfully flushed, false otherwise. If false, there will be accompanying log messages explaining why the region was not flushed.
-
notifyFlushRequest
-
wakeUpIfBlocking
-
isTooManyStoreFiles
-
getStoreFileCount
-
reclaimMemStoreMemory
Check if the regionserver's memstore memory usage is greater than the limit. If so, flush regions with the biggest memstores until we're down to the lower limit. This method blocks callers until we're down to a safe amount of memstore consumption. -
logMsg
-
toString
-
dumpQueue
-
registerFlushRequestListener
Register a MemstoreFlushListener- Specified by:
registerFlushRequestListenerin interfaceFlushRequester
-
unregisterFlushRequestListener
Unregister the listener from MemstoreFlushListeners- Specified by:
unregisterFlushRequestListenerin interfaceFlushRequester- Returns:
- true when passed listener is unregistered successfully.
-
setGlobalMemStoreLimit
Sets the global memstore limit to a new size.- Specified by:
setGlobalMemStoreLimitin interfaceFlushRequester
-
getHandlerCount
-
onConfigurationChange
Description copied from interface:ConfigurationObserverThis method would be called by theConfigurationManagerobject when theConfigurationobject is reloaded from disk.- Specified by:
onConfigurationChangein interfaceConfigurationObserver
-
startFlushHandlerThreads
private void startFlushHandlerThreads(MemStoreFlusher.FlushHandler[] flushHandlers, int start, int end) -
stopFlushHandlerThreads
private void stopFlushHandlerThreads(MemStoreFlusher.FlushHandler[] flushHandlers, int start, int end) -
getFlusherCount
-