From 00893abe277e3123bc94123365883f5e68730ca2 Mon Sep 17 00:00:00 2001 From: Robert Davies Date: Wed, 27 Feb 2008 10:21:27 +0000 Subject: [PATCH] recycle hash pages git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@631537 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/activemq/kaha/impl/index/hash/HashBin.java | 11 ++++++++--- .../activemq/kaha/impl/index/hash/HashIndex.java | 6 +++--- .../activemq/kaha/impl/index/hash/HashPageInfo.java | 4 ++++ .../store/kahadaptor/KahaReferenceStoreAdapter.java | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashBin.java b/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashBin.java index f11a2d5380..1acd2fa5a6 100644 --- a/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashBin.java +++ b/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashBin.java @@ -23,6 +23,8 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import sun.security.action.GetBooleanAction; + /** * Bin in a HashIndex * @@ -219,6 +221,11 @@ class HashBin { HashPageInfo page = getRetrievePage(index); int offset = getRetrieveOffset(index); HashEntry result = page.removeHashEntry(offset); + + if (page.isEmpty()) { + hashPages.remove(page); + hashIndex.releasePage(page.getPage()); + } doUnderFlow(index); return result; } @@ -295,9 +302,7 @@ class HashBin { } } - private void doUnderFlow(@SuppressWarnings("unused") - int index) { - // does little + private void doUnderFlow(int index) { } private void end() throws IOException { diff --git a/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashIndex.java b/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashIndex.java index 8e5cebc411..01ed8151ee 100644 --- a/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashIndex.java +++ b/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashIndex.java @@ -462,8 +462,8 @@ public class HashIndex implements Index, HashIndexMBean { } static { - DEFAULT_PAGE_SIZE = Integer.parseInt(System.getProperty("defaultPageSize", "16384")); - DEFAULT_KEY_SIZE = Integer.parseInt(System.getProperty("defaultKeySize", "96")); - DEFAULT_BIN_SIZE= Integer.parseInt(System.getProperty("defaultBinSize", "1024")); + DEFAULT_PAGE_SIZE = Integer.parseInt(System.getProperty("defaultPageSize", "8000")); + DEFAULT_KEY_SIZE = Integer.parseInt(System.getProperty("defaultKeySize", "80")); + DEFAULT_BIN_SIZE= Integer.parseInt(System.getProperty("defaultBinSize", "128")); } } diff --git a/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashPageInfo.java b/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashPageInfo.java index 4442e92b69..cdad444c8a 100644 --- a/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashPageInfo.java +++ b/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashPageInfo.java @@ -55,6 +55,10 @@ class HashPageInfo { int size() { return this.size; } + + boolean isEmpty() { + return size <= 0; + } /** * @param size the size to set diff --git a/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaReferenceStoreAdapter.java b/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaReferenceStoreAdapter.java index e134292203..a802bfb6c9 100644 --- a/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaReferenceStoreAdapter.java +++ b/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaReferenceStoreAdapter.java @@ -59,7 +59,7 @@ public class KahaReferenceStoreAdapter extends KahaPersistenceAdapter implements private static final Log LOG = LogFactory.getLog(KahaReferenceStoreAdapter.class); private static final String STORE_STATE = "store-state"; private static final String INDEX_VERSION_NAME = "INDEX_VERSION"; - private static final Integer INDEX_VERSION = new Integer(4); + private static final Integer INDEX_VERSION = new Integer(5); private static final String RECORD_REFERENCES = "record-references"; private static final String TRANSACTIONS = "transactions-state"; private MapContainer stateMap;