jakarta-jcs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asm...@apache.org
Subject cvs commit: jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk AbstractDiskCache.java
Date Wed, 14 Apr 2004 06:24:18 GMT
asmuts      2004/04/13 23:24:18

  Modified:    src/java/org/apache/jcs/auxiliary/disk/indexed
                        IndexedDiskCache.java IndexedDisk.java
               src/java/org/apache/jcs/auxiliary/disk
                        AbstractDiskCache.java
  Log:
  Fixed diskcache key storage shutdown bug.  Added debugging information.
  
  I think there is a problem if stuff is being written to disk during the final stage of the
optimization.  This should be easy to fix.
  
  I also need to make sure that the maxlife parameter is getting stored properly.
  
  Revision  Changes    Path
  1.8       +33 -10    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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- IndexedDiskCache.java	22 Aug 2003 11:57:17 -0000	1.7
  +++ IndexedDiskCache.java	14 Apr 2004 06:24:18 -0000	1.8
  @@ -175,6 +175,11 @@
       {
           storageLock.writeLock();
   
  +        if ( log.isInfoEnabled() )
  +        {
  +          log.info( "loading keys for " + keyFile.toString() );
  +        }
  +
           try
           {
               keyHash = ( HashMap ) keyFile.readObject( 0 );
  @@ -184,11 +189,24 @@
                   keyHash = new HashMap();
               }
   
  -            if ( log.isDebugEnabled() )
  +            if ( log.isInfoEnabled() )
               {
  -                log.debug( "Loaded keys from: " + fileName +
  +               log.info( "Loaded keys from: " + fileName +
                       ", key count: " + keyHash.size() );
               }
  +
  +            if ( log.isDebugEnabled() )
  +            {
  +                Iterator itr = keyHash.entrySet().iterator();
  +                while ( itr.hasNext() )
  +                {
  +                   Map.Entry e = (Map.Entry)itr.next();
  +                   String key = (String)e.getKey();
  +                   IndexedDiskElementDescriptor de = (IndexedDiskElementDescriptor)e.getValue();
  +                   log.debug( "key entry: " + key + ", ded.pos" + de.pos + ", ded.len"
+ de.len );
  +                }
  +            }
  +
           }
           catch ( Exception e )
           {
  @@ -589,9 +607,9 @@
               IndexedDisk dataFileTemp =
                   new IndexedDisk( new File( rafDir, fileName + "Temp.data" ) );
   
  -            if ( log.isDebugEnabled() )
  +            if ( log.isInfoEnabled() )
               {
  -                log.info( "optomizing file keyHash.size()=" + keyHash.size() );
  +                log.info( "Optomizing file keyHash.size()=" + keyHash.size() );
               }
   
               Iterator itr = keyHash.keySet().iterator();
  @@ -603,16 +621,21 @@
                   CacheElement tempDe = ( CacheElement ) readElement( key );
                   try
                   {
  -                    IndexedDiskElementDescriptor de =
  -                        dataFileTemp.appendObject( tempDe );
  +                    //IndexedDiskElementDescriptor de =
  +                    //    dataFileTemp.appendObject( tempDe );
  +
  +                    IndexedDiskElementDescriptor ded = new IndexedDiskElementDescriptor();
  +                    byte[] data = IndexedDisk.serialize( tempDe );
  +                    ded.init( dataFileTemp.length(), data );
  +                    dataFileTemp.write( data, ded.pos );
   
                       if ( log.isDebugEnabled() )
                       {
  -                        log.debug( "Put to temp disk cache: " + fileName +
  -                                   ", key: " + key );
  +                        log.debug( "Optomize: Put to temp disk cache: " + fileName +
  +                                   ", key: " + key + ", ded.pos:" + ded.pos + ", ded.len:"
+ ded.len);
                       }
   
  -                    keyHashTemp.put( key, de );
  +                    keyHashTemp.put( key, ded );
                   }
                   catch ( Exception e )
                   {
  
  
  
  1.4       +1 -1      jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDisk.java
  
  Index: IndexedDisk.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDisk.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- IndexedDisk.java	22 Aug 2003 11:57:17 -0000	1.3
  +++ IndexedDisk.java	14 Apr 2004 06:24:18 -0000	1.4
  @@ -127,7 +127,7 @@
               }
               if ( corrupted )
               {
  -                log.debug( "The datFile is corrupted" );
  +                log.warn( "The dataFile is corrupted!" );
                   //reset();
                   return null;
               }
  
  
  
  1.18      +4 -2      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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- AbstractDiskCache.java	22 Aug 2003 11:57:18 -0000	1.17
  +++ AbstractDiskCache.java	14 Apr 2004 06:24:18 -0000	1.18
  @@ -299,7 +299,6 @@
        */
       public final void dispose()
       {
  -        alive = false;
   
           // Invoke any implementation specific disposal code
   
  @@ -308,6 +307,9 @@
           // FIXME: May lose the end of the queue, need to be more graceful
   
           cacheEventQueue.destroy();
  +
  +        alive = false;
  +
       }
   
       /**
  
  
  

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


Mime
View raw message