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 open = new RandomAccessFile(file, "rw")
|
||||||
|
|
||||||
override def dispose() = {
|
override def on_close ={
|
||||||
flush
|
force
|
||||||
super.dispose()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val flushed_offset = new AtomicLong(0)
|
val flushed_offset = new AtomicLong(0)
|
||||||
|
|
||||||
def append_position = {
|
def append_position = {
|
||||||
|
@ -233,9 +231,12 @@ case class RecordLog(directory: File, logSuffix:String) {
|
||||||
val channel = fd.getChannel
|
val channel = fd.getChannel
|
||||||
|
|
||||||
override def dispose() {
|
override def dispose() {
|
||||||
|
on_close
|
||||||
fd.close()
|
fd.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def on_close = {}
|
||||||
|
|
||||||
def check_read_flush(end_offset:Long) = {}
|
def check_read_flush(end_offset:Long) = {}
|
||||||
|
|
||||||
def read(record_position:Long, length:Int) = {
|
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,15 +347,11 @@ class DFSLevelDBClient(val store:DFSLevelDBStore) extends LevelDBClient(store) {
|
||||||
dfs_os.sync()
|
dfs_os.sync()
|
||||||
}
|
}
|
||||||
|
|
||||||
override def dispose() = {
|
override def on_close {
|
||||||
try {
|
super.force
|
||||||
super.dispose()
|
|
||||||
} finally {
|
|
||||||
dfs_os.close()
|
dfs_os.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue