HBASE-13745 Say why a flush was requested in log message
This commit is contained in:
parent
e5df9bb2e2
commit
a6cf9c51d9
|
@ -1942,10 +1942,12 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
|||
/**
|
||||
* Should the memstore be flushed now
|
||||
*/
|
||||
boolean shouldFlush() {
|
||||
boolean shouldFlush(final StringBuffer whyFlush) {
|
||||
whyFlush.setLength(0);
|
||||
// This is a rough measure.
|
||||
if (this.maxFlushedSeqId > 0
|
||||
&& (this.maxFlushedSeqId + this.flushPerChanges < this.sequenceId.get())) {
|
||||
whyFlush.append("more than max edits, " + this.flushPerChanges + ", since last flush");
|
||||
return true;
|
||||
}
|
||||
long modifiedFlushCheckInterval = flushCheckInterval;
|
||||
|
@ -1966,6 +1968,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
|||
for (Store s : getStores()) {
|
||||
if (s.timeOfOldestEdit() < now - modifiedFlushCheckInterval) {
|
||||
// we have an old enough edit in the memstore, flush
|
||||
whyFlush.append(s.toString() + " has an old edit so flush to free WALs");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1548,15 +1548,17 @@ public class HRegionServer extends HasThread implements
|
|||
|
||||
@Override
|
||||
protected void chore() {
|
||||
final StringBuffer whyFlush = new StringBuffer();
|
||||
for (Region r : this.server.onlineRegions.values()) {
|
||||
if (r == null)
|
||||
continue;
|
||||
if (((HRegion)r).shouldFlush()) {
|
||||
if (r == null) continue;
|
||||
if (((HRegion)r).shouldFlush(whyFlush)) {
|
||||
FlushRequester requester = server.getFlushRequester();
|
||||
if (requester != null) {
|
||||
long randomDelay = RandomUtils.nextInt(RANGE_OF_DELAY) + MIN_DELAY_TIME;
|
||||
LOG.info(getName() + " requesting flush for region " +
|
||||
r.getRegionInfo().getRegionNameAsString() + " after a delay of " + randomDelay);
|
||||
LOG.info(getName() + " requesting flush of " +
|
||||
r.getRegionInfo().getRegionNameAsString() + " because " +
|
||||
whyFlush.toString() +
|
||||
" after random delay " + randomDelay + "ms");
|
||||
//Throttle the flushes by putting a delay. If we don't throttle, and there
|
||||
//is a balanced write-load on the regions in a table, we might end up
|
||||
//overwhelming the filesystem with too many flushes at once.
|
||||
|
|
|
@ -927,9 +927,10 @@ public class TestDefaultMemStore extends TestCase {
|
|||
edge.setCurrentTimeMillis(1234);
|
||||
s.add(KeyValueTestUtil.create("r", "f", "q", 100, "v"));
|
||||
edge.setCurrentTimeMillis(1234 + 100);
|
||||
assertTrue(region.shouldFlush() == false);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
assertTrue(region.shouldFlush(sb) == false);
|
||||
edge.setCurrentTimeMillis(1234 + 10000);
|
||||
assertTrue(region.shouldFlush() == expected);
|
||||
assertTrue(region.shouldFlush(sb) == expected);
|
||||
} finally {
|
||||
EnvironmentEdgeManager.reset();
|
||||
}
|
||||
|
@ -960,9 +961,10 @@ public class TestDefaultMemStore extends TestCase {
|
|||
wFactory.getWAL(hri.getEncodedNameAsBytes()));
|
||||
HRegion.addRegionToMETA(meta, r);
|
||||
edge.setCurrentTimeMillis(1234 + 100);
|
||||
assertTrue(meta.shouldFlush() == false);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
assertTrue(meta.shouldFlush(sb) == false);
|
||||
edge.setCurrentTimeMillis(edge.currentTime() + HRegion.META_CACHE_FLUSH_INTERVAL + 1);
|
||||
assertTrue(meta.shouldFlush() == true);
|
||||
assertTrue(meta.shouldFlush(sb) == true);
|
||||
}
|
||||
|
||||
private class EnvironmentEdgeForMemstoreTest implements EnvironmentEdge {
|
||||
|
|
Loading…
Reference in New Issue