From d6ad7c7cd0a2101b9a1160bd8ea7d906437fef10 Mon Sep 17 00:00:00 2001 From: Bosanac Dejan Date: Wed, 24 Nov 2010 11:48:27 +0000 Subject: [PATCH] https://issues.apache.org/activemq/browse/AMQ-3028 - sync pageCache git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1038566 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/kahadb/page/PageFile.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/kahadb/src/main/java/org/apache/kahadb/page/PageFile.java b/kahadb/src/main/java/org/apache/kahadb/page/PageFile.java index 4127b7f857..e13d9336cf 100644 --- a/kahadb/src/main/java/org/apache/kahadb/page/PageFile.java +++ b/kahadb/src/main/java/org/apache/kahadb/page/PageFile.java @@ -26,14 +26,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InterruptedIOException; import java.io.RandomAccessFile; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Properties; -import java.util.TreeMap; +import java.util.*; import java.util.Map.Entry; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; @@ -106,7 +99,7 @@ public class PageFile { int writeBatchSize = DEFAULT_WRITE_BATCH_SIZE; // We keep a cache of pages recently used? - private LRUCache pageCache; + private Map pageCache; // The cache of recently used pages. private boolean enablePageCaching=true; // How many pages will we keep in the cache? @@ -301,7 +294,7 @@ public class PageFile { if (loaded.compareAndSet(false, true)) { if( enablePageCaching ) { - pageCache = new LRUCache(pageCacheSize, pageCacheSize, 0.75f, true); + pageCache = Collections.synchronizedMap(new LRUCache(pageCacheSize, pageCacheSize, 0.75f, true)); } File file = getMainPageFile();