diff --git a/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java b/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java index be1171f15a..9f8b52ae96 100644 --- a/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java +++ b/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java @@ -65,7 +65,6 @@ import org.apache.activemq.usage.MemoryUsage; import org.apache.activemq.usage.SystemUsage; import org.apache.activemq.util.ServiceStopper; import org.apache.activemq.wireformat.WireFormat; -import org.apache.kahadb.util.ByteSequence; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.kahadb.journal.Location; @@ -994,7 +993,11 @@ public class KahaDBStore extends MessageDatabase implements PersistenceAdapter { } public long size() { - return storeSize.get(); + try { + return journalSize.get() + getPageFile().getDiskSize(); + } catch (IOException e) { + throw new RuntimeException(e); + } } public void beginTransaction(ConnectionContext context) throws IOException { diff --git a/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java b/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java index 1d33f2da6a..a3476457a6 100644 --- a/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java +++ b/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java @@ -207,7 +207,7 @@ public abstract class MessageDatabase extends ServiceSupport implements BrokerSe protected boolean enableJournalDiskSyncs=true; protected boolean archiveDataLogs; protected File directoryArchive; - protected AtomicLong storeSize = new AtomicLong(0); + protected AtomicLong journalSize = new AtomicLong(0); long checkpointInterval = 5*1000; long cleanupInterval = 30*1000; int journalMaxFileLength = Journal.DEFAULT_MAX_FILE_LENGTH; @@ -2170,7 +2170,7 @@ public abstract class MessageDatabase extends ServiceSupport implements BrokerSe manager.setChecksum(checksumJournalFiles || checkForCorruptJournalFiles); manager.setWriteBatchSize(getJournalMaxWriteBatchSize()); manager.setArchiveDataLogs(isArchiveDataLogs()); - manager.setSizeAccumulator(storeSize); + manager.setSizeAccumulator(journalSize); manager.setEnableAsyncDiskSync(isEnableJournalDiskSyncs()); if (getDirectoryArchive() != null) { IOHelper.mkdirs(getDirectoryArchive()); diff --git a/activemq-core/src/test/java/org/apache/activemq/store/kahadb/KahaDBFastEnqueueTest.java b/activemq-core/src/test/java/org/apache/activemq/store/kahadb/KahaDBFastEnqueueTest.java index d791e99f95..f990f18536 100644 --- a/activemq-core/src/test/java/org/apache/activemq/store/kahadb/KahaDBFastEnqueueTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/store/kahadb/KahaDBFastEnqueueTest.java @@ -92,6 +92,8 @@ public class KahaDBFastEnqueueTest { LOG.info("Rate: " + (toSend * 1000/duration) + "m/s"); LOG.info("Total send: " + totalSent); LOG.info("Total journal write: " + kahaDBPersistenceAdapter.getStore().getJournal().length()); + LOG.info("Total index size " + kahaDBPersistenceAdapter.getStore().getPageFile().getDiskSize()); + LOG.info("Total store size: " + kahaDBPersistenceAdapter.size()); LOG.info("Journal writes %: " + kahaDBPersistenceAdapter.getStore().getJournal().length() / (double)totalSent * 100 + "%"); restartBroker(0, 1200000); @@ -134,6 +136,8 @@ public class KahaDBFastEnqueueTest { LOG.info("Rate: " + (toSend * 1000/duration) + "m/s"); LOG.info("Total send: " + totalSent); LOG.info("Total journal write: " + kahaDBPersistenceAdapter.getStore().getJournal().length()); + LOG.info("Total index size " + kahaDBPersistenceAdapter.getStore().getPageFile().getDiskSize()); + LOG.info("Total store size: " + kahaDBPersistenceAdapter.size()); LOG.info("Journal writes %: " + kahaDBPersistenceAdapter.getStore().getJournal().length() / (double)totalSent * 100 + "%"); restartBroker(0, 0);