From db321727c9d68156cd82d92b74f3752cc118c0cd Mon Sep 17 00:00:00 2001 From: Hiram Chirino Date: Fri, 21 Mar 2014 12:54:55 -0400 Subject: [PATCH] Fixes AMQ-5115: LevelDB sync=true is not being honored. --- .../org/apache/activemq/leveldb/RecordLog.scala | 14 ++++---------- .../leveldb/replicated/MasterLevelDBStore.scala | 1 + 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/RecordLog.scala b/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/RecordLog.scala index 08f18a77c7..daef103088 100644 --- a/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/RecordLog.scala +++ b/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/RecordLog.scala @@ -76,8 +76,6 @@ case class RecordLog(directory: File, logSuffix:String) { var logSize = 1024 * 1024 * 100L var current_appender:LogAppender = _ var verify_checksums = false - var sync = false - val log_infos = new TreeMap[Long, LogInfo]() object log_mutex @@ -130,20 +128,16 @@ case class RecordLog(directory: File, logSuffix:String) { channel.position(logSize-1) channel.write(new Buffer(1).toByteBuffer) channel.force(true) - if( sync ) { - channel.position(0) - } + channel.position(0) } val write_buffer = new DataByteArrayOutputStream(BUFFER_SIZE+LOG_HEADER_SIZE) def force = { flush - if(sync) { - max_log_flush_latency { - // only need to update the file metadata if the file size changes.. - channel.force(append_offset > logSize) - } + max_log_flush_latency { + // only need to update the file metadata if the file size changes.. + channel.force(append_offset > logSize) } } diff --git a/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/MasterLevelDBStore.scala b/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/MasterLevelDBStore.scala index 249e0c487d..6de5f63ab4 100644 --- a/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/MasterLevelDBStore.scala +++ b/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/MasterLevelDBStore.scala @@ -345,6 +345,7 @@ class MasterLevelDBStore extends LevelDBStore with ReplicatedLevelDBStoreTrait { val value = new LogWrite value.file = position; value.offset = offset; + value.sync = (syncToMask & SYNC_TO_REMOTE_DISK)!=0 value.length = fileTransferFrame.length value.date = date encoded = JsonCodec.encode(value)