Author: jdcryans
Date: Fri Oct 30 00:07:37 2009
New Revision: 831165
URL: http://svn.apache.org/viewvc?rev=831165&view=rev
Log:
HBASE-1939 HLog group commit, v3
Modified:
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java
Modified:
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java
URL:
http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java?rev=831165&r1=831164&r2=831165&view=diff
==============================================================================
---
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java
(original)
+++
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java
Fri Oct 30 00:07:37 2009
@@ -35,7 +35,6 @@
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.Condition;
@@ -127,7 +126,7 @@
private final short replicationLevel;
// used to indirectly tell syncFs to force the sync
- private final AtomicBoolean forceSync = new AtomicBoolean(false);
+ private boolean forceSync = false;
/*
* Current log file.
@@ -771,7 +770,7 @@
* This method first signals the thread that there's a sync needed
* and then waits for it to happen before returning.
*/
- public void addToSyncQueue() {
+ public void addToSyncQueue(boolean force) {
// Don't bother if somehow our append was already synced
if (unflushedEntries.get() == 0) {
@@ -779,6 +778,9 @@
}
lock.lock();
try {
+ if(force) {
+ forceSync = true;
+ }
// Wake the thread
queueEmpty.signal();
@@ -803,10 +805,7 @@
* @param force For catalog regions, force the sync to happen
*/
public void sync(boolean force) {
- // Set to force only if it was false and force == true
- // It is reset to false after sync
- forceSync.compareAndSet(!forceSync.get() && !force, true);
- logSyncerThread.addToSyncQueue();
+ logSyncerThread.addToSyncQueue(force);
}
/**
@@ -820,14 +819,14 @@
if (this.closed)
return;
- if (this.forceSync.get() ||
+ if (this.forceSync ||
this.unflushedEntries.get() > this.flushlogentries) {
try {
this.writer.sync();
if (this.writer_out != null) {
this.writer_out.sync();
}
- this.forceSync.compareAndSet(true, false);
+ this.forceSync = false;
this.unflushedEntries.set(0);
} catch (IOException e) {
LOG.fatal("Could not append. Requesting close of hlog", e);