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 2008/01/16 19:28:14 UTC

svn commit: r612538 - in /jakarta/jcs/trunk/src: java/org/apache/jcs/auxiliary/disk/jdbc/ java/org/apache/jcs/auxiliary/disk/jdbc/mysql/ java/org/apache/jcs/auxiliary/disk/jdbc/mysql/util/ test/org/apache/jcs/auxiliary/disk/

Author: asmuts
Date: Wed Jan 16 10:28:13 2008
New Revision: 612538

URL: http://svn.apache.org/viewvc?rev=612538&view=rev
Log:
There were a couple of error logs in the jdbc disk cache that did not use the two argument error() method.  Hence, the stack trace was missing from the logs.  I fixed this and added a few missing javadocs here and there.

Modified:
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCache.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheAttributes.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheFactory.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/util/ScheduleFormatException.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/util/ScheduleParser.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/DiskTestObject.java

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=612538&r1=612537&r2=612538&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 Jan 16 10:28:13 2008
@@ -47,13 +47,11 @@
 /**
  * This is the jdbc disk cache plugin.
  * <p>
- * It expects a table created by the following script. The table name is
- * configurable.
+ * It expects a table created by the following script. The table name is configurable.
  * <p>
- *
+ * 
  * <pre>
  *                       drop TABLE JCS_STORE;
- *
  *                       CREATE TABLE JCS_STORE
  *                       (
  *                       CACHE_KEY                  VARCHAR(250)          NOT NULL,
@@ -67,42 +65,49 @@
  *                       PRIMARY KEY (CACHE_KEY, REGION)
  *                       );
  * </pre>
- *
+ * 
  * <p>
- * The cleanup thread will delete non eternal items where (now - create time) >
- * max life seconds * 1000
+ * The cleanup thread will delete non eternal items where (now - create time) > max life seconds *
+ * 1000
  * <p>
- * To speed up the deletion the SYSTEM_EXPIRE_TIME_SECONDS is used instead. It
- * is recommended that an index be created on this column is you will have over
- * a million records.
+ * To speed up the deletion the SYSTEM_EXPIRE_TIME_SECONDS is used instead. It is recommended that
+ * an index be created on this column is you will have over a million records.
  * <p>
  * @author Aaron Smuts
  */
 public class JDBCDiskCache
     extends AbstractDiskCache
 {
+    /** The local logger. */
     private final static Log log = LogFactory.getLog( JDBCDiskCache.class );
 
+    /** Don't change. */
     private static final long serialVersionUID = -7169488308515823492L;
 
+    /** custom serialization */
     private IElementSerializer elementSerializer = new StandardSerializer();
 
+    /** configuration */
     private JDBCDiskCacheAttributes jdbcDiskCacheAttributes;
 
+    /** # of times update was called */
     private int updateCount = 0;
 
+    /** # of times get was called */
     private int getCount = 0;
 
-    // if count % interval == 0 then log
+    /** if count % interval == 0 then log */
     private static final int LOG_INTERVAL = 100;
 
+    /** db connection pool */
     private JDBCDiskCachePoolAccess poolAccess = null;
 
+    /** tracks optimization */
     private TableState tableState;
 
     /**
-     * Constructs a JDBC Disk Cache for the provided cache attributes. The table
-     * state object is used to mark deletions.
+     * Constructs a JDBC Disk Cache for the provided cache attributes. The table state object is
+     * used to mark deletions.
      * <p>
      * @param cattr
      * @param tableState
@@ -160,9 +165,12 @@
         }
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.apache.jcs.auxiliary.disk.AbstractDiskCache#doUpdate(org.apache.jcs.engine.behavior.ICacheElement)
+    /**
+     * Inserts or updates. By default it will try to insert. If the item exists we will get an
+     * error. It will then update. This behavior is configurable. The cache can be configured to
+     * check before inserting.
+     * <p>
+     * @param ce
      */
     public void doUpdate( ICacheElement ce )
     {
@@ -438,8 +446,7 @@
     }
 
     /**
-     * Queries the database for the value. If it gets a result, the value is
-     * deserialized.
+     * Queries the database for the value. If it gets a result, the value is deserialized.
      * <p>
      * @see org.apache.jcs.auxiliary.disk.AbstractDiskCache#doGet(java.io.Serializable)
      */
@@ -449,7 +456,7 @@
 
         if ( log.isDebugEnabled() )
         {
-            log.debug( "Getting " + key + " from disk" );
+            log.debug( "Getting [" + key + "] from disk" );
         }
 
         if ( !alive )
@@ -492,11 +499,11 @@
                             }
                             catch ( IOException ioe )
                             {
-                                log.error( ioe );
+                                log.error( "Problem getting item for key [" + key + "]", ioe );
                             }
                             catch ( Exception e )
                             {
-                                log.error( "Problem getting item.", e );
+                                log.error( "Problem getting item for key [" + key + "]", e );
                             }
                         }
                     }
