HBASE-440 Add optional log roll interval so that log files are garbage collected

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@627152 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jim Kellerman 2008-02-12 22:19:24 +00:00
parent ef9a7c1017
commit 8b2c345d4c
3 changed files with 28 additions and 5 deletions

View File

@ -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

View File

@ -155,6 +155,16 @@
Default: 30 minutes (in miliseconds)
</description>
</property>
<property>
<name>hbase.regionserver.optionallogrollinterval</name>
<value>1800000</value>
<description>
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)
</description>
</property>
<property>
<name>hbase.hregion.memcache.flush.size</name>
<value>67108864</value>

View File

@ -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;
}
}
}
}