activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1480722 - /activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/LevelDBClient.scala
Date Thu, 09 May 2013 16:52:37 GMT
Author: chirino
Date: Thu May  9 16:52:37 2013
New Revision: 1480722

URL: http://svn.apache.org/r1480722
Log:
Better index copying logic.

Modified:
    activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/LevelDBClient.scala

Modified: activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/LevelDBClient.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/LevelDBClient.scala?rev=1480722&r1=1480721&r2=1480722&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/LevelDBClient.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/LevelDBClient.scala
Thu May  9 16:52:37 2013
@@ -162,6 +162,21 @@ object LevelDBClient extends Log {
     source.copy_to(target)
   }
 
+  def copy_index(from:File, to:File) = {
+    for( file <- from.list_files ) {
+      val name: String = file.getName
+      if( name.endsWith(".sst") ) {
+        // SST files don't change once created, safe to hard link.
+        link(file, to / name)
+      } else if(name == "LOCK")  {
+        // No need to copy the lock file.
+      } else {
+        /// These might not be append only files, so avoid hard linking just to be safe.
+        file.copy_to(to/name)
+      }
+    }
+  }
+
 }
 
 /**
@@ -344,7 +359,13 @@ class LevelDBClient(store: LevelDBStore)
       dirty_index_file.mkdirs()
 
       for( (id, file) <- last_snapshot_index) {
-        copy_index(file, dirty_index_file)
+        try {
+          copy_index(file, dirty_index_file)
+        } catch {
+          case e: Exception =>
+            warn(e, "Could not recover snapshot of the index: " + e)
+            last_snapshot_index = None
+        }
       }
 
       def recover = {
@@ -676,19 +697,6 @@ class LevelDBClient(store: LevelDBStore)
     snapshot_rw_lock.writeLock().unlock()
   }
 
-  def copy_index(from:File, to:File) = {
-    for( file <- from.list_files ) {
-      val name: String = file.getName
-      if( name.endsWith(".sst") ) {
-        // SST files don't change once created, safe to hard link.
-        link(file, to / name)
-      } else {
-        /// These might not be append only files, so avoid hard linking just to be safe.
-        copyLinkStrategy(file, to / name)
-      }
-    }
-  }
-
   def copy_dirty_index_to_snapshot {
     if (log.appender_limit == last_index_snapshot_pos) {
       // no need to snapshot again...



Mime
View raw message