From 4de4bc65f848bdfa45c8b191c4fc6baca9eae93c Mon Sep 17 00:00:00 2001 From: Robert Davies Date: Mon, 14 Jul 2008 15:59:12 +0000 Subject: [PATCH] Fix for https://issues.apache.org/activemq/browse/AMQ-1856 git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@676636 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/activemq/kaha/impl/async/AsyncDataManager.java | 8 ++++++-- .../org/apache/activemq/store/amq/AMQMessageStore.java | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/AsyncDataManager.java b/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/AsyncDataManager.java index d94d197e1d..a10b032296 100644 --- a/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/AsyncDataManager.java +++ b/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/AsyncDataManager.java @@ -72,6 +72,7 @@ public class AsyncDataManager { public static final String DEFAULT_FILE_PREFIX = "data-"; public static final int DEFAULT_MAX_FILE_LENGTH = 1024 * 1024 * 32; public static final int DEFAULT_CLEANUP_INTERVAL = 1000 * 30; + public static final int PREFERED_DIFF = 1024 * 512; private static final Log LOG = LogFactory.getLog(AsyncDataManager.class); @@ -85,7 +86,7 @@ public class AsyncDataManager { protected boolean useNio = true; protected int maxFileLength = DEFAULT_MAX_FILE_LENGTH; - protected int preferedFileLength = DEFAULT_MAX_FILE_LENGTH - 1024 * 512; + protected int preferedFileLength = DEFAULT_MAX_FILE_LENGTH - PREFERED_DIFF; protected DataFileAppender appender; protected DataFileAccessorPool accessorPool = new DataFileAccessorPool(this); @@ -115,6 +116,7 @@ public class AsyncDataManager { } started = true; + preferedFileLength=Math.max(PREFERED_DIFF, getMaxFileLength()-PREFERED_DIFF); lock(); ByteSequence sequence = controlFile.load(); @@ -427,11 +429,13 @@ public class AsyncDataManager { List purgeList = new ArrayList(); for (Integer key : unUsed) { // Only add files less than the lastFile.. + System.err.println("LAST FILE IS: " + lastFile); if( key.intValue() < lastFile.intValue() ) { DataFile dataFile = (DataFile)fileMap.get(key); purgeList.add(dataFile); } } + System.err.println("PURGE LIST IS: " + purgeList); for (DataFile dataFile : purgeList) { forceRemoveDataFile(dataFile); } @@ -468,7 +472,7 @@ public class AsyncDataManager { dataFile.unlink(); if (archiveDataLogs) { dataFile.move(getDirectoryArchive()); - LOG.debug("moved data file " + dataFile + " to " + LOG.info("moved data file " + dataFile + " to " + getDirectoryArchive()); } else { boolean result = dataFile.delete(); diff --git a/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQMessageStore.java b/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQMessageStore.java index 716f8a00f3..f46a8e81b8 100644 --- a/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQMessageStore.java +++ b/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQMessageStore.java @@ -231,10 +231,10 @@ public class AMQMessageStore implements MessageStore { lock.lock(); try { inFlightTxLocations.remove(location); - removeMessage(ack,location); }finally { lock.unlock(); } + removeMessage(ack,location); } public void afterRollback() throws Exception {