Fixes AMQ-5115: LevelDB sync=true is not being honored.

This commit is contained in:
Hiram Chirino 2014-03-21 12:54:55 -04:00
parent 2ccc349542
commit db321727c9
2 changed files with 5 additions and 10 deletions

View File

@ -76,8 +76,6 @@ case class RecordLog(directory: File, logSuffix:String) {
var logSize = 1024 * 1024 * 100L var logSize = 1024 * 1024 * 100L
var current_appender:LogAppender = _ var current_appender:LogAppender = _
var verify_checksums = false var verify_checksums = false
var sync = false
val log_infos = new TreeMap[Long, LogInfo]() val log_infos = new TreeMap[Long, LogInfo]()
object log_mutex object log_mutex
@ -130,20 +128,16 @@ case class RecordLog(directory: File, logSuffix:String) {
channel.position(logSize-1) channel.position(logSize-1)
channel.write(new Buffer(1).toByteBuffer) channel.write(new Buffer(1).toByteBuffer)
channel.force(true) channel.force(true)
if( sync ) { channel.position(0)
channel.position(0)
}
} }
val write_buffer = new DataByteArrayOutputStream(BUFFER_SIZE+LOG_HEADER_SIZE) val write_buffer = new DataByteArrayOutputStream(BUFFER_SIZE+LOG_HEADER_SIZE)
def force = { def force = {
flush flush
if(sync) { max_log_flush_latency {
max_log_flush_latency { // only need to update the file metadata if the file size changes..
// only need to update the file metadata if the file size changes.. channel.force(append_offset > logSize)
channel.force(append_offset > logSize)
}
} }
} }

View File

@ -345,6 +345,7 @@ class MasterLevelDBStore extends LevelDBStore with ReplicatedLevelDBStoreTrait {
val value = new LogWrite val value = new LogWrite
value.file = position; value.file = position;
value.offset = offset; value.offset = offset;
value.sync = (syncToMask & SYNC_TO_REMOTE_DISK)!=0
value.length = fileTransferFrame.length value.length = fileTransferFrame.length
value.date = date value.date = date
encoded = JsonCodec.encode(value) encoded = JsonCodec.encode(value)