mirror of https://github.com/apache/activemq.git
Make sure the leveldb append log file is flushed to disk before it's closed to avoid data loss.
This commit is contained in:
parent
7319697da5
commit
d609d2ae38
|
@ -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) = {
|
||||
|
|
|
@ -148,6 +148,9 @@ class MasterLevelDBClient(val store:MasterLevelDBStore) extends LevelDBClient(st
|
|||
}
|
||||
}
|
||||
|
||||
override def on_close {
|
||||
super.force
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue