cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From froehl...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/store MRUMemoryStore.java FilesystemQueueObject.java FilesystemQueueImpl.java FilesystemQueue.java
Date Sun, 27 Jan 2002 13:14:40 GMT
froehlich    02/01/27 05:14:40

  Modified:    src/java/org/apache/cocoon/components/store
                        MRUMemoryStore.java
  Removed:     src/java/org/apache/cocoon/components/store
                        FilesystemQueueObject.java FilesystemQueueImpl.java
                        FilesystemQueue.java
  Log:
  you'll hate me for that but had to change some things, because
  there were too much issues with that:
  a) changed the swapping algorithm. Objects are only written to fs
  method in the free() method of the MRUMemoryStore
  b) therefore no need of the FilesystemQueue. Because there were
  much less writing to fs.
  c) removed the configuratioin section in the cocoon.xconf file
  d) add "isDebugEnabled()"
  
  Revision  Changes    Path
  1.3       +48 -34    xml-cocoon2/src/java/org/apache/cocoon/components/store/MRUMemoryStore.java
  
  Index: MRUMemoryStore.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/store/MRUMemoryStore.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MRUMemoryStore.java	22 Jan 2002 00:17:12 -0000	1.2
  +++ MRUMemoryStore.java	27 Jan 2002 13:14:40 -0000	1.3
  @@ -65,7 +65,6 @@
       private File cachedir;
       private File workdir;
       private String cachedirstr;
  -    private FilesystemQueue filesystemQueue;
       private ComponentManager manager;
   
       /**
  @@ -75,12 +74,12 @@
        */
       public void compose(ComponentManager manager) throws ComponentException {
           this.manager = manager;
  -        getLogger().debug("Looking up " + Store.ROLE + "/Filesystem");
           this.fsstore = (Store)manager.lookup(Store.ROLE + "/Filesystem");
  -        getLogger().debug("Looking up " + StoreJanitor.ROLE);
           this.storejanitor = (StoreJanitor)manager.lookup(StoreJanitor.ROLE);
  -        getLogger().debug("Looking up " + FilesystemQueue.ROLE);
  -        this.filesystemQueue = (FilesystemQueue)manager.lookup(FilesystemQueue.ROLE);
  +        if (this.getLogger().isDebugEnabled()) {
  +            getLogger().debug("Looking up " + Store.ROLE + "/Filesystem");
  +            getLogger().debug("Looking up " + StoreJanitor.ROLE);    
  +        }
       }
   
       /**
  @@ -133,8 +132,6 @@
           if (this.manager != null) {
               this.manager.release(this.storejanitor);
               this.storejanitor = null;
  -            this.manager.release(this.filesystemQueue);
  -            this.filesystemQueue = null;
               this.manager.release(this.fsstore);
               this.fsstore = null;
           }
  @@ -161,32 +158,22 @@
        * @param the object to be stored
        */
       public void hold(Object key, Object value) {
  -        getLogger().debug("Holding object in memory. key: " + key);
  -        getLogger().debug("Holding object in memory. value: " + value);
  -
  +        if (this.getLogger().isDebugEnabled()) {
  +            getLogger().debug("Holding object in memory. key: " + key);
  +            getLogger().debug("Holding object in memory. value: " + value);
  +        }
           /** ...first test if the max. objects in cache is reached... */
           while (this.mrulist.size() >= this.maxobjects) {
               /** ...ok, heapsize is reached, remove the last element... */
               this.free();
           }
  -
  -        /** put the object on the filesystem */
  -        if(this.filesystem) {
  -            if(this.checkSerializable(value) &&
  -               !this.fsstore.containsKey(getFileName(key.toString()))) {
  -                this.getLogger().debug("Storing object on fs");
  -                try {
  -                    this.filesystemQueue.insert(new FilesystemQueueObject(key,value));
  -                } catch(Exception e) {
  -                    this.getLogger().error("Error storing Object on fs",e);
  -                }
  -            }
  -        }
           /** ..put the new object in the cache, on the top of course ... */
           this.cache.put(key, value);
           this.mrulist.remove(key);
           this.mrulist.addFirst(key);
  -        this.getLogger().debug("Cache size=" + cache.size());
  +        if (this.getLogger().isDebugEnabled()) {
  +            this.getLogger().debug("Cache size=" + cache.size());
  +        }
       }
   
       /**
  @@ -196,7 +183,9 @@
        * @return the requested object
        */
       public Object get(Object key) {
  -        this.getLogger().debug("Getting object from memory. Key: " + key);
  +        if (this.getLogger().isDebugEnabled()) {
  +            this.getLogger().debug("Getting object from memory. Key: " + key);
  +        }
           Object tmpobject = this.cache.get(key);
           if ( tmpobject != null ) {
               /** put the accessed key on top of the linked list */
  @@ -205,16 +194,22 @@
               return tmpobject;
           }
   
  -        this.getLogger().debug("Object not found in memory");
  +        if (this.getLogger().isDebugEnabled()) {
  +            this.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) {
  -                this.getLogger().debug( "Object was NOT found on fs.  Looked for: "
  -                                + getFileName(key.toString()));
  +                if (this.getLogger().isDebugEnabled()) {
  +                    this.getLogger().debug( "Object was NOT found on fs.  Looked for: "
  +                                    + getFileName(key.toString()));
  +                }
                   return null;
               } else {
  -                this.getLogger().debug("Object was found on fs");
  +                if (this.getLogger().isDebugEnabled()) {
  +                    this.getLogger().debug("Object was found on fs");
  +                }
                   try {
                       tmpobject = IOUtils.deserializeObject((File)tmpobject);
                       if(!this.cache.containsKey(key)) {
  @@ -239,7 +234,9 @@
        * @param the key of to be removed object
        */
       public void remove(Object key) {
  -        this.getLogger().debug("Removing object from store");
  +        if (this.getLogger().isDebugEnabled()) {
  +            this.getLogger().debug("Removing object from store");
  +        }
           this.cache.remove(key);
           this.mrulist.remove(key);
           if(this.filesystem && key != null) {
  @@ -277,10 +274,25 @@
       public void free() {
           try {
               if(this.cache.size() > 0) {
  -                this.getLogger().debug("Freeing cache");
  +                if (this.getLogger().isDebugEnabled()) {
  +                    this.getLogger().debug("Freeing cache");
  +                }
  +                // Swapping object on fs.
  +                if(this.filesystem) {
  +                    if(checkSerializable(this.cache.get(this.mrulist.getLast()))) {
  +                        try {
  +                            this.fsstore.store(this.getFileName(this.mrulist.getLast().toString()),

  +                                               this.cache.get(this.mrulist.getLast()));
  +                        } catch(Exception e) {
  +                            this.getLogger().error("Error storing Object on fs",e);
  +                        }
  +                    }
  +                }
                   this.cache.remove(this.mrulist.getLast());
                   this.mrulist.removeLast();
  -                this.getLogger().debug("Cache size=" + cache.size());
  +                if (this.getLogger().isDebugEnabled()) {
  +                    this.getLogger().debug("Cache size=" + cache.size());
  +                }
               }
           } catch (Exception e) {
               this.getLogger().error("Error in free()", e);
  @@ -297,7 +309,9 @@
        */
       private boolean checkSerializable(Object object) {
           try {
  -            this.getLogger().debug("Object=" + object);
  +            if (this.getLogger().isDebugEnabled()) {
  +                this.getLogger().debug("Object=" + object);
  +            }
               if((object.getClass().getName().equals("org.apache.cocoon.caching.CachedEventObject"))
                 || (object.getClass().getName().equals("org.apache.cocoon.caching.CachedStreamObject"))
                 || (ClassUtils.implementsInterface(object.getClass().getName(),"org.apache.cocoon.caching.CacheValidity")))
{
  @@ -378,6 +392,6 @@
               }
               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


Mime
View raw message