Return-Path: Delivered-To: apmail-geronimo-activemq-commits-archive@www.apache.org Received: (qmail 33466 invoked from network); 25 Jan 2007 16:21:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 Jan 2007 16:21:07 -0000 Received: (qmail 68347 invoked by uid 500); 25 Jan 2007 16:21:13 -0000 Delivered-To: apmail-geronimo-activemq-commits-archive@geronimo.apache.org Received: (qmail 68331 invoked by uid 500); 25 Jan 2007 16:21:12 -0000 Mailing-List: contact activemq-commits-help@geronimo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: activemq-dev@geronimo.apache.org Delivered-To: mailing list activemq-commits@geronimo.apache.org Received: (qmail 68315 invoked by uid 99); 25 Jan 2007 16:21:12 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Jan 2007 08:21:12 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Jan 2007 08:21:05 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id AF0EE1A981C; Thu, 25 Jan 2007 08:20:45 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r499827 - in /incubator/activemq/trunk/activemq-core/src: main/java/org/apache/activemq/kaha/ main/java/org/apache/activemq/kaha/impl/container/ main/java/org/apache/activemq/store/kahadaptor/ main/java/org/apache/activemq/store/rapid/ test... Date: Thu, 25 Jan 2007 16:20:45 -0000 To: activemq-commits@geronimo.apache.org From: rajdavies@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070125162045.AF0EE1A981C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rajdavies Date: Thu Jan 25 08:20:42 2007 New Revision: 499827 URL: http://svn.apache.org/viewvc?view=rev&rev=499827 Log: remove the caching (as was causing memory leaks) in the ListContainer Added: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/MessageIdMarshaller.java (with props) Removed: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/CachedContainerListIterator.java incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/impl/CachedListContainerImplTest.java Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/ListContainer.java incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/ListContainerImpl.java incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaPersistenceAdapter.java incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/rapid/RapidPersistenceAdapter.java Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/ListContainer.java URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/ListContainer.java?view=diff&rev=499827&r1=499826&r2=499827 ============================================================================== --- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/ListContainer.java (original) +++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/ListContainer.java Thu Jan 25 08:20:42 2007 @@ -99,21 +99,6 @@ public boolean doRemove(int position); /** - * @return the maximumCacheSize - */ - public int getMaximumCacheSize(); - - /** - * @param maximumCacheSize the maximumCacheSize to set - */ - public void setMaximumCacheSize(int maximumCacheSize); - - /** - * clear any cached values - */ - public void clearCache(); - - /** * add an Object to the list but get a StoreEntry of its position * * @param object Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/ListContainerImpl.java URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/ListContainerImpl.java?view=diff&rev=499827&r1=499826&r2=499827 ============================================================================== --- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/ListContainerImpl.java (original) +++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/container/ListContainerImpl.java Thu Jan 25 08:20:42 2007 @@ -43,11 +43,7 @@ private static final Log log=LogFactory.getLog(ListContainerImpl.class); protected Marshaller marshaller=Store.ObjectMarshaller; - protected LinkedList cacheList=new LinkedList(); - protected int offset=0; - protected int maximumCacheSize=100; - protected IndexItem lastCached; - protected boolean cacheEnabled = true; + public ListContainerImpl(ContainerId id,IndexItem root,IndexManager indexManager,DataManager dataManager, String indexType) throws IOException{ @@ -91,7 +87,7 @@ if(loaded){ loaded=false; indexList.clear(); - clearCache(); + } } @@ -406,7 +402,7 @@ checkClosed(); super.clear(); doClear(); - clearCache(); + } /* @@ -416,7 +412,12 @@ */ public synchronized Object get(int index){ load(); - return getCachedItem(index); + Object result = null; + IndexItem item=indexList.get(index); + if(item!=null){ + result=getValue(item); + } + return result; } /* @@ -589,7 +590,8 @@ */ public synchronized ListIterator listIterator(){ load(); - return new CachedContainerListIterator(this,0); + IndexItem start= indexList.getFirst(); + return new ContainerListIterator(this,indexList,indexList.getRoot()); } /* @@ -599,7 +601,8 @@ */ public synchronized ListIterator listIterator(int index){ load(); - return new CachedContainerListIterator(this,index); + IndexItem start = (index-1) >0 ?indexList.get(index-1):indexList.getRoot(); + return new ContainerListIterator(this,indexList,start); } /* @@ -676,7 +679,7 @@ load(); boolean result=false; if(item!=null){ - clearCache(); + remove(item); result = true; } @@ -864,156 +867,21 @@ } protected synchronized void itemAdded(IndexItem item,int pos,Object value){ - if(cacheEnabled){ - int cachePosition=pos-offset; - // if pos is before the cache offset - // we need to clear the cache - if(pos=0&&cachePosition<=cacheList.size()){ - cacheList.add(cachePosition,value); - if(cacheList.size()>maximumCacheSize){ - itemRemoved(cacheList.size()-1); - } - } - } + } protected synchronized void itemRemoved(int pos){ - if(cacheEnabled){ - int lastPosition=offset+cacheList.size()-1; - int cachePosition=pos-offset; - if(cachePosition>=0&&cachePosition=0&&cachePositionmaximumCacheSize){ - itemRemoved(0); - } - } - }else{ - IndexItem item=indexList.get(pos); - if(item!=null){ - result=getValue(item); - if(result!=null){ - // outside the cache window - so clear - if(!cacheList.isEmpty()){ - clearCache(); - } - offset=pos; - cacheList.add(result); - lastCached=item; - } - } - } - } - }else { + IndexItem item=indexList.get(pos); if(item!=null){ result=getValue(item); } - } + return result; - } - - /** - * clear any cached values - */ - public synchronized void clearCache(){ - cacheList.clear(); - offset=0; - lastCached=null; - } - - /** - * @return the cacheList - */ - public synchronized LinkedList getCacheList(){ - return cacheList; - } - - /** - * @param cacheList the cacheList to set - */ - public synchronized void setCacheList(LinkedList cacheList){ - this.cacheList=cacheList; - } - - /** - * @return the lastCached - */ - public synchronized StoreEntry getLastCached(){ - return lastCached; - } - - /** - * @param lastCached the lastCached to set - */ - public synchronized void setLastCached(IndexItem lastCached){ - this.lastCached=lastCached; - } - - /** - * @return the maximumCacheSize - */ - public synchronized int getMaximumCacheSize(){ - return maximumCacheSize; - } - - /** - * @param maximumCacheSize the maximumCacheSize to set - */ - public synchronized void setMaximumCacheSize(int maximumCacheSize){ - this.maximumCacheSize=maximumCacheSize; - cacheEnabled = maximumCacheSize >= 0; - if (!cacheEnabled) { - clearCache(); - } - } - - /** - * @return the offset - */ - public synchronized int getOffset(){ - return offset; - } - - /** - * @param offset the offset to set - */ - public synchronized void setOffset(int offset){ - this.offset=offset; - } + } } Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaPersistenceAdapter.java URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaPersistenceAdapter.java?view=diff&rev=499827&r1=499826&r2=499827 ============================================================================== --- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaPersistenceAdapter.java (original) +++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaPersistenceAdapter.java Thu Jan 25 08:20:42 2007 @@ -188,7 +188,6 @@ protected ListContainer getListContainer(Object id,String containerName) throws IOException{ Store store=getStore(); ListContainer container=store.getListContainer(id,containerName); - container.setMaximumCacheSize(0); container.setMarshaller(createMessageMarshaller()); container.load(); return container; Added: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/MessageIdMarshaller.java URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/MessageIdMarshaller.java?view=auto&rev=499827 ============================================================================== --- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/MessageIdMarshaller.java (added) +++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/MessageIdMarshaller.java Thu Jan 25 08:20:42 2007 @@ -0,0 +1,43 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.store.kahadaptor; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import org.apache.activemq.command.MessageId; +import org.apache.activemq.kaha.Marshaller; + + +/** + * Marshall an AtomicInteger + * @version $Revision: 1.10 $ + */ +public class MessageIdMarshaller implements Marshaller{ + + + public void writePayload(MessageId mid,DataOutput dataOut) throws IOException{ + dataOut.writeUTF(mid.toString()); + + } + + public MessageId readPayload(DataInput dataIn) throws IOException{ + String str = dataIn.readUTF(); + return new MessageId(str); + } +} Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/MessageIdMarshaller.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/rapid/RapidPersistenceAdapter.java URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/rapid/RapidPersistenceAdapter.java?view=diff&rev=499827&r1=499826&r2=499827 ============================================================================== --- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/rapid/RapidPersistenceAdapter.java (original) +++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/rapid/RapidPersistenceAdapter.java Thu Jan 25 08:20:42 2007 @@ -179,7 +179,6 @@ protected ListContainer getListContainer(Object id,String containerName) throws IOException{ Store store=getStore(); ListContainer container=store.getListContainer(id,containerName); - container.setMaximumCacheSize(0); container.setMarshaller(new RapidMessageReferenceMarshaller()); container.load(); return container;