You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-dev@jakarta.apache.org by as...@apache.org on 2005/01/29 01:40:02 UTC

cvs commit: jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/indexed IndexedDiskCache.java IndexedDiskCacheManager.java

asmuts      2005/01/28 16:40:02

  Modified:    src/java/org/apache/jcs/auxiliary/disk
                        AbstractDiskCache.java
               src/conf cache.ccf
               src/java/org/apache/jcs/engine CacheEventQueue.java
                        ElementAttributes.java PooledCacheEventQueue.java
               src/java/org/apache/jcs/engine/control CompositeCache.java
               src/java/org/apache/jcs/auxiliary/disk/indexed
                        IndexedDiskCache.java IndexedDiskCacheManager.java
  Log:
  Fixed two problems noticed by Allen Wyatt:
  
  1.  If the disk files exist and the app does not have permission to read from or
  write to them, then elements build up in purgatory.  This should be fixed now.
  I will do some more testing.
  
  2.  The isSpool setting was being ignore, since spooling is treated differently
  than other aux updates.  It is now checked.  I changed the default settings
  for the attributes to allow them to spool by default.
  
  Revision  Changes    Path
  1.27      +64 -6     jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java
  
  Index: AbstractDiskCache.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- AbstractDiskCache.java	13 Jan 2005 09:12:44 -0000	1.26
  +++ AbstractDiskCache.java	29 Jan 2005 00:40:01 -0000	1.27
  @@ -115,12 +115,18 @@
   
       // ----------------------------------------------------------- constructors
   
  +    /**
  +     * Construc the abstract disk cache, create event queues and purgatory.
  +     * 
  +     * @param attr
  +     */    
       public AbstractDiskCache( IDiskCacheAttributes attr )
       {
         	this.dcattr = attr;
   
           this.cacheName = attr.getCacheName();
   
  +        // create queue
           CacheEventQueueFactory fact = new CacheEventQueueFactory();
           this.cacheEventQueue = fact.createCacheEventQueue( new MyCacheListener(),
                                                       CacheInfo.listenerId,
  @@ -128,6 +134,7 @@
                                                       dcattr.getEventQueuePoolName(),
                                                       dcattr.getEventQueueTypeFactoryCode() );
   
  +        // create purgatory
           initPurgatory();
       }
   
  @@ -162,6 +169,13 @@
        * Adds the provided element to the cache. Element will be added to
        * purgatory, and then queued for later writing to the serialized storage
        * mechanism.
  +     * <p>
  +     * An update results in a put event being created.  The put event will call the
  +     * handlePut method defined here.  The handlePut method calls the implemented
  +     * doPut on the child.
  +     * 
  +     * @param cacheElement
  +     * @throws IOException
        *
        * @see org.apache.jcs.engine.behavior.ICache#update
        */
  @@ -203,6 +217,9 @@
       }
   
       /**
  +     * @param key
  +     * @return ICacheElement or null
  +     * 
        * @see AuxiliaryCache#get
        */
       public final ICacheElement get( Serializable key )
  @@ -238,8 +255,6 @@
               // since the mem cache may be set to 0.  If an item is active, it will keep
               // getting put into purgatory and removed. The CompositeCache now does
               // not put an item to memory from disk ifthe size is 0;
  -            // pe.setSpoolable( false );  // commented out for above reasons
  -            //purgatory.remove( key );
   
               log.debug( "Found element in purgatory, cacheName: " + cacheName
                       + ", key: " + key );
  @@ -268,6 +283,11 @@
       public abstract Set getGroupKeys(String groupName);
   
       /**
  +     * Removes are not queued.  A call to remove is immediate.
  +     * 
  +     * @param key
  +     * @return whether the item was present to be removed.
  +     * 
        * @see org.apache.jcs.engine.behavior.ICache#remove
        */
       public final boolean remove( Serializable key )
  @@ -317,8 +337,7 @@
       public final void dispose()
       {
   
  -       // FIXME: May lose the end of the queue, need to be more graceful
  -       // call finish up or something first
  +       // This stops the processor thread.
          cacheEventQueue.destroy();
   
           // Invoke any implementation specific disposal code
  @@ -364,8 +383,8 @@
       	se.setData("" + purgHits);
       	elems.add(se);
   
  -    	se.setName( "Purgatory Size" );
       	se = new StatElement();
  +    	se.setName( "Purgatory Size" );
       	se.setData("" + purgatory.size());
       	elems.add(se);
   
  @@ -469,6 +488,9 @@
           }
   
           /**
  +         * @param id
  +         * @throws IOException
  +         * 
            * @see ICacheListener#setListenerId
            */
           public void setListenerId( long id )
  @@ -478,6 +500,8 @@
           }
   
           /**
  +         * @param element
  +         * @throws IOException
            * @see ICacheListener#handlePut
            *
            * NOTE: This checks if the element is a puratory element and behaves
  @@ -532,12 +556,38 @@
                   }
                   else
                   {
  +                    // call the child's implementation
                       doUpdate( element );
                   }
               }
  +            else 
  +            {
  +                // The cache is not alive, hence the element should be removed from
  +                // purgatory. All elements should be removed eventually.
  +                // Perhaps, the alive check should have been done before it went in the
  +                // queue.  This block handles the case where the disk cache fails
  +                // during normal opertations.
  +                
  +                String keyAsString = element.getKey().toString();
  +
  +                writeLock( keyAsString );
  +
  +                try
  +                {
  +                    purgatory.remove( element.getKey() );
  +                }
  +                finally
  +                {
  +                    releaseLock( keyAsString );
  +                }                              
  +            }
           }
   
           /**
  +         * @param cacheName
  +         * @param key
  +         * @throws IOException
  +         * 
            * @see ICacheListener#handleRemove
            */
           public void handleRemove( String cacheName, Serializable key )
  @@ -553,6 +603,9 @@
           }
   
           /**
  +         * @param cacheName
  +         * @throws IOException
  +         * 
            * @see ICacheListener#handleRemoveAll
            */
           public void handleRemoveAll( String cacheName )
  @@ -565,6 +618,9 @@
           }
   
           /**
  +         * @param cacheName
  +         * @throws IOException
  +         * 
            * @see ICacheListener#handleDispose
            */
           public void handleDispose( String cacheName )
  @@ -590,6 +646,7 @@
   
       /**
        * Add a cache element to the persistent store.
  +     * @param element
        */
       protected abstract void doUpdate( ICacheElement element );
   
  @@ -597,6 +654,7 @@
        * Remove an object from the persistent store if found.
        *
        * @param key Key of object to remove.
  +     * @return whether or no the item was present when removed
        */
       protected abstract boolean doRemove( Serializable key );
   
  
  
  
  1.17      +2 -2      jakarta-turbine-jcs/src/conf/cache.ccf
  
  Index: cache.ccf
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/conf/cache.ccf,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- cache.ccf	27 Jan 2005 22:44:30 -0000	1.16
  +++ cache.ccf	29 Jan 2005 00:40:01 -0000	1.17
  @@ -20,9 +20,9 @@
   ##############################################################
   ################## CACHE REGIONS AVAILABLE ###################
   # Regions preconfirgured for caching
  -jcs.region.testCache1=RC
  +jcs.region.testCache1=DC
   jcs.region.testCache1.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
  -jcs.region.testCache1.cacheattributes.MaxObjects=1000
  +jcs.region.testCache1.cacheattributes.MaxObjects=10
   jcs.region.testCache1.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
   jcs.region.testCache1.cacheattributes.UseMemoryShrinker=true
   jcs.region.testCache1.cacheattributes.ShrinkerIntervalSeconds=30
  
  
  
  1.16      +23 -7     jakarta-turbine-jcs/src/java/org/apache/jcs/engine/CacheEventQueue.java
  
  Index: CacheEventQueue.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/CacheEventQueue.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- CacheEventQueue.java	27 Jan 2005 22:40:43 -0000	1.15
  +++ CacheEventQueue.java	29 Jan 2005 00:40:01 -0000	1.16
  @@ -59,7 +59,6 @@
     private long listenerId;
     private String cacheName;
   
  -  private int failureCount;
     private int maxFailure;
   
     // in milliseconds
  @@ -134,7 +133,8 @@
     }
     
     /**
  -   * Event Q is emtpy.
  +   * Kill the processor thread and indicate that the queue is detroyed and no
  +   * longer alive, but it can still be working.
      */
     public synchronized void stopProcessing()
     {
  @@ -146,6 +146,7 @@
   
     /**
      * Returns the time to wait for events before killing the background thread.
  +   * @return int
      */
     public int getWaitToDieMillis()
     {
  @@ -154,6 +155,7 @@
   
     /**
      * Sets the time to wait for events before killing the background thread.
  +   * @param wtdm, the ms for the q to sit idle.
      */
     public void setWaitToDieMillis( int wtdm)
     {
  @@ -161,7 +163,7 @@
     }
   
     /**
  -   * @return
  +   * @return String debugging info.
      */
     public String toString()
     {
  @@ -170,14 +172,19 @@
     }
   
     /**
  -   * @return The {3} value
  +   * @return The alive value
      */
     public boolean isAlive()
     {
       return ( !destroyed );
     }
   
  -  public void setAlive( boolean aState )
  +  /**
  +   * Sets whether the queue is actively processing -- if there are working threads.
  +   * 
  +   * @param aState
  +   */
  +public void setAlive( boolean aState )
     {
       destroyed = !aState;
     }
  @@ -349,6 +356,8 @@
     /**
      * Returns the next cache event from the queue or null if there are no events
      * in the queue.
  +   * 
  +   * @return An event to process.
      *
      */
     private AbstractCacheEvent take()
  @@ -398,8 +407,8 @@
     	se.setData("" + this.working);
     	elems.add(se);
     	
  -  	se.setName( "Alive" );
     	se = new StatElement();
  +  	se.setName( "Alive" );
     	se.setData("" + this.isAlive());
     	elems.add(se);
   
  @@ -455,8 +464,11 @@
         extends Thread
     {
       CacheEventQueue queue;
  +    
       /**
        * Constructor for the QProcessor object
  +     * 
  +     * @param aQueue, the event queue to take items from.
        */
       QProcessor( CacheEventQueue aQueue )
       {
  @@ -741,7 +753,7 @@
     }
   
     /**
  -   * @return
  +   * @return whether the queue is functional.
      */
     public boolean isWorking()
     {
  @@ -756,6 +768,10 @@
       working = b;
     }
   
  +  /**
  +   * 
  +   * @return whether there are any items in the queue.
  +   */
     public boolean isEmpty()
     {
       return tail == head;
  
  
  
  1.7       +5 -5      jakarta-turbine-jcs/src/java/org/apache/jcs/engine/ElementAttributes.java
  
  Index: ElementAttributes.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/ElementAttributes.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ElementAttributes.java	21 Apr 2004 01:00:43 -0000	1.6
  +++ ElementAttributes.java	29 Jan 2005 00:40:01 -0000	1.7
  @@ -41,24 +41,24 @@
     /**
      *  Is this item distributable at all.
      */
  -  public boolean IS_DISTRIBUTE = false;
  +  public boolean IS_DISTRIBUTE = true;
   
     // lateral
   
     /**
      *  can this item be flushed to disk
      */
  -  public boolean IS_SPOOL = false;
  +  public boolean IS_SPOOL = true;
   
     /**
      *  Is this item laterally distributable
      */
  -  public boolean IS_LATERAL = false;
  +  public boolean IS_LATERAL = true;
   
     /**
      *  Can this item be sent to the remote cache
      */
  -  public boolean IS_REMOTE = false;
  +  public boolean IS_REMOTE = true;
   
     /**
      *  can turn off expiration
  @@ -173,7 +173,7 @@
     /**
      *  Description of the Method
      *
  -   *@return
  +   * @return a clone of these attributes
      */
     public Object clone2()
     {
  
  
  
  1.3       +26 -22    jakarta-turbine-jcs/src/java/org/apache/jcs/engine/PooledCacheEventQueue.java
  
  Index: PooledCacheEventQueue.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/PooledCacheEventQueue.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PooledCacheEventQueue.java	13 Jan 2005 09:12:40 -0000	1.2
  +++ PooledCacheEventQueue.java	29 Jan 2005 00:40:01 -0000	1.3
  @@ -70,8 +70,6 @@
   
     private String           cacheName;
   
  -  private int              failureCount;
  -
     private int              maxFailure;
   
     // in milliseconds
  @@ -81,8 +79,6 @@
   
     private boolean          working         = true;
   
  -  private Thread           processorThread;
  -
     //The Thread Pool to execute events with.
     private ThreadPool       pool            = null;
   
  @@ -94,6 +90,7 @@
      * @param cacheName
      * @param maxFailure
      * @param waitBeforeRetry
  +   * @param threadPoolName
      */
     public PooledCacheEventQueue(ICacheListener listener, long listenerId,
         String cacheName, int maxFailure, int waitBeforeRetry,
  @@ -145,12 +142,12 @@
     {
   
       destroyed = true;
  -    processorThread = null;
   
     }
   
     /**
      * Returns the time to wait for events before killing the background thread.
  +   * @return the time to wait before shutting down in ms.
      */
     public int getWaitToDieMillis()
     {
  @@ -159,6 +156,7 @@
   
     /**
      * Sets the time to wait for events before killing the background thread.
  +   * @param wtdm
      */
     public void setWaitToDieMillis( int wtdm )
     {
  @@ -166,7 +164,7 @@
     }
   
     /**
  -   * @return
  +   * @return String info.
      */
     public String toString()
     {
  @@ -182,13 +180,16 @@
       return (!destroyed);
     }
   
  +  /**
  +   * @param aState
  +   */
     public void setAlive( boolean aState )
     {
  -    destroyed = !aState;
  +      destroyed = !aState;
     }
   
     /**
  -   * @return The {3} value
  +   * @return The listenerId value
      */
     public long getListenerId()
     {
  @@ -196,19 +197,19 @@
     }
   
     /**
  -   * Destroy the queue.  Interrupt all threads.
  +   * Destroy the queue. Interrupt all threads.
      */
  -  public synchronized void destroy()
  -  {
  -    if (!destroyed)
  +    public synchronized void destroy()
       {
  -      destroyed = true;
  -      // TODO decide whether to shutdown or interrupt
  -     // pool.getPool().shutdownNow();
  -     pool.getPool().interruptAll();
  -      log.info( "Cache event queue destroyed: " + this );
  +        if (!destroyed)
  +        {
  +            destroyed = true;
  +            // TODO decide whether to shutdown or interrupt
  +            // pool.getPool().shutdownNow();
  +            pool.getPool().interruptAll();
  +            log.info( "Cache event queue destroyed: " + this );
  +        }
       }
  -  }
   
     /**
      * @param ce
  @@ -308,6 +309,9 @@
       }
     }
   
  +  /**
  +   * @return Statistics info
  +   */
     public String getStats()
     {
       return getStatistics().toString();
  @@ -568,7 +572,7 @@
     }
   
     /**
  -   * Description of the Class
  +   * The Event put into the queue for dispose requests.
      *
      * @author asmuts
      * @created January 15, 2002
  @@ -593,7 +597,7 @@
     }
   
     /**
  -   * @return
  +   * @return whether or not the queue is functional
      */
     public boolean isWorking()
     {
  @@ -601,7 +605,7 @@
     }
   
     /**
  -   * @param b
  +   * @param b, whether the queue is functional
      */
     public void setWorking( boolean b )
     {
  @@ -612,7 +616,7 @@
      * If the Queue is using a bounded channel we can determine the size.
      * If it is zero or we can't determine the size, we return true.
      *
  -   * @return
  +   * @return whether or not there are items in the queue
      */
     public boolean isEmpty()
     {
  
  
  
  1.21      +7 -1      jakarta-turbine-jcs/src/java/org/apache/jcs/engine/control/CompositeCache.java
  
  Index: CompositeCache.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/control/CompositeCache.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- CompositeCache.java	27 Jan 2005 22:40:43 -0000	1.20
  +++ CompositeCache.java	29 Jan 2005 00:40:02 -0000	1.21
  @@ -320,6 +320,12 @@
       public void spoolToDisk( ICacheElement ce )
       {
   
  +        // if the item is not spoolable, return
  +        if ( !ce.getElementAttributes().getIsSpool() )
  +        {
  +            return;
  +        }
  +                        
           boolean diskAvailable = false;
   
           // SPOOL TO DISK.
  
  
  
  1.19      +69 -47    jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
  
  Index: IndexedDiskCache.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- IndexedDiskCache.java	12 Jan 2005 01:21:58 -0000	1.18
  +++ IndexedDiskCache.java	29 Jan 2005 00:40:02 -0000	1.19
  @@ -32,9 +32,11 @@
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  +
  +import EDU.oswego.cs.dl.util.concurrent.WriterPreferenceReadWriteLock;
  +
   import org.apache.jcs.auxiliary.disk.AbstractDiskCache;
   import org.apache.jcs.auxiliary.disk.LRUMapJCS;
  -import org.apache.jcs.auxiliary.disk.behavior.IDiskCacheAttributes;
   import org.apache.jcs.engine.CacheConstants;
   import org.apache.jcs.engine.CacheElement;
   import org.apache.jcs.engine.behavior.ICacheElement;
  @@ -46,8 +48,6 @@
   import org.apache.jcs.engine.stats.behavior.IStats;
   import org.apache.jcs.utils.struct.SortedPreferentialArray;
   
  -import EDU.oswego.cs.dl.util.concurrent.WriterPreferenceReadWriteLock;
  -
   /**
    * Disk cache that uses a RandomAccessFile with keys stored in memory.
    *
  @@ -93,8 +93,6 @@
      * Each instance of a Disk cache should use this lock to synchronize reads
      * and writes to the underlying storage mechansism.
      */
  -  //protected ReadWriteLock storageLock = new ReadWriteLock();
  -
     protected WriterPreferenceReadWriteLock storageLock = new
         WriterPreferenceReadWriteLock();
   
  @@ -105,7 +103,7 @@
      */
     public IndexedDiskCache(IndexedDiskCacheAttributes cattr)
     {
  -    super((IDiskCacheAttributes)cattr);
  +    super(cattr);
   
       String cacheName = cattr.getCacheName();
       String rootDirName = cattr.getDiskPath();
  @@ -180,10 +178,11 @@
     /**
      * Loads the keys from the .key file.  The keys are stored in a HashMap on
      * disk.  This is converted into a LRUMap.
  +   * 
  +   * @throws InterruptedException
      */
     private void loadKeys() throws InterruptedException
     {
  -    //storageLock.writeLock();
       storageLock.writeLock().acquire();
   
       if (log.isInfoEnabled())
  @@ -233,15 +232,17 @@
       }
       finally
       {
  -      //storageLock.done();
         storageLock.writeLock().release();
       }
     }
   
   
     /**
  -   * Check the consitency between the keys and the datafile.  Makes sure
  +   * Check for minimal consitency between the keys and the datafile.  Makes sure
      * no staring positions in the keys exceed the file length.
  +   * <p>
  +   * The caller should take the appropriate action if the keys and data
  +   * are not consistent.  
      *
      * @return True if the test passes
      */
  @@ -276,23 +277,7 @@
                       "\n raf.length() = " + len +
                       "\n pos = " + pos );
             return isOk;
  -          //reset();
  -          //throw new IOException( "The Data File Is Corrupt, need to reset" );
  -         // return null;
         }
  -
  -/*
  -      else
  -      {
  -        raf.seek(pos);
  -        int datalen = raf.readInt();
  -        if (datalen > raf.length())
  -        {
  -          isOk = false;
  -          break;
  -        }
  -      }
  - */
       }
   
       log.info( "Finished inital consistency check, isOk = " + isOk );
  @@ -345,6 +330,8 @@
      * Update the disk cache. Called from the Queue. Makes sure the Item has not
      * been retireved from purgatory while in queue for disk. Remove items from
      * purgatory when they go to disk.
  +   * 
  +   * @param ce, The ICacheElement to put to disk.
      */
     public void doUpdate(ICacheElement ce)
     {
  @@ -354,6 +341,15 @@
         log.debug("Storing element on disk, key: " + ce.getKey());
       }
   
  +    if (!alive)
  +    {
  +        if (log.isDebugEnabled())
  +        {
  +          log.debug("Disk is not alive, aborting put." );
  +        }
  +        return;
  +    }
  +    
       IndexedDiskElementDescriptor ded = null;
   
       try
  @@ -369,10 +365,6 @@
   
         try
         {
  -        if (!alive)
  -        {
  -          return;
  -        }
   
           IndexedDiskElementDescriptor old =
               (IndexedDiskElementDescriptor)
  @@ -452,6 +444,8 @@
     }
   
     /**
  +   * @param key
  +   * @return ICacheElement or null
      * @see AbstractDiskCache#doGet
      */
     protected ICacheElement doGet(Serializable key)
  @@ -587,7 +581,6 @@
       boolean removed = false;
       try
       {
  -      //storageLock.writeLock();
         storageLock.writeLock().acquire();
   
         if (key instanceof String
  @@ -695,7 +688,6 @@
       }
       finally
       {
  -      //storageLock.done();
         storageLock.writeLock().release();
       }
   
  @@ -774,9 +766,6 @@
     /**
      * If the maxKeySize is < 0, use 5000, no way to have an unlimted
      * recycle bin right now, or one less than the mazKeySize.
  -   * 
  -   * @TODO make separate config.  
  -   *
      */
     private void initRecycleBin()
     {
  @@ -800,7 +789,10 @@
       }       
     }  
     
  -  
  +  /**
  +   * Create the map for keys that contain the index position on disk.
  +   *
  +   */
     private void initKeyMap()
     {
       keyHash = null;
  @@ -821,9 +813,12 @@
         }
       }       
     }    
  +  
     /**
      * Dispose of the disk cache in a background thread.  Joins against this
      * thread to put a cap on the disposal time.
  +   * 
  +   * @todo make dispose window configurable.
      */
     public void doDispose()
     {
  @@ -854,7 +849,6 @@
     {
       try
       {
  -      //storageLock.writeLock();
         storageLock.writeLock().acquire();
   
         if (!alive)
  @@ -896,7 +890,6 @@
   
         try
         {
  -        //storageLock.done();
           storageLock.writeLock().release();
         }
         catch (Exception e)
  @@ -1017,7 +1010,6 @@
   
         // potentially, this will cause the longest delay
         // lock so no more gets to the queue -- optimizingPutList
  -      //storageLock.writeLock();
         storageLock.writeLock().acquire();
         try
         {
  @@ -1047,7 +1039,6 @@
         }
         finally
         {
  -        //storageLock.done();
           storageLock.writeLock().release();
         }
   
  @@ -1125,10 +1116,13 @@
     /**
      * Copies data for a key from main file to temp file and key to temp keyhash
      * Clients must manage locking.
  -   *
  -   * @param key Serializable
  -   * @param keyHash Map
  -   * @param dataFileTemp IndexedDisk
  +   * 
  +   * @param key
  +   *            Serializable
  +   * @param keyHashTemp
  +   * @param dataFileTemp
  +   *            IndexedDisk
  +   * @throws Exception
      */
     private void moveKeyDataToTemp(Serializable key, LRUMap keyHashTemp,
                                    IndexedDisk dataFileTemp) throws Exception
  @@ -1142,7 +1136,7 @@
       catch (IOException e)
       {
         log.error("Failed to get orinigal off disk cache: " + fileName
  -                + ", key: " + key + "" );//; keyHash.tag = " + keyHash.tag);
  +                + ", key: " + key + "" );
         //reset();
         throw e;
       }
  @@ -1310,15 +1304,34 @@
       IStatElement se = null;
   
       se = new StatElement();
  +    se.setName( "Is Alive" );
  +    se.setData( "" + alive );        
  +    elems.add( se );
  +    
  +    se = new StatElement();
       se.setName( "Key Map Size" );
  -    se.setData( "" + this.keyHash.size() );
  +    if ( this.keyHash != null )
  +    {
  +        se.setData( "" + this.keyHash.size() );        
  +    }
  +    else
  +    {
  +        se.setData( "-1" );                
  +    }
       elems.add( se );
   
       try
       {
         se = new StatElement();
         se.setName( "Data File Length" );
  -      se.setData( "" + this.dataFile.length() );
  +      if ( this.dataFile != null )
  +      {
  +          se.setData( "" + this.dataFile.length() );          
  +      }
  +      else
  +      {
  +          se.setData( "-1" );                    
  +      }
         elems.add( se );
       }
       catch (Exception e)
  @@ -1366,13 +1379,22 @@
         extends LRUMapJCS
     {
   
  +    /**
  +     * <code>tag</code> tells us which map we are working on.
  +     */
       public String tag = "orig";
   
  +    /**
  +     * 
  +     */
       public LRUMap()
       {
         super();
       }
   
  +    /**
  +     * @param maxKeySize
  +     */
       public LRUMap(int maxKeySize)
       {
         super(maxKeySize);
  
  
  
  1.7       +1 -3      jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheManager.java
  
  Index: IndexedDiskCacheManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- IndexedDiskCacheManager.java	16 Nov 2004 07:40:41 -0000	1.6
  +++ IndexedDiskCacheManager.java	29 Jan 2005 00:40:02 -0000	1.7
  @@ -86,8 +86,6 @@
        * Gets an IndexedDiskCache for the supplied name using the default
        * attributes.
        *
  -     * @see #getCache( IndexedDiskCacheAttributes }
  -     *
        * @param cacheName Name that will be used when creating attributes.
        * @return A cache.
        */
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-dev-help@jakarta.apache.org