diff --git a/CHANGES.txt b/CHANGES.txt index 506ff96be1c..26d02975eef 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -44,6 +44,8 @@ Hbase Change Log HBASE-436 website: http://hadoop.apache.org/hbase HBASE-417 Factor TableOperation and subclasses into separate files from HMaster (Bryan Duxbury via Stack) + HBASE-440 Add optional log roll interval so that log files are garbage + collected Branch 0.1 diff --git a/conf/hbase-default.xml b/conf/hbase-default.xml index da4a7e01463..f40527bb530 100644 --- a/conf/hbase-default.xml +++ b/conf/hbase-default.xml @@ -155,6 +155,16 @@ Default: 30 minutes (in miliseconds) + + hbase.regionserver.optionallogrollinterval + 1800000 + + Amount of time to wait since the last time a the region server's log was + rolled before invoking an optional log roll (An optional log roll is a + one in which the log does not contain hbase.regionserver.maxlogentries). + Default: 30 minutes (in miliseconds) + + hbase.hregion.memcache.flush.size 67108864 diff --git a/src/java/org/apache/hadoop/hbase/HRegionServer.java b/src/java/org/apache/hadoop/hbase/HRegionServer.java index 8978a0667c3..57cd8767d8d 100644 --- a/src/java/org/apache/hadoop/hbase/HRegionServer.java +++ b/src/java/org/apache/hadoop/hbase/HRegionServer.java @@ -508,12 +508,17 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable { /** Runs periodically to determine if the HLog should be rolled */ class LogRoller extends Thread implements LogRollListener { private final Integer rollLock = new Integer(0); + private final long optionalLogRollInterval; + private long lastLogRollTime; private volatile boolean rollLog; /** constructor */ public LogRoller() { super(); + this.optionalLogRollInterval = conf.getLong( + "hbase.regionserver.optionallogrollinterval", 30L * 60L * 1000L); this.rollLog = false; + lastLogRollTime = System.currentTimeMillis(); } /** {@inheritDoc} */ @@ -521,12 +526,18 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable { public void run() { while (!stopRequested.get()) { while (!rollLog && !stopRequested.get()) { - synchronized (rollLock) { - try { - rollLock.wait(threadWakeFrequency); + long now = System.currentTimeMillis(); + if (this.lastLogRollTime + this.optionalLogRollInterval <= now) { + rollLog = true; + this.lastLogRollTime = now; + } else { + synchronized (rollLock) { + try { + rollLock.wait(threadWakeFrequency); - } catch (InterruptedException e) { - continue; + } catch (InterruptedException e) { + continue; + } } } }