HBASE-728, HBASE-956, HBASE-955 Address thread naming, which threads are Chores, vs Threads, make HLog manager the write ahead log and not extend it to provided optional HLog sync operations.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@708324 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jim Kellerman 2008-10-27 21:28:22 +00:00
parent cf7ae9adcb
commit 2de525ab33
1 changed files with 16 additions and 27 deletions

View File

@ -84,7 +84,7 @@ import org.apache.hadoop.io.SequenceFile.Reader;
* separate reentrant lock is used. * separate reentrant lock is used.
* *
*/ */
public class HLog extends Thread implements HConstants, Syncable { public class HLog implements HConstants, Syncable {
private static final Log LOG = LogFactory.getLog(HLog.class); private static final Log LOG = LogFactory.getLog(HLog.class);
private static final String HLOG_DATFILE = "hlog.dat."; private static final String HLOG_DATFILE = "hlog.dat.";
static final byte [] METACOLUMN = Bytes.toBytes("METACOLUMN:"); static final byte [] METACOLUMN = Bytes.toBytes("METACOLUMN:");
@ -157,7 +157,6 @@ public class HLog extends Thread implements HConstants, Syncable {
this.dir = dir; this.dir = dir;
this.conf = conf; this.conf = conf;
this.listener = listener; this.listener = listener;
this.setName(this.getClass().getSimpleName());
this.maxlogentries = this.maxlogentries =
conf.getInt("hbase.regionserver.maxlogentries", 100000); conf.getInt("hbase.regionserver.maxlogentries", 100000);
this.flushlogentries = this.flushlogentries =
@ -362,9 +361,6 @@ public class HLog extends Thread implements HConstants, Syncable {
try { try {
synchronized (updateLock) { synchronized (updateLock) {
this.closed = true; this.closed = true;
if (this.isAlive()) {
this.interrupt();
}
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("closing log writer in " + this.dir.toString()); LOG.debug("closing log writer in " + this.dir.toString());
} }
@ -433,34 +429,27 @@ public class HLog extends Thread implements HConstants, Syncable {
} }
} }
/** {@inheritDoc} */
@Override
public void run() {
while (!this.closed) {
synchronized (updateLock) {
if (((System.currentTimeMillis() - this.optionalFlushInterval) >
this.lastLogFlushTime) && this.unflushedEntries > 0) {
try {
sync();
} catch (IOException e) {
LOG.error("Error flushing HLog", e);
}
}
try {
updateLock.wait(this.threadWakeFrequency);
} catch (InterruptedException e) {
// continue
}
}
}
}
public void sync() throws IOException { public void sync() throws IOException {
lastLogFlushTime = System.currentTimeMillis(); lastLogFlushTime = System.currentTimeMillis();
this.writer.sync(); this.writer.sync();
unflushedEntries = 0; unflushedEntries = 0;
} }
void optionalSync() {
if (!this.closed) {
synchronized (updateLock) {
if (((System.currentTimeMillis() - this.optionalFlushInterval) >
this.lastLogFlushTime) && this.unflushedEntries > 0) {
try {
sync();
} catch (IOException e) {
LOG.error("Error flushing HLog", e);
}
}
}
}
}
private void requestLogRoll() { private void requestLogRoll() {
if (this.listener != null) { if (this.listener != null) {
this.listener.logRollRequested(); this.listener.logRollRequested();