Author: asmuts
Date: Wed Jun  3 21:31:03 2009
New Revision: 781588

URL: http://svn.apache.org/viewvc?rev=781588&view=rev
Log:
Added a clearDiskOnStartup configuration option for the IndexedDisk Cache.

Modified:
    
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCache.java
    
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
    
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheAttributes.java
    
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java
    jakarta/jcs/trunk/src/test-conf/TestRemoteCacheClientServer.ccf
    
jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerStartupUtil.java
    jakarta/jcs/trunk/xdocs/IndexedDiskCacheProperties.xml

Modified: 
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCache.java
URL: 
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCache.java?rev=781588&r1=781587&r2=781588&view=diff
==============================================================================
--- 
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCache.java
 (original)
+++ 
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCache.java
 Wed Jun  3 21:31:03 2009
@@ -183,14 +183,14 @@
                 Object data = this.dataFile.read( (int[]) entry.getValue() );
                 if ( data == null )
                 {
-                    throw new Exception( "Couldn't find data for key [" + 
entry.getKey() + "]" );
+                    throw new Exception( logCacheName + "Couldn't find data 
for key [" + entry.getKey() + "]" );
                 }
             }
             alright = true;
         }
         catch ( Exception e )
         {
-            log.warn( "Problem verifying disk.  Message [" + e.getMessage() + 
"]" );
+            log.warn( logCacheName + "Problem verifying disk.  Message [" + 
e.getMessage() + "]" );
             alright = false;
         }
         return alright;

Modified: 
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
URL: 
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java?rev=781588&r1=781587&r2=781588&view=diff
==============================================================================
--- 
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
 (original)
+++ 
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
 Wed Jun  3 21:31:03 2009
@@ -20,6 +20,7 @@
  */
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.Serializable;
 import java.util.ArrayList;
@@ -154,81 +155,28 @@
      * Constructor for the DiskCache object.
      * <p>
      * @param cattr
-     * @param elementSerializer  used if supplied, the super's super will not 
set a null
+     * @param elementSerializer used if supplied, the super's super will not 
set a null
      */
     public IndexedDiskCache( IndexedDiskCacheAttributes cattr, 
IElementSerializer elementSerializer )
     {
         super( cattr );
+
         setElementSerializer( elementSerializer );
 
-        String rootDirName = cattr.getDiskPath();
+        this.cattr = cattr;
         this.maxKeySize = cattr.getMaxKeySize();
-
         this.isRealTimeOptimizationEnabled = cattr.getOptimizeAtRemoveCount() 
> 0;
         this.isShutdownOptimizationEnabled = cattr.isOptimizeOnShutdown();
-
-        this.cattr = cattr;
-
         this.logCacheName = "Region [" + getCacheName() + "] ";
         this.fileName = getCacheName();
 
-        this.rafDir = new File( rootDirName );
-        this.rafDir.mkdirs();
-
-        if ( log.isInfoEnabled() )
-        {
-            log.info( logCacheName + "Cache file root directory: " + 
rootDirName );
-        }
-
         try
         {
-            this.dataFile = new IndexedDisk( new File( rafDir, fileName + 
".data" ), getElementSerializer() );
+            initializeFileSystem( cattr );
 
-            this.keyFile = new IndexedDisk( new File( rafDir, fileName + 
".key" ), getElementSerializer() );
+            initializeKeysAndData( cattr );
 
-            // If the key file has contents, try to initialize the keys
-            // from it. In no keys are loaded reset the data file.
-
-            if ( keyFile.length() > 0 )
-            {
-                loadKeys();
-
-                if ( keyHash.size() == 0 )
-                {
-                    dataFile.reset();
-                }
-                else
-                {
-                    boolean isOk = checkKeyDataConsistency( false );
-                    if ( !isOk )
-                    {
-                        keyHash.clear();
-                        keyFile.reset();
-                        dataFile.reset();
-                        log.warn( logCacheName + "Corruption detected.  Reset 
data and keys files." );
-                    }
-                    else
-                    {
-                        startupSize = keyHash.size();
-                    }
-                }
-            }
-
-            // Otherwise start with a new empty map for the keys, and reset
-            // the data file if it has contents.
-
-            else
-            {
-                initKeyMap();
-
-                if ( dataFile.length() > 0 )
-                {
-                    dataFile.reset();
-                }
-            }
-
-            // create the recyclebin
-            initRecycleBin();
+            initializeRecycleBin();
 
             // Initialization finished successfully, so set alive to true.
             alive = true;
@@ -239,8 +187,8 @@
         }
         catch ( Exception e )
         {
-            log.error( logCacheName + "Failure initializing for fileName: " + 
fileName + " and root directory: "
-                + rootDirName, e );
+            log.error( logCacheName + "Failure initializing for fileName: " + 
fileName + " and directory: "
+                + this.rafDir.getAbsolutePath(), e );
         }
 
         // TODO: Should we improve detection of whether or not the file should 
be optimized.
@@ -252,6 +200,111 @@
     }
 
     /**
+     * Tries to create the root directory if it does not already exist.
+     * <p>
+     * @param cattr
+     */
+    private void initializeFileSystem( IndexedDiskCacheAttributes cattr )
+    {
+        String rootDirName = cattr.getDiskPath();
+        this.rafDir = new File( rootDirName );
+        boolean createdDirectories = this.rafDir.mkdirs();
+        if ( log.isInfoEnabled() )
+        {
+            log.info( logCacheName + "Cache file root directory: " + 
rootDirName );
+            log.info( logCacheName + "Created root directory: " + 
createdDirectories );
+        }
+    }
+
+    /**
+     * Creates the key and data disk caches.
+     * <p>
+     * Loads any keys if they are present and ClearDiskOnStartup is false.
+     * <p>
+     * @param cattr
+     * @throws FileNotFoundException
+     * @throws IOException
+     * @throws InterruptedException
+     */
+    private void initializeKeysAndData( IndexedDiskCacheAttributes cattr )
+        throws FileNotFoundException, IOException, InterruptedException
+    {
+        this.dataFile = new IndexedDisk( new File( rafDir, fileName + ".data" 
), getElementSerializer() );
+
+        this.keyFile = new IndexedDisk( new File( rafDir, fileName + ".key" ), 
getElementSerializer() );
+
+        if ( cattr.isClearDiskOnStartup() )
+        {
+            if ( log.isInfoEnabled() )
+            {
+                log.info( logCacheName + "ClearDiskOnStartup is set to true.  
Ingnoring any persisted data." );
+            }
+            initializeEmptyStore();
+        }
+        else if ( keyFile.length() > 0 )
+        {
+            // If the key file has contents, try to initialize the keys
+            // from it. In no keys are loaded reset the data file.
+            initializeStoreFromPersistedData();
+        }
+        else
+        {
+            // Otherwise start with a new empty map for the keys, and reset
+            // the data file if it has contents.
+            initializeEmptyStore();
+        }
+    }
+
+    /**
+     * Initializes an empty disk cache.
+     * <p>
+     * @throws IOException
+     */
+    private void initializeEmptyStore()
+        throws IOException
+    {
+        initializeKeyMap();
+
+        if ( dataFile.length() > 0 )
+        {
+            dataFile.reset();
+        }
+    }
+
+    /**
+     * Loads any persisted data and checks for consistency. If there is a 
consistency issue, the
+     * files are cleared.
+     * <p>
+     * @throws InterruptedException
+     * @throws IOException
+     */
+    private void initializeStoreFromPersistedData()
+        throws InterruptedException, IOException
+    {
+        loadKeys();
+
+        if ( keyHash.size() == 0 )
+        {
+            dataFile.reset();
+        }
+        else
+        {
+            boolean isOk = checkKeyDataConsistency( false );
+            if ( !isOk )
+            {
+                keyHash.clear();
+                keyFile.reset();
+                dataFile.reset();
+                log.warn( logCacheName + "Corruption detected.  Reseting data 
and keys files." );
+            }
+            else
+            {
+                startupSize = keyHash.size();
+            }
+        }
+    }
+
+    /**
      * Loads the keys from the .key file. The keys are stored in a HashMap on 
disk. This is
      * converted into a LRUMap.
      * <p>
@@ -270,7 +323,7 @@
         try
         {
             // create a key map to use.
-            initKeyMap();
+            initializeKeyMap();
 
             HashMap keys = (HashMap) keyFile.readObject( new 
IndexedDiskElementDescriptor( 0, (int) keyFile.length()
                 - IndexedDisk.RECORD_HEADER ) );
@@ -307,7 +360,7 @@
     }
 
     /**
-     * Check for minimal consitency between the keys and the datafile. Makes 
sure no starting
+     * Check for minimal consistency between the keys and the datafile. Makes 
sure no starting
      * positions in the keys exceed the file length.
      * <p>
      * The caller should take the appropriate action if the keys and data are 
not consistent.
@@ -405,9 +458,9 @@
     {
         try
         {
-            if ( log.isDebugEnabled() )
+            if ( log.isInfoEnabled() )
             {
-                log.debug( logCacheName + "Saving keys to: " + fileName + ", 
key count: " + keyHash.size() );
+                log.info( logCacheName + "Saving keys to: " + fileName + ", 
key count: " + keyHash.size() );
             }
 
             keyFile.reset();
@@ -420,9 +473,9 @@
                 keyFile.writeObject( keys, 0 );
             }
 
-            if ( log.isDebugEnabled() )
+            if ( log.isInfoEnabled() )
             {
-                log.debug( logCacheName + "Finished saving keys." );
+                log.info( logCacheName + "Finished saving keys." );
             }
         }
         catch ( Exception e )
@@ -933,9 +986,9 @@
 
             keyFile = new IndexedDisk( new File( rafDir, fileName + ".key" ), 
getElementSerializer() );
 
-            initRecycleBin();
+            initializeRecycleBin();
 
-            initKeyMap();
+            initializeKeyMap();
         }
         catch ( Exception e )
         {
@@ -951,7 +1004,7 @@
      * If the maxKeySize is < 0, use 5000, no way to have an unlimted recycle 
bin right now, or one
      * less than the mazKeySize.
      */
-    private void initRecycleBin()
+    private void initializeRecycleBin()
     {
         int recycleBinSize = cattr.getMaxRecycleBinSize() >= 0 ? 
cattr.getMaxRecycleBinSize() : 0;
         recycle = new SortedPreferentialArray( recycleBinSize );
@@ -964,7 +1017,7 @@
     /**
      * Create the map for keys that contain the index position on disk.
      */
-    private void initKeyMap()
+    private void initializeKeyMap()
     {
         keyHash = null;
         if ( maxKeySize >= 0 )
@@ -1233,7 +1286,7 @@
             // RESTORE NORMAL OPERATION
             removeCount = 0;
             bytesFree = 0;
-            initRecycleBin();
+            initializeRecycleBin();
             queuedPutList.clear();
             queueInput = false;
             // turn recycle back on.
@@ -1251,9 +1304,9 @@
     }
 
     /**
-     * Defragments the file inplace by compacting out the free space (i.e., 
moving records forward).
-     * If there were no gaps the resulting file would be the same size as the 
previous file. This
-     * must be supplied an ordered defragList.
+     * Defragments the file in place by compacting out the free space (i.e., 
moving records
+     * forward). If there were no gaps the resulting file would be the same 
size as the previous
+     * file. This must be supplied an ordered defragList.
      * <p>
      * @param defragList sorted list of descriptors for optimization
      * @param startingPos the start position in the file

Modified: 
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheAttributes.java
URL: 
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheAttributes.java?rev=781588&r1=781587&r2=781588&view=diff
==============================================================================
--- 
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheAttributes.java
 (original)
+++ 
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheAttributes.java
 Wed Jun  3 21:31:03 2009
@@ -41,8 +41,7 @@
     private static final int DEFAULT_maxRecycleBinSize = 5000;
 
     /**
-     * Cannot be larger than the max size. If max is less than 0, this will be
-     * 5000
+     * Cannot be larger than the max size. If max is less than 0, this will be 
5000
      */
     private int maxRecycleBinSize = DEFAULT_maxRecycleBinSize;
 
@@ -55,6 +54,12 @@
     /** Should we optimize on shutdown. */
     private boolean optimizeOnShutdown = DEFAULT_OPTIMIZE_ON_SHUTDOWN;
 
+    /** Should we clear the disk on startup. */
+    public static final boolean DEFAULT_CLEAR_DISK_ON_STARTUP = false;
+
+    /** Should we clear the disk on startup. If true the congtents of disk are 
cleared. */
+    private boolean clearDiskOnStartup = DEFAULT_CLEAR_DISK_ON_STARTUP;
+
     /**
      * Constructor for the DiskCacheAttributes object
      */
@@ -76,8 +81,7 @@
     /**
      * Sets the maxKeySize attribute of the DiskCacheAttributes object
      * <p>
-     * @param maxKeySize
-     *            The new maxKeySize value
+     * @param maxKeySize The new maxKeySize value
      */
     public void setMaxKeySize( int maxKeySize )
     {
@@ -88,8 +92,7 @@
     }
 
     /**
-     * Gets the optimizeAtRemoveCount attribute of the DiskCacheAttributes
-     * object
+     * Gets the optimizeAtRemoveCount attribute of the DiskCacheAttributes 
object
      * <p>
      * @return The optimizeAtRemoveCount value
      */
@@ -99,12 +102,10 @@
     }
 
     /**
-     * Sets the optimizeAtRemoveCount attribute of the DiskCacheAttributes
-     * object This number determines how often the disk cache should run real
-     * time optimizations.
+     * Sets the optimizeAtRemoveCount attribute of the DiskCacheAttributes 
object This number
+     * determines how often the disk cache should run real time optimizations.
      * <p>
-     * @param cnt
-     *            The new optimizeAtRemoveCount value
+     * @param cnt The new optimizeAtRemoveCount value
      */
     public void setOptimizeAtRemoveCount( int cnt )
     {
@@ -112,14 +113,12 @@
     }
 
     /**
-     * This cannot be larger than the maxKeySize. It wouldn't hurt anything, 
but
-     * it makes the config necessary. The recycle bin entry willbe at least as
-     * large as a key.
+     * This cannot be larger than the maxKeySize. It wouldn't hurt anything, 
but it makes the config
+     * necessary. The recycle bin entry willbe at least as large as a key.
      * <p>
      * If the maxKeySize is -1 this will be set tot he default, which is 5000.
      * <p>
-     * @param maxRecycleBinSize
-     *            The maxRecycleBinSize to set.
+     * @param maxRecycleBinSize The maxRecycleBinSize to set.
      */
     public void setMaxRecycleBinSize( int maxRecycleBinSize )
     {
@@ -151,6 +150,22 @@
     }
 
     /**
+     * @param clearDiskOnStartup the clearDiskOnStartup to set
+     */
+    public void setClearDiskOnStartup( boolean clearDiskOnStartup )
+    {
+        this.clearDiskOnStartup = clearDiskOnStartup;
+    }
+
+    /**
+     * @return the clearDiskOnStartup
+     */
+    public boolean isClearDiskOnStartup()
+    {
+        return clearDiskOnStartup;
+    }
+
+    /**
      * Returns a copy of the attributes.
      * <p>
      * @return AuxiliaryCacheAttributes
@@ -184,7 +199,7 @@
         str.append( "\n optimizeAtRemoveCount  = " + optimizeAtRemoveCount );
         str.append( "\n shutdownSpoolTimeLimit  = " + shutdownSpoolTimeLimit );
         str.append( "\n optimizeOnShutdown  = " + optimizeOnShutdown );
+        str.append( "\n clearDiskOnStartup  = " + clearDiskOnStartup );
         return str.toString();
     }
-
 }

Modified: 
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java
URL: 
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java?rev=781588&r1=781587&r2=781588&view=diff
==============================================================================
--- 
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java
 (original)
+++ 
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java
 Wed Jun  3 21:31:03 2009
@@ -253,25 +253,7 @@
                 return;
             }
 
-            boolean exists = false;
-
-            // First do a query to determine if the element already exists
-            if ( this.getJdbcDiskCacheAttributes().isTestBeforeInsert() )
-            {
-                exists = doesElementExist( ce );
-            }
-
-            // If it doesn't exist, insert it, otherwise update
-            if ( !exists )
-            {
-                exists = insertRow( ce, con, element );
-            }
-
-            // update if it exists.
-            if ( exists )
-            {
-                updateRow( ce, con, element );
-            }
+            insertOrUpdate( ce, con, element );
         }
         finally
         {
@@ -296,6 +278,38 @@
     }
 
     /**
+     * If test before insert it true, we check to see if the element exists. 
If the element exists
+     * we will update. Otherwise, we try inserting.  If this fails because the 
item exists, we will
+     * update.
+     * <p>
+     * @param ce
+     * @param con
+     * @param element
+     */
+    private void insertOrUpdate( ICacheElement ce, Connection con, byte[] 
element )
+    {
+        boolean exists = false;
+
+        // First do a query to determine if the element already exists
+        if ( this.getJdbcDiskCacheAttributes().isTestBeforeInsert() )
+        {
+            exists = doesElementExist( ce );
+        }
+
+        // If it doesn't exist, insert it, otherwise update
+        if ( !exists )
+        {
+            exists = insertRow( ce, con, element );
+        }
+
+        // update if it exists.
+        if ( exists )
+        {
+            updateRow( ce, con, element );
+        }
+    }
+
+    /**
      * This inserts a new row in the database.
      * <p>
      * @param ce
@@ -773,7 +787,6 @@
                     log.error( "Problem closing statement.", e1 );
                 }
             }
-
         }
         catch ( Exception e )
         {

Modified: jakarta/jcs/trunk/src/test-conf/TestRemoteCacheClientServer.ccf
URL: 
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test-conf/TestRemoteCacheClientServer.ccf?rev=781588&r1=781587&r2=781588&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test-conf/TestRemoteCacheClientServer.ccf (original)
+++ jakarta/jcs/trunk/src/test-conf/TestRemoteCacheClientServer.ccf Wed Jun  3 
21:31:03 2009
@@ -21,7 +21,7 @@
 registry.port=1102
 
 # client callback port.
-remote.cache.service.port=1103
+remote.cache.service.port=1301
 remote.cache.rmiSocketFactoryTimeoutMillis=12345
 
 # cluster setting

Modified: 
jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerStartupUtil.java
URL: 
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerStartupUtil.java?rev=781588&r1=781587&r2=781588&view=diff
==============================================================================
--- 
jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerStartupUtil.java
 (original)
+++ 
jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerStartupUtil.java
 Wed Jun  3 21:31:03 2009
@@ -119,7 +119,6 @@
             {
                 log.error( "Problem starting remote cache server.", e );
             }
-
             catch ( Throwable t )
             {
                 log.error( "Problem starting remote cache server.", t );
@@ -132,5 +131,4 @@
 
         return RemoteCacheServerFactory.getRemoteCacheServer();
     }
-
 }

Modified: jakarta/jcs/trunk/xdocs/IndexedDiskCacheProperties.xml
URL: 
http://svn.apache.org/viewvc/jakarta/jcs/trunk/xdocs/IndexedDiskCacheProperties.xml?rev=781588&r1=781587&r2=781588&view=diff
==============================================================================
--- jakarta/jcs/trunk/xdocs/IndexedDiskCacheProperties.xml (original)
+++ jakarta/jcs/trunk/xdocs/IndexedDiskCacheProperties.xml Wed Jun  3 21:31:03 
2009
@@ -1,37 +1,27 @@
 <?xml version="1.0"?>
-<!--
- 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.
--->
-
+       <!--
+               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.
+       -->
 <document>
        <properties>
                <title>Indexed Disk Cache Configuration</title>
                <author email="asm...@apache.org">Aaron Smuts</author>
        </properties>
-
        <body>
                <section name="Indexed Disk Auxiliary Cache Configuration">
-
-                       <p>
-                               The following properties apply to the Indexed 
Disk Cache
-                               plugin.
+                       <p> The following properties apply to the Indexed Disk 
Cache plugin.
                        </p>
-
                        <subsection name="Indexed Disk Configuration 
Properties">
                                <table>
                                        <tr>
@@ -42,75 +32,64 @@
                                        </tr>
                                        <tr>
                                                <td>DiskPath</td>
-                                               <td>
-                                                       The directory where the 
disk cache should
-                                                       write its files.
+                                               <td> The directory where the 
disk cache should write its files.
                                                </td>
                                                <td>Y</td>
                                                <td>n/a</td>
                                        </tr>
                                        <tr>
                                                <td>MaxPurgatorySize</td>
-                                               <td>
-                                                       The maximum number of 
items allowed in the
-                                                       queue of items to be 
written to disk.
-                                               </td>
+                                               <td> The maximum number of 
items allowed in the queue of items to
+                                                       be written to disk.</td>
                                                <td>N</td>
                                                <td>5000</td>
                                        </tr>
                                        <tr>
                                                <td>MaxKeySize</td>
-                                               <td>
-                                                       The maximum number of 
keys that the indexed
-                                                       disk cache can have. 
Since the keys are
-                                                       stored in memory, you 
may want to limit this
-                                                       number to something 
reasonable. The default
-                                                       is a bit small.
+                                               <td> The maximum number of keys 
that the indexed disk cache can
+                                                       have. Since the keys 
are stored in memory, you may want to limit
+                                                       this number to 
something reasonable. The default is a bit small.
                                                </td>
                                                <td>N</td>
                                                <td>5000</td>
                                        </tr>
                                        <tr>
                                                <td>OptimizeAtRemoveCount</td>
-                                               <td>
-                                                       At how many removes 
should the cache try to
-                                                       defragment the data 
file. Since we recycle
-                                                       empty spots, 
defragmentation is usually not
-                                                       needed. To prevent the 
cache from
-                                                       defragmenting the data 
file, you can set
-                                                       this to -1. This is the 
default value.
+                                               <td> At how many removes should 
the cache try to defragment the
+                                                       data file. Since we 
recycle empty spots, defragmentation is
+                                                       usually not needed. To 
prevent the cache from defragmenting the
+                                                       data file, you can set 
this to -1. This is the default value.
                                                </td>
                                                <td>N</td>
                                                <td>-1</td>
                                        </tr>
                                        <tr>
                                                <td>OptimizeOnShutdown</td>
-                                               <td>
-                                                       By default the Indexed 
Disk Cache will
-                                                       optimize on shutdown if 
the free data size
-                                                       is greater than 0. If 
you want to prevent
-                                                       this behavior, you can 
set this parameter to
-                                                       false.
-                                               </td>
+                                               <td> By default the Indexed 
Disk Cache will optimize on shutdown
+                                                       if the free data size 
is greater than 0. If you want to prevent
+                                                       this behavior, you can 
set this parameter to false.</td>
                                                <td>N</td>
                                                <td>true</td>
                                        </tr>
                                        <tr>
+                                               <td>ClearDiskOnStartup</td>
+                                               <td> By default the Indexed 
Disk Cache will use items found on
+                                                       disk on startup. If you 
set this value to try, the old key and
+                                                       data files will be 
cleared.</td>
+                                               <td>N</td>
+                                               <td>false</td>
+                                       </tr>
+                                       <tr>
                                                <td>MaxRecycleBinSize</td>
-                                               <td>
-                                                       The maximum number of 
empty spots the cache
-                                                       will keep track of. The 
smallest are removed
-                                                       when the maximum size 
is reached. Keeping
-                                                       track of empty spots on 
disk allows us to
-                                                       reuse spots, thereby 
keeping the file from
-                                                       growing unncessarily.
-                                               </td>
+                                               <td> The maximum number of 
empty spots the cache will keep track
+                                                       of. The smallest are 
removed when the maximum size is reached.
+                                                       Keeping track of empty 
spots on disk allows us to reuse spots,
+                                                       thereby keeping the 
file from growing unncessarily.</td>
                                                <td>N</td>
                                                <td>5000</td>
                                        </tr>
                                </table>
                        </subsection>
-
                        <subsection name="Example Configuration">
                                <source>
                                        <![CDATA[
@@ -121,13 +100,12 @@
 jcs.auxiliary.DC.attributes.MaxKeySize=10000
 jcs.auxiliary.DC.attributes.OptimizeAtRemoveCount=300000
 jcs.auxiliary.DC.attributes.OptimizeOnShutdown=true
+jcs.auxiliary.DC.attributes.ClearDiskOnStartup=false
 jcs.auxiliary.DC.attributes.MaxRecycleBinSize=7500
         ]]>
                                </source>
                        </subsection>
-
                        <subsection name="Indexed Disk Event Queue 
Configuration">
-
                                <table>
                                        <tr>
                                                <th>Property</th>
@@ -137,41 +115,29 @@
                                        </tr>
                                        <tr>
                                                <td>EventQueueType</td>
-                                               <td>
-                                                       This should be either 
SINGLE or POOLED. By
-                                                       default the single 
style pool is used. The
-                                                       single style pool uses 
a single thread per
-                                                       event queue. That 
thread is killed whenever
-                                                       the queue is inactive 
for 30 seconds. Since
-                                                       the disk cache uses an 
event queue for every
-                                                       region, if you have 
many regions and they
-                                                       are all active, you 
will be using many
-                                                       threads. To limit the 
number of threads, you
-                                                       can configure the disk 
cache to use the
-                                                       pooled event queue. 
Using more threads than
-                                                       regions will not add 
any benefit for the
-                                                       indexed disk cache, 
since only one thread
-                                                       can read or write at a 
time for a single
-                                                       region.
-                                               </td>
+                                               <td> This should be either 
SINGLE or POOLED. By default the single
+                                                       style pool is used. The 
single style pool uses a single thread
+                                                       per event queue. That 
thread is killed whenever the queue is
+                                                       inactive for 30 
seconds. Since the disk cache uses an event queue
+                                                       for every region, if 
you have many regions and they are all
+                                                       active, you will be 
using many threads. To limit the number of
+                                                       threads, you can 
configure the disk cache to use the pooled event
+                                                       queue. Using more 
threads than regions will not add any benefit
+                                                       for the indexed disk 
cache, since only one thread can read or
+                                                       write at a time for a 
single region.</td>
                                                <td>N</td>
                                                <td>SINGLE</td>
                                        </tr>
                                        <tr>
                                                <td>EventQueuePoolName</td>
-                                               <td>
-                                                       This is the name of the 
pool to use. It is
-                                                       required if you choose 
the POOLED event
-                                                       queue type, otherwise 
it is ignored.
-                                               </td>
+                                               <td> This is the name of the 
pool to use. It is required if you
+                                                       choose the POOLED event 
queue type, otherwise it is ignored.</td>
                                                <td>Y</td>
                                                <td>n/a</td>
                                        </tr>
                                </table>
                        </subsection>
-
-                       <subsection
-                               name="Example Configuration Using Thread Pool">
+                       <subsection name="Example Configuration Using Thread 
Pool">
                                <source>
                                        <![CDATA[
 jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
@@ -196,8 +162,6 @@
         ]]>
                                </source>
                        </subsection>
-
-
                </section>
        </body>
-</document>
+</document>
\ No newline at end of file



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

Reply via email to