activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r1159570 - in /activemq/trunk: activemq-core/src/test/java/org/apache/activemq/usecases/DurableUnsubscribeTest.java kahadb/src/main/java/org/apache/kahadb/page/PageFile.java kahadb/src/main/java/org/apache/kahadb/page/Transaction.java
Date Fri, 19 Aug 2011 10:16:34 GMT
Author: dejanb
Date: Fri Aug 19 10:16:33 2011
New Revision: 1159570

URL: http://svn.apache.org/viewvc?rev=1159570&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3374,https://issues.apache.org/jira/browse/AMQ-3443
- long kahadb tx, delayed tmp file removal

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableUnsubscribeTest.java
    activemq/trunk/kahadb/src/main/java/org/apache/kahadb/page/PageFile.java
    activemq/trunk/kahadb/src/main/java/org/apache/kahadb/page/Transaction.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableUnsubscribeTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableUnsubscribeTest.java?rev=1159570&r1=1159569&r2=1159570&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableUnsubscribeTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableUnsubscribeTest.java
Fri Aug 19 10:16:33 2011
@@ -104,6 +104,7 @@ public class DurableUnsubscribeTest exte
         //broker.setPersistent(false);
         broker.setUseJmx(true);
         broker.setBrokerName(getName());
+        broker.deleteAllMessages();
         broker.start();
 
         connection = createConnection();

Modified: activemq/trunk/kahadb/src/main/java/org/apache/kahadb/page/PageFile.java
URL: http://svn.apache.org/viewvc/activemq/trunk/kahadb/src/main/java/org/apache/kahadb/page/PageFile.java?rev=1159570&r1=1159569&r2=1159570&view=diff
==============================================================================
--- activemq/trunk/kahadb/src/main/java/org/apache/kahadb/page/PageFile.java (original)
+++ activemq/trunk/kahadb/src/main/java/org/apache/kahadb/page/PageFile.java Fri Aug 19 10:16:33
2011
@@ -131,6 +131,8 @@ public class PageFile {
     // Persistent settings stored in the page file. 
     private MetaData metaData;
 
+    private ArrayList<File> tmpFilesForRemoval = new ArrayList<File>();
+
     /**
      * Use to keep track of updated pages which have not yet been committed.
      */
@@ -1042,6 +1044,12 @@ public class PageFile {
                      // the write cache.
                      if (w.isDone()) {
                          writes.remove(w.page.getPageId());
+                         if (w.tmpFile != null && tmpFilesForRemoval.contains(w.tmpFile))
{
+                             if (!w.tmpFile.delete()) {
+                                 throw new IOException("Can't delete temporary KahaDB transaction
file:" + w.tmpFile);
+                             }
+                             tmpFilesForRemoval.remove(w.tmpFile);
+                         }
                      }
                  }
              }
@@ -1052,6 +1060,10 @@ public class PageFile {
          }
      }
 
+    public void removeTmpFile(File file) {
+        tmpFilesForRemoval.add(file);
+    }
+
     private long recoveryFileSizeForPages(int pageCount) {
         return RECOVERY_FILE_HEADER_SIZE+((pageSize+8)*pageCount);
     }

Modified: activemq/trunk/kahadb/src/main/java/org/apache/kahadb/page/Transaction.java
URL: http://svn.apache.org/viewvc/activemq/trunk/kahadb/src/main/java/org/apache/kahadb/page/Transaction.java?rev=1159570&r1=1159569&r2=1159570&view=diff
==============================================================================
--- activemq/trunk/kahadb/src/main/java/org/apache/kahadb/page/Transaction.java (original)
+++ activemq/trunk/kahadb/src/main/java/org/apache/kahadb/page/Transaction.java Fri Aug 19
10:16:33 2011
@@ -636,6 +636,12 @@ public class Transaction implements Iter
      */
     public void commit() throws IOException {
         if( writeTransactionId!=-1 ) {
+            if (tmpFile != null) {
+                tmpFile.close();
+                pageFile.removeTmpFile(getTempFile());
+                tmpFile = null;
+                txFile = null;
+            }
             // Actually do the page writes...
             pageFile.write(writes.entrySet());
             // Release the pages that were freed up in the transaction..
@@ -645,14 +651,6 @@ public class Transaction implements Iter
             allocateList.clear();
             writes.clear();
             writeTransactionId = -1;
-            if (tmpFile != null) {
-                tmpFile.close();
-                if (!getTempFile().delete()) {
-                    throw new IOException("Can't delete temporary KahaDB transaction file:"
 + getTempFile());
-                }
-                tmpFile = null;
-                txFile = null;
-            }
         }
         size = 0;
     }
@@ -662,6 +660,12 @@ public class Transaction implements Iter
      */
     public void rollback() throws IOException {
         if( writeTransactionId!=-1 ) {
+            if (tmpFile != null) {
+                tmpFile.close();
+                pageFile.removeTmpFile(getTempFile());
+                tmpFile = null;
+                txFile = null;
+            }
             // Release the pages that were allocated in the transaction...
             freePages(allocateList);
 
@@ -669,14 +673,6 @@ public class Transaction implements Iter
             allocateList.clear();
             writes.clear();
             writeTransactionId = -1;
-            if (tmpFile != null) {
-                tmpFile.close();
-                if (getTempFile().delete()) {
-                    throw new IOException("Can't delete temporary KahaDB transaction file:"
 + getTempFile());
-                }
-                tmpFile = null;
-                txFile = null;
-            }
         }
         size = 0;
     }



Mime
View raw message