Return-Path: Delivered-To: apmail-xml-cocoon-cvs-archive@xml.apache.org Received: (qmail 53481 invoked by uid 500); 23 Aug 2001 12:28:10 -0000 Mailing-List: contact cocoon-cvs-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: cocoon-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cocoon-cvs@xml.apache.org Received: (qmail 53472 invoked by uid 500); 23 Aug 2001 12:28:10 -0000 Delivered-To: apmail-xml-cocoon2-cvs@apache.org Date: 23 Aug 2001 12:22:24 -0000 Message-ID: <20010823122224.20792.qmail@icarus.apache.org> From: vgritsenko@apache.org To: xml-cocoon2-cvs@apache.org Subject: cvs commit: xml-cocoon2/src/org/apache/cocoon/components/store MRUMemoryStore.java X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N vgritsenko 01/08/23 05:22:24 Modified: src/org/apache/cocoon/components/store Tag: cocoon_20_branch MRUMemoryStore.java Log: Rick Tessner [rick@dingle.myra.com] Revision Changes Path No revision No revision 1.2.2.12 +29 -27 xml-cocoon2/src/org/apache/cocoon/components/store/MRUMemoryStore.java Index: MRUMemoryStore.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/components/store/MRUMemoryStore.java,v retrieving revision 1.2.2.11 retrieving revision 1.2.2.12 diff -u -r1.2.2.11 -r1.2.2.12 --- MRUMemoryStore.java 2001/08/22 03:16:40 1.2.2.11 +++ MRUMemoryStore.java 2001/08/23 12:22:23 1.2.2.12 @@ -24,6 +24,7 @@ import org.apache.cocoon.util.IOUtils; import java.io.File; +import java.io.IOException; import java.net.URLEncoder; import java.util.Enumeration; import java.util.HashMap; @@ -205,7 +206,8 @@ public void run() { if(Thread.currentThread().getName().equals("checker")) { while (true) { - if (this.jvm.totalMemory() > this.heapsize) { + // amount of memory used is greater then heapsize + if (this.jvm.totalMemory() - this.jvm.freeMemory() > this.heapsize) { this.jvm.runFinalization(); this.jvm.gc(); synchronized (this) { @@ -225,7 +227,7 @@ try { TmpStackObject tmp = (TmpStackObject)this.writerstack.pop(); this.fsstore.store(getFileName(tmp.getKey().toString()), tmp.getObject()); - } catch(java.io.IOException e) { + } catch(IOException e) { getLogger().error("Error in writer thread",e); } catch(Exception ex) { getLogger().error("Error in writer thread",ex); @@ -286,39 +288,39 @@ */ public Object get(Object key) { getLogger().debug("Getting object from memory. Key: " + key); - Object tmpobject = new Object(); - try { + Object tmpobject = this.cache.get(key); + if ( tmpobject != null ) { /** put the accessed key on top of the linked list */ this.mrulist.remove(key); this.mrulist.addFirst(key); - return this.cache.get(key); - } catch(NullPointerException e) { - getLogger().debug("Object not found in memory"); - /** try to fetch from filesystem */ - if(this.filesystem) { - tmpobject = this.fsstore.get(getFileName(key.toString())); - if (tmpobject == null) { - getLogger().debug( "Object was NOT found on fs. Looked for: " + URLEncoder.encode(key.toString()) ); + return tmpobject; + } + + getLogger().debug("Object not found in memory"); + /** try to fetch from filesystem */ + if(this.filesystem) { + tmpobject = this.fsstore.get(getFileName(key.toString())); + if (tmpobject == null) { + getLogger().debug( "Object was NOT found on fs. Looked for: " + URLEncoder.encode(key.toString()) ); + return null; + } else { + getLogger().debug("Object was found on fs"); + try { + tmpobject = IOUtils.deserializeObject((File)tmpobject); + this.hold(key,tmpobject); + return tmpobject; + } catch (ClassNotFoundException ce) { + getLogger().error("Error in get()!", ce); return null; - } else { - getLogger().debug("Object was found on fs"); - try { - tmpobject = IOUtils.deserializeObject((File)tmpobject); - this.hold(key,tmpobject); - return tmpobject; - } catch (ClassNotFoundException ce) { - getLogger().error("Error in get()!",e); - return null; - } catch (java.io.IOException ioe) { - getLogger().error("Error in get()!",e); - return null; - } + } catch (IOException ioe) { + getLogger().error("Error in get()!", ioe); + return null; } - } else { - return null; } } + + return null; } /** ---------------------------------------------------------------------- In case of troubles, e-mail: webmaster@xml.apache.org To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org For additional commands, e-mail: cocoon-cvs-help@xml.apache.org