activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject git commit: Make sure the leveldb append log file is flushed to disk before it's closed to avoid data loss.
Date Wed, 09 Oct 2013 15:49:25 GMT
Updated Branches:
  refs/heads/trunk 7319697da -> d609d2ae3


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


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/d609d2ae
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/d609d2ae
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/d609d2ae

Branch: refs/heads/trunk
Commit: d609d2ae38cb2c99fa3f3408107c5e099de727dd
Parents: 7319697
Author: Hiram Chirino <hiram@hiramchirino.com>
Authored: Wed Oct 9 11:48:55 2013 -0400
Committer: Hiram Chirino <hiram@hiramchirino.com>
Committed: Wed Oct 9 11:49:11 2013 -0400

----------------------------------------------------------------------
 .../scala/org/apache/activemq/leveldb/RecordLog.scala     |  9 +++++----
 .../activemq/leveldb/replicated/MasterLevelDBClient.scala |  3 +++
 .../apache/activemq/leveldb/dfs/DFSLevelDBClient.scala    | 10 +++-------
 3 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/d609d2ae/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/RecordLog.scala
----------------------------------------------------------------------
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 abf967b..1dc94aa 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
@@ -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) = {

http://git-wip-us.apache.org/repos/asf/activemq/blob/d609d2ae/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/MasterLevelDBClient.scala
----------------------------------------------------------------------
diff --git a/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/MasterLevelDBClient.scala
b/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/MasterLevelDBClient.scala
index 95a7e73..8813e6c 100644
--- a/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/MasterLevelDBClient.scala
+++ b/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/MasterLevelDBClient.scala
@@ -148,6 +148,9 @@ class MasterLevelDBClient(val store:MasterLevelDBStore) extends LevelDBClient(st
           }
         }
 
+        override def on_close {
+          super.force
+        }
       }
     }
 

http://git-wip-us.apache.org/repos/asf/activemq/blob/d609d2ae/activemq-leveldb-store/src/test/scala/org/apache/activemq/leveldb/dfs/DFSLevelDBClient.scala
----------------------------------------------------------------------
diff --git a/activemq-leveldb-store/src/test/scala/org/apache/activemq/leveldb/dfs/DFSLevelDBClient.scala
b/activemq-leveldb-store/src/test/scala/org/apache/activemq/leveldb/dfs/DFSLevelDBClient.scala
index fa34148..586aff8 100644
--- a/activemq-leveldb-store/src/test/scala/org/apache/activemq/leveldb/dfs/DFSLevelDBClient.scala
+++ b/activemq-leveldb-store/src/test/scala/org/apache/activemq/leveldb/dfs/DFSLevelDBClient.scala
@@ -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()
         }
-
       }
     }
   }


Mime
View raw message