HBASE-1939 HLog group commit, v3
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@831165 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
279ac982a7
commit
535651ce1d
|
@ -35,7 +35,6 @@ import java.util.TreeMap;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.concurrent.locks.Condition;
|
import java.util.concurrent.locks.Condition;
|
||||||
|
@ -127,7 +126,7 @@ public class HLog implements HConstants, Syncable {
|
||||||
private final short replicationLevel;
|
private final short replicationLevel;
|
||||||
|
|
||||||
// used to indirectly tell syncFs to force the sync
|
// used to indirectly tell syncFs to force the sync
|
||||||
private final AtomicBoolean forceSync = new AtomicBoolean(false);
|
private boolean forceSync = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Current log file.
|
* Current log file.
|
||||||
|
@ -771,7 +770,7 @@ public class HLog implements HConstants, Syncable {
|
||||||
* This method first signals the thread that there's a sync needed
|
* This method first signals the thread that there's a sync needed
|
||||||
* and then waits for it to happen before returning.
|
* 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
|
// Don't bother if somehow our append was already synced
|
||||||
if (unflushedEntries.get() == 0) {
|
if (unflushedEntries.get() == 0) {
|
||||||
|
@ -779,6 +778,9 @@ public class HLog implements HConstants, Syncable {
|
||||||
}
|
}
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
|
if(force) {
|
||||||
|
forceSync = true;
|
||||||
|
}
|
||||||
// Wake the thread
|
// Wake the thread
|
||||||
queueEmpty.signal();
|
queueEmpty.signal();
|
||||||
|
|
||||||
|
@ -803,10 +805,7 @@ public class HLog implements HConstants, Syncable {
|
||||||
* @param force For catalog regions, force the sync to happen
|
* @param force For catalog regions, force the sync to happen
|
||||||
*/
|
*/
|
||||||
public void sync(boolean force) {
|
public void sync(boolean force) {
|
||||||
// Set to force only if it was false and force == true
|
logSyncerThread.addToSyncQueue(force);
|
||||||
// It is reset to false after sync
|
|
||||||
forceSync.compareAndSet(!forceSync.get() && !force, true);
|
|
||||||
logSyncerThread.addToSyncQueue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -820,14 +819,14 @@ public class HLog implements HConstants, Syncable {
|
||||||
if (this.closed)
|
if (this.closed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this.forceSync.get() ||
|
if (this.forceSync ||
|
||||||
this.unflushedEntries.get() > this.flushlogentries) {
|
this.unflushedEntries.get() > this.flushlogentries) {
|
||||||
try {
|
try {
|
||||||
this.writer.sync();
|
this.writer.sync();
|
||||||
if (this.writer_out != null) {
|
if (this.writer_out != null) {
|
||||||
this.writer_out.sync();
|
this.writer_out.sync();
|
||||||
}
|
}
|
||||||
this.forceSync.compareAndSet(true, false);
|
this.forceSync = false;
|
||||||
this.unflushedEntries.set(0);
|
this.unflushedEntries.set(0);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.fatal("Could not append. Requesting close of hlog", e);
|
LOG.fatal("Could not append. Requesting close of hlog", e);
|
||||||
|
|
Loading…
Reference in New Issue