activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r588725 - in /activemq/trunk/activemq-core/src/main/java/org/apache/activemq: kaha/impl/async/AsyncDataManager.java store/amq/AMQPersistenceAdapter.java
Date Fri, 26 Oct 2007 18:00:15 GMT
Author: chirino
Date: Fri Oct 26 11:00:14 2007
New Revision: 588725

URL: http://svn.apache.org/viewvc?rev=588725&view=rev
Log:
Avoid deleting datafiles that are in-use.. timing issue was making this possible

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/AsyncDataManager.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/AsyncDataManager.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/AsyncDataManager.java?rev=588725&r1=588724&r2=588725&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/AsyncDataManager.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/AsyncDataManager.java
Fri Oct 26 11:00:14 2007
@@ -374,9 +374,20 @@
         }
     }
 
-    public synchronized void consolidateDataFilesNotIn(Set<Integer> inUse) throws IOException
{
+    public synchronized void consolidateDataFilesNotIn(Set<Integer> inUse, Integer
lastDataFile) throws IOException {
         Set<Integer> unUsed = new HashSet<Integer>(fileMap.keySet());
         unUsed.removeAll(inUse);
+        
+        // Don't purge any data files past lastDataFile
+        if( lastDataFile!=null ) {
+            for (Iterator iterator = unUsed.iterator(); iterator.hasNext();) {
+                DataFile dataFile = (DataFile)iterator.next();
+                if( dataFile.getDataFileId() >= lastDataFile ) {
+                    iterator.remove();
+                }
+            }
+        }
+        
         List<DataFile> purgeList = new ArrayList<DataFile>();
         for (Integer key : unUsed) {
             DataFile dataFile = (DataFile)fileMap.get(key);
@@ -581,4 +592,10 @@
 		this.useNio = useNio;
 	}
 
+	
+    synchronized public Integer getCurrentDataFileId() {
+        if( currentWriteFile==null )
+            return null;
+        return currentWriteFile.getDataFileId();
+    }
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java?rev=588725&r1=588724&r2=588725&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java
Fri Oct 26 11:00:14 2007
@@ -351,8 +351,11 @@
      */
     public void cleanup() {
         try {
+            // Capture the lastDataFile so that we don't delete any data files
+            // after this one.
+            Integer lastDataFile = asyncDataManager.getCurrentDataFileId();            
             Set<Integer> inUse = referenceStoreAdapter.getReferenceFileIdsInUse();
-            asyncDataManager.consolidateDataFilesNotIn(inUse);
+            asyncDataManager.consolidateDataFilesNotIn(inUse, lastDataFile);
         } catch (IOException e) {
             LOG.error("Could not cleanup data files: " + e, e);
         }



Mime
View raw message