Make sure the leveldb append log file is flushed to disk before it's closed to avoid data loss.

This commit is contained in:
Hiram Chirino 2013-10-09 11:48:55 -04:00
parent 7319697da5
commit d609d2ae38
3 changed files with 11 additions and 11 deletions

View File

@ -114,12 +114,10 @@ case class RecordLog(directory: File, logSuffix:String) {
override def open = new RandomAccessFile(file, "rw")
override def dispose() = {
flush
super.dispose()
override def on_close ={
force
}
val flushed_offset = new AtomicLong(0)
def append_position = {
@ -233,9 +231,12 @@ case class RecordLog(directory: File, logSuffix:String) {
val channel = fd.getChannel
override def dispose() {
on_close
fd.close()
}
def on_close = {}
def check_read_flush(end_offset:Long) = {}
def read(record_position:Long, length:Int) = {

View File

@ -148,6 +148,9 @@ class MasterLevelDBClient(val store:MasterLevelDBStore) extends LevelDBClient(st
}
}
override def on_close {
super.force
}
}
}

View File

@ -347,14 +347,10 @@ class DFSLevelDBClient(val store:DFSLevelDBStore) extends LevelDBClient(store) {
dfs_os.sync()
}
override def dispose() = {
try {
super.dispose()
} finally {
dfs_os.close()
}
override def on_close {
super.force
dfs_os.close()
}
}
}
}