activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r962468 - in /activemq/trunk: activemq-core/src/main/java/org/apache/activemq/store/kahadb/ kahadb/src/main/java/org/apache/kahadb/journal/
Date Fri, 09 Jul 2010 09:52:44 GMT
Author: gtully
Date: Fri Jul  9 09:52:43 2010
New Revision: 962468

URL: http://svn.apache.org/viewvc?rev=962468&view=rev
Log:
resolve PerDestinationStoreLimitTest - have store size reflect stored messages rather than
disk usage (so now it reports used rather than allocated disk soace excluding the index) such
that 100MB messages gives store size ~100MB while disk utilisation may be bigger. getDiskSize
still exsits to get totall allocated space on disk. This allows configured limits to be more
accuratly enforced and fixes this test regression. Also calculation is accumulative rather
than on demand so it much faster

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java
    activemq/trunk/kahadb/src/main/java/org/apache/kahadb/journal/Journal.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java?rev=962468&r1=962467&r2=962468&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java
Fri Jul  9 09:52:43 2010
@@ -914,14 +914,7 @@ public class KahaDBStore extends Message
     }
 
     public long size() {
-        if (!isStarted()) {
-            return 0;
-        }
-        try {
-            return journal.getDiskSize() + pageFile.getDiskSize();
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
+        return storeSize.get();
     }
 
     public void beginTransaction(ConnectionContext context) throws IOException {

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java?rev=962468&r1=962467&r2=962468&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java
Fri Jul  9 09:52:43 2010
@@ -39,6 +39,7 @@ import java.util.TreeMap;
 import java.util.TreeSet;
 import java.util.Map.Entry;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import org.apache.activemq.ActiveMQMessageAuditNoSync;
@@ -190,6 +191,7 @@ public class MessageDatabase extends Ser
     protected boolean enableJournalDiskSyncs=true;
     protected boolean archiveDataLogs;
     protected File directoryArchive;
+    protected AtomicLong storeSize = new AtomicLong(0);
     long checkpointInterval = 5*1000;
     long cleanupInterval = 30*1000;
     int journalMaxFileLength = Journal.DEFAULT_MAX_FILE_LENGTH;
@@ -1594,6 +1596,7 @@ public class MessageDatabase extends Ser
         manager.setChecksum(checksumJournalFiles || checkForCorruptJournalFiles);
         manager.setWriteBatchSize(getJournalMaxWriteBatchSize());
         manager.setArchiveDataLogs(isArchiveDataLogs());
+        manager.setSizeAccumulator(storeSize);
         if (getDirectoryArchive() != null) {
             IOHelper.mkdirs(getDirectoryArchive());
             manager.setDirectoryArchive(getDirectoryArchive());

Modified: activemq/trunk/kahadb/src/main/java/org/apache/kahadb/journal/Journal.java
URL: http://svn.apache.org/viewvc/activemq/trunk/kahadb/src/main/java/org/apache/kahadb/journal/Journal.java?rev=962468&r1=962467&r2=962468&view=diff
==============================================================================
--- activemq/trunk/kahadb/src/main/java/org/apache/kahadb/journal/Journal.java (original)
+++ activemq/trunk/kahadb/src/main/java/org/apache/kahadb/journal/Journal.java Fri Jul  9
09:52:43 2010
@@ -112,7 +112,7 @@ public class Journal {
 
     protected final AtomicReference<Location> lastAppendLocation = new AtomicReference<Location>();
     protected Runnable cleanupTask;
-    protected final AtomicLong totalLength = new AtomicLong();
+    protected AtomicLong totalLength = new AtomicLong();
     protected boolean archiveDataLogs;
 	private ReplicationTarget replicationTarget;
     protected boolean checksum;
@@ -226,7 +226,11 @@ public class Journal {
             accessorPool.closeDataFileAccessor(reader);
         }
 
+        int existingLen = dataFile.getLength();
         dataFile.setLength(location.getOffset());
+        if (existingLen > dataFile.getLength()) {
+            totalLength.addAndGet(dataFile.getLength() - existingLen);
+        }
 
         if( !dataFile.corruptedBlocks.isEmpty() ) {
             // Is the end of the data file corrupted?
@@ -735,4 +739,8 @@ public class Journal {
     public int getWriteBatchSize() {
         return writeBatchSize;
     }
+
+    public void setSizeAccumulator(AtomicLong storeSizeAccumulator) {
+       this.totalLength = storeSizeAccumulator;
+    }
 }



Mime
View raw message