@@ -528,7 +535,7 @@
         }
         catch ( SQLException sqle )
         {
-            log.error( sqle );
+            log.error( "Caught a SQL exception trying to get the item for key [" + key + "]", sqle );
         }
 
         if ( log.isInfoEnabled() )
@@ -544,8 +551,8 @@
     }
 
     /**
-     * Returns true if the removal was succesful; or false if there is nothing
-     * to remove. Current implementation always result in a disk orphan.
+     * Returns true if the removal was succesful; or false if there is nothing to remove. Current
+     * implementation always results in a disk orphan.
      * <p>
      * @param key
      * @return boolean
@@ -581,7 +588,7 @@
                     psSelect.setString( 2, key.toString() );
                 }
 
-                psSelect.executeUpdate( );
+                psSelect.executeUpdate();
 
                 alive = true;
             }
@@ -615,7 +622,10 @@
         return false;
     }
 
-    /** This should remove all elements. */
+    /**
+     * This should remove all elements. The auxiliary can be configured to forbid this behavior. If
+     * remove all is not allowed, the method balks.
+     */
     public void doRemoveAll()
     {
         // it should never get here formt he abstract dis cache.
@@ -631,7 +641,7 @@
                     psDelete = con.prepareStatement( sql );
                     psDelete.setString( 1, this.getCacheName() );
                     alive = true;
-                    psDelete.executeUpdate( );
+                    psDelete.executeUpdate();
                 }
                 catch ( SQLException e )
                 {
@@ -704,7 +714,7 @@
 
                 alive = true;
 
-                deleted = psDelete.executeUpdate( );
+                deleted = psDelete.executeUpdate();
             }
             catch ( SQLException e )
             {
@@ -741,8 +751,7 @@
     }
 
     /**
-     * Typically this is used to handle errors by last resort, force content
-     * update, or removeall
+     * Typically this is used to handle errors by last resort, force content update, or removeall
      */
     public void reset()
     {
@@ -853,7 +862,7 @@
 
     /**
      * @param groupName
-     * @return
+     * @return Set
      */
     public Set getGroupKeys( String groupName )
     {
@@ -865,8 +874,7 @@
     }
 
     /**
-     * @param elementSerializer
-     *            The elementSerializer to set.
+     * @param elementSerializer The elementSerializer to set.
      */
     public void setElementSerializer( IElementSerializer elementSerializer )
     {
@@ -894,8 +902,7 @@
     }
 
     /**
-     * @param jdbcDiskCacheAttributes
-     *            The jdbcDiskCacheAttributes to set.
+     * @param jdbcDiskCacheAttributes The jdbcDiskCacheAttributes to set.
      */
     protected void setJdbcDiskCacheAttributes( JDBCDiskCacheAttributes jdbcDiskCacheAttributes )
     {
@@ -920,6 +927,8 @@
 
     /**
      * Extends the parent stats.
+     * <p>
+     * @return IStats
      */
     public IStats getStatistics()
     {
@@ -1007,6 +1016,8 @@
 
     /**
      * For debugging.
+     * <p>
+     * @return this.getStats();
      */
     public String toString()
     {

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCache.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCache.java?rev=612538&r1=612537&r2=612538&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCache.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCache.java Wed Jan 16 10:28:13 2008
@@ -38,10 +38,13 @@
 public class MySQLDiskCache
     extends JDBCDiskCache
 {
+    /** don't change */
     private static final long serialVersionUID = -7169488308515823491L;
 
+    /** local logger */
     private final static Log log = LogFactory.getLog( MySQLDiskCache.class );
 
+    /** config attributes */
     MySQLDiskCacheAttributes mySQLDiskCacheAttributes;
 
     /**

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheAttributes.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheAttributes.java?rev=612538&r1=612537&r2=612538&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheAttributes.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheAttributes.java Wed Jan 16 10:28:13 2008
@@ -29,6 +29,7 @@
 public class MySQLDiskCacheAttributes
     extends JDBCDiskCacheAttributes
 {
+    /** Don't change. */
     private static final long serialVersionUID = -6535808344813320061L;
 
     /**

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheFactory.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheFactory.java?rev=612538&r1=612537&r2=612538&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheFactory.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheFactory.java Wed Jan 16 10:28:13 2008
@@ -32,12 +32,17 @@
 public class MySQLDiskCacheFactory
     implements AuxiliaryCacheFactory
 {
+    /** name of the factory */
     private String name = "JDBCDiskCacheFactory";
 
     /**
      * This factory method should create an instance of the mysqlcache.
+     * <p>
+     * @param rawAttr 
+     * @param cacheManager 
+     * @return AuxiliaryCache
      */
-    public AuxiliaryCache createCache( AuxiliaryCacheAttributes rawAttr, ICompositeCacheManager arg1 )
+    public AuxiliaryCache createCache( AuxiliaryCacheAttributes rawAttr, ICompositeCacheManager cacheManager )
     {
         MySQLDiskCacheManager mgr = MySQLDiskCacheManager.getInstance( (MySQLDiskCacheAttributes) rawAttr );
         return mgr.getCache( (MySQLDiskCacheAttributes) rawAttr );
@@ -45,6 +50,8 @@
 
     /**
      * The name of the factory.
+     * <p>
+     * @param nameArg 
      */
     public void setName( String nameArg )
     {
@@ -52,7 +59,9 @@
     }
 
     /**
-     * Returns the display name
+     * Returns the display name.
+     * <p>
+     * @return factory name
      */
     public String getName()
     {

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/util/ScheduleFormatException.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/util/ScheduleFormatException.java?rev=612538&r1=612537&r2=612538&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/util/ScheduleFormatException.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/util/ScheduleFormatException.java Wed Jan 16 10:28:13 2008
@@ -27,6 +27,7 @@
 public class ScheduleFormatException
     extends Exception
 {
+    /** don't change */
     private static final long serialVersionUID = 1L;
 
     /**

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/util/ScheduleParser.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/util/ScheduleParser.java?rev=612538&r1=612537&r2=612538&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/util/ScheduleParser.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/util/ScheduleParser.java Wed Jan 16 10:28:13 2008
@@ -63,7 +63,7 @@
      * combo will be seen.
      * <p>
      * @param startTime
-     * @return
+     * @return Date
      * @throws ScheduleFormatException
      */
     public static Date getDateForSchedule( String startTime )

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/DiskTestObject.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/DiskTestObject.java?rev=612538&r1=612537&r2=612538&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/DiskTestObject.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/DiskTestObject.java Wed Jan 16 10:28:13 2008
@@ -27,6 +27,7 @@
 public class DiskTestObject
     implements Serializable
 {
+    /** don't change */
     private static final long serialVersionUID = 1L;
 
     /**



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