HBASE-3826 Minor compaction needs to check if still over compactionThreshold after compacting

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1125140 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2011-05-19 22:00:27 +00:00
parent 6cc03b35a3
commit 19402cd814
2 changed files with 19 additions and 16 deletions

View File

@ -107,6 +107,8 @@ Release 0.91.0 - Unreleased
jenkins and local jenkins and local
HBASE-3897 Docs (notsoquick guide) suggest invalid XML (Philip Zeyliger) HBASE-3897 Docs (notsoquick guide) suggest invalid XML (Philip Zeyliger)
HBASE-3898 TestSplitTransactionOnCluster broke in TRUNK HBASE-3898 TestSplitTransactionOnCluster broke in TRUNK
HBASE-3826 Minor compaction needs to check if still over
compactionThreshold after compacting (Nicolas Spiegelberg)
IMPROVEMENTS IMPROVEMENTS
HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack) HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack)

View File

@ -133,6 +133,7 @@ import org.apache.hadoop.io.MapWritable;
import org.apache.hadoop.io.Writable; import org.apache.hadoop.io.Writable;
import org.apache.hadoop.ipc.RemoteException; import org.apache.hadoop.ipc.RemoteException;
import org.apache.hadoop.net.DNS; import org.apache.hadoop.net.DNS;
import org.apache.hadoop.util.StringUtils;
import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
@ -232,9 +233,9 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
MemStoreFlusher cacheFlusher; MemStoreFlusher cacheFlusher;
/* /*
* Check for major compactions. * Check for compactions requests.
*/ */
Chore majorCompactionChecker; Chore compactionChecker;
// HLog and HLog roller. log is protected rather than private to avoid // HLog and HLog roller. log is protected rather than private to avoid
// eclipse warning when accessed by inner classes // eclipse warning when accessed by inner classes
@ -565,11 +566,11 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
// Compaction thread // Compaction thread
this.compactSplitThread = new CompactSplitThread(this); this.compactSplitThread = new CompactSplitThread(this);
// Background thread to check for major compactions; needed if region // Background thread to check for compactions; needed if region
// has not gotten updates in a while. Make it run at a lesser frequency. // has not gotten updates in a while. Make it run at a lesser frequency.
int multiplier = this.conf.getInt(HConstants.THREAD_WAKE_FREQUENCY + int multiplier = this.conf.getInt(HConstants.THREAD_WAKE_FREQUENCY +
".multiplier", 1000); ".multiplier", 1000);
this.majorCompactionChecker = new MajorCompactionChecker(this, this.compactionChecker = new CompactionChecker(this,
this.threadWakeFrequency * multiplier, this); this.threadWakeFrequency * multiplier, this);
this.leases = new Leases((int) conf.getLong( this.leases = new Leases((int) conf.getLong(
@ -671,7 +672,8 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
if (this.cacheFlusher != null) this.cacheFlusher.interruptIfNecessary(); if (this.cacheFlusher != null) this.cacheFlusher.interruptIfNecessary();
if (this.compactSplitThread != null) this.compactSplitThread.interruptIfNecessary(); if (this.compactSplitThread != null) this.compactSplitThread.interruptIfNecessary();
if (this.hlogRoller != null) this.hlogRoller.interruptIfNecessary(); if (this.hlogRoller != null) this.hlogRoller.interruptIfNecessary();
if (this.majorCompactionChecker != null) this.majorCompactionChecker.interrupt(); if (this.compactionChecker != null)
this.compactionChecker.interrupt();
if (this.killed) { if (this.killed) {
// Just skip out w/o closing regions. Used when testing. // Just skip out w/o closing regions. Used when testing.
@ -1030,17 +1032,16 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
} }
/* /*
* Inner class that runs on a long period checking if regions need major * Inner class that runs on a long period checking if regions need compaction.
* compaction.
*/ */
private static class MajorCompactionChecker extends Chore { private static class CompactionChecker extends Chore {
private final HRegionServer instance; private final HRegionServer instance;
MajorCompactionChecker(final HRegionServer h, final int sleepTime, CompactionChecker(final HRegionServer h, final int sleepTime,
final Stoppable stopper) { final Stoppable stopper) {
super("MajorCompactionChecker", sleepTime, h); super("CompactionChecker", sleepTime, h);
this.instance = h; this.instance = h;
LOG.info("Runs every " + sleepTime + "ms"); LOG.info("Runs every " + StringUtils.formatTime(sleepTime));
} }
@Override @Override
@ -1050,7 +1051,7 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
continue; continue;
for (Store s : r.getStores().values()) { for (Store s : r.getStores().values()) {
try { try {
if (s.isMajorCompaction()) { if (s.isMajorCompaction() || s.needsCompaction()) {
// Queue a compaction. Will recognize if major is needed. // Queue a compaction. Will recognize if major is needed.
this.instance.compactSplitThread.requestCompaction(r, s, this.instance.compactSplitThread.requestCompaction(r, s,
getName() + " requests major compaction"); getName() + " requests major compaction");
@ -1247,8 +1248,8 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
Threads.setDaemonThreadRunning(this.hlogRoller, n + ".logRoller", handler); Threads.setDaemonThreadRunning(this.hlogRoller, n + ".logRoller", handler);
Threads.setDaemonThreadRunning(this.cacheFlusher, n + ".cacheFlusher", Threads.setDaemonThreadRunning(this.cacheFlusher, n + ".cacheFlusher",
handler); handler);
Threads.setDaemonThreadRunning(this.majorCompactionChecker, n + Threads.setDaemonThreadRunning(this.compactionChecker, n +
".majorCompactionChecker", handler); ".compactionChecker", handler);
// Leases is not a Thread. Internally it runs a daemon thread. If it gets // Leases is not a Thread. Internally it runs a daemon thread. If it gets
// an unhandled exception, it will just exit. // an unhandled exception, it will just exit.
@ -1316,7 +1317,7 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
// Verify that all threads are alive // Verify that all threads are alive
if (!(leases.isAlive() if (!(leases.isAlive()
&& cacheFlusher.isAlive() && hlogRoller.isAlive() && cacheFlusher.isAlive() && hlogRoller.isAlive()
&& this.majorCompactionChecker.isAlive())) { && this.compactionChecker.isAlive())) {
stop("One or more threads are no longer alive -- stop"); stop("One or more threads are no longer alive -- stop");
return false; return false;
} }
@ -1430,7 +1431,7 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
* have already been called. * have already been called.
*/ */
protected void join() { protected void join() {
Threads.shutdown(this.majorCompactionChecker); Threads.shutdown(this.compactionChecker);
Threads.shutdown(this.cacheFlusher); Threads.shutdown(this.cacheFlusher);
Threads.shutdown(this.hlogRoller); Threads.shutdown(this.hlogRoller);
if (this.compactSplitThread != null) { if (this.compactSplitThread != null) {