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 2006/04/12 00:25:06 UTC

svn commit: r393321 - in /jakarta/jcs/trunk/src/java/org/apache/jcs: engine/control/CompositeCache.java engine/control/CompositeCacheManager.java engine/control/event/ElementEventQueue.java utils/threadpool/ThreadPoolManager.java

Author: asmuts
Date: Tue Apr 11 15:24:52 2006
New Revision: 393321

URL: http://svn.apache.org/viewcvs?rev=393321&view=rev
Log:
Improving formatting and comments

Modified:
    jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCache.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/event/ElementEventQueue.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/utils/threadpool/ThreadPoolManager.java

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCache.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCache.java?rev=393321&r1=393320&r2=393321&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCache.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCache.java Tue Apr 11 15:24:52 2006
@@ -56,7 +56,7 @@
  * This is the primary hub for a single cache/region. It controls the flow of
  * items through the cache. The auxiliary and memory caches are plugged in here.
  * <p>
- * This is the core of a JCS region.
+ * This is the core of a JCS region.  Hence, this simple class is the core of JCS.
  * 
  * @version $Id$
  */
@@ -219,13 +219,6 @@
 
         memCache.update( cacheElement );
 
-        // Updates to all auxiliary caches -- remote and laterals, can add as
-        // many of each
-        // as necessary.
-        // could put the update criteria in each but it would a bit cumbersome
-        // the disk cache would have to check the cache size, the lateral
-        // would have to check the region cattr configuration
-
         // UPDATE AUXILLIARY CACHES
         // There are 3 types of auxiliary caches: remote, lateral, and disk
         // more can be added if future auxiliary caches don't fit the model
@@ -564,11 +557,10 @@
                     }
                 }
             }
-
         }
         catch ( Exception e )
         {
-            log.error( e );
+            log.error( "Problem encountered getting element.", e );
         }
 
         if ( !found )
@@ -696,8 +688,8 @@
      * fromRemote: If a remove call was made on a cache with both, then the
      * remote should have been called. If it wasn't then the remote is down.
      * we'll assume it is down for all. If it did come from the remote then the
-     * caceh is remotely configured and lateral removal is unncessary. If it
-     * came laterally then lateral removal is unnecessary. Does this assumes
+     * cache is remotely configured and lateral removal is unncessary. If it
+     * came laterally then lateral removal is unnecessary. Does this assume
      * that there is only one lateral and remote for the cache? Not really, the
      * intial removal should take care of the problem if the source cache was
      * similiarly configured. Otherwise the remote cache, if it had no laterals,
@@ -802,14 +794,13 @@
     protected synchronized void removeAll( boolean localOnly )
         throws IOException
     {
-
         try
         {
             memCache.removeAll();
 
             if ( log.isDebugEnabled() )
             {
-                log.debug( "Removed All keys from mem cache." );
+                log.debug( "Removed All keys from the memory cache." );
             }
         }
         catch ( IOException ex )
@@ -935,7 +926,6 @@
             {
                 log.error( "Failure disposing of aux", ex );
             }
-
         }
 
         log.info( "In dispose, " + this.cacheName + " disposing of memory cache." );
@@ -949,7 +939,6 @@
         }
 
         log.warn( "Called close for " + cacheName );
-
     }
 
     /**
@@ -1290,7 +1279,6 @@
                 }
             }
         }
-
     }
 
     /**

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java?rev=393321&r1=393320&r2=393321&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java Tue Apr 11 15:24:52 2006
@@ -48,6 +48,14 @@
 /**
  * Manages a composite cache. This provides access to caches and is the primary
  * way to shutdown the caching system as a whole.
+ * <p>
+ * The composite cache manager is responsible for creating / configuring cache
+ * regions. It serves as a factory for the ComositeCache class. The
+ * CompositeCache is the core of JCS, the hub for various auxiliaries.
+ * <p>
+ * It is recommended that you use the JCS convenience class for all cache
+ * access.
+ * 
  */
 public class CompositeCacheManager
     implements IRemoteCacheConstants, Serializable, ICompositeCacheManager, IShutdownObservable
@@ -128,7 +136,7 @@
         {
             if ( log.isInfoEnabled() )
             {
-                log.info( "Instance is null, creating with default config [" + propsFilename + "]" );                
+                log.info( "Instance is null, creating with default config [" + propsFilename + "]" );
             }
 
             instance = createInstance();
@@ -155,7 +163,7 @@
             {
                 log.info( "Instance is null, creating with provided config" );
             }
-            
+
             instance = createInstance();
         }
 
@@ -167,6 +175,7 @@
     /**
      * Simple factory method, must override in subclasses so getInstance creates /
      * returns the correct object.
+     * 
      * @return CompositeCacheManager
      */
     protected static CompositeCacheManager createInstance()
@@ -223,7 +232,6 @@
                     // Ignored
                 }
             }
-
         }
         else
         {
@@ -296,7 +304,7 @@
             {
                 log.debug( "ThreadPoolManager = " + poolMgr );
             }
-            
+
             // configure the cache
             CompositeCacheConfigurator configurator = new CompositeCacheConfigurator( this );
 
@@ -352,8 +360,9 @@
         return this.defaultElementAttr.copy();
     }
 
-    /** 
-     * Gets the cache attribute of the CacheHub object 
+    /**
+     * Gets the cache attribute of the CacheHub object
+     * 
      * @param cacheName
      * @return CompositeCache -- the cache region controller
      */
@@ -362,7 +371,9 @@
         return getCache( cacheName, this.defaultCacheAttr.copy() );
     }
 
-    /** Gets the cache attribute of the CacheHub object 
+    /**
+     * Gets the cache attribute of the CacheHub object
+     * 
      * @param cacheName
      * @param cattr
      * @return
@@ -373,7 +384,9 @@
         return getCache( cattr, this.defaultElementAttr );
     }
 
-    /** Gets the cache attribute of the CacheHub object 
+    /**
+     * Gets the cache attribute of the CacheHub object
+     * 
      * @param cacheName
      * @param cattr
      * @param attr
@@ -385,7 +398,9 @@
         return getCache( cattr, attr );
     }
 
-    /** Gets the cache attribute of the CacheHub object 
+    /**
+     * Gets the cache attribute of the CacheHub object
+     * 
      * @param cattr
      * @return
      */
@@ -395,21 +410,24 @@
     }
 
     /**
-     * If the cache is created the CacheAttributes and the element Attributes
-     * will be ignored. Currently there is no overiding once it is set up.
+     * If the cache has already been created, then the CacheAttributes and the
+     * element Attributes will be ignored. Currently there is no overiding the
+     * CacheAttributes once it is set up. You can change the default
+     * ElementAttributes for a region later.
      * <p>
-     * Overriding hte default elemental atributes will require cahnging the way
+     * Overriding the default elemental atributes will require changing the way
      * the atributes are assigned to elements. Get cache creates a cache with
      * defaults if none are specified. We might want to create separate method
      * for creating/getting. . .
+     * 
      * @param cattr
      * @param attr
-     * @return
+     * @return CompositeCache
      */
     public CompositeCache getCache( ICompositeCacheAttributes cattr, IElementAttributes attr )
     {
         CompositeCache cache;
-        
+
         if ( log.isDebugEnabled() )
         {
             log.debug( "attr = " + attr );
@@ -434,7 +452,7 @@
     }
 
     /**
-     * @param name 
+     * @param name
      */
     public void freeCache( String name )
     {
@@ -443,7 +461,7 @@
 
     /**
      * @param name
-     * @param fromRemote 
+     * @param fromRemote
      */
     public void freeCache( String name, boolean fromRemote )
     {
@@ -464,16 +482,16 @@
         synchronized ( shutdownObservers )
         {
             // We don't need to worry about lcoking the set.
-            // since this is a shutdown command, nor do we need 
+            // since this is a shutdown command, nor do we need
             // to queue these up.
             Iterator it = shutdownObservers.iterator();
             while ( it.hasNext() )
             {
-                IShutdownObserver observer = (IShutdownObserver)it.next();
+                IShutdownObserver observer = (IShutdownObserver) it.next();
                 observer.shutdown();
             }
         }
-        
+
         // do the traditional shutdown of the regions.
         String[] names = getCacheNames();
         int len = names.length;
@@ -497,7 +515,7 @@
     }
 
     /**
-     * @param fromRemote 
+     * @param fromRemote
      */
     private void release( boolean fromRemote )
     {
@@ -533,7 +551,8 @@
     }
 
     /**
-     * Returns a list of the current cache names. 
+     * Returns a list of the current cache names.
+     * 
      * @return String[]
      */
     public String[] getCacheNames()
@@ -548,7 +567,7 @@
     }
 
     /**
-     * @return 
+     * @return
      */
     public int getCacheType()
     {
@@ -556,7 +575,7 @@
     }
 
     /**
-     * @return  ICompositeCacheAttributes
+     * @return ICompositeCacheAttributes
      */
     public ICompositeCacheAttributes getDefaultCattr()
     {
@@ -564,7 +583,7 @@
     }
 
     /**
-     * @param auxFac 
+     * @param auxFac
      */
     void registryFacPut( AuxiliaryCacheFactory auxFac )
     {
@@ -581,7 +600,7 @@
     }
 
     /**
-     * @param auxAttr 
+     * @param auxAttr
      */
     void registryAttrPut( AuxiliaryCacheAttributes auxAttr )
     {
@@ -598,25 +617,25 @@
     }
 
     /**
-     * Gets stats for debugging.  This calls gets statistics and then
-     * puts all the results in a string.  This returns data for all regions.
+     * Gets stats for debugging. This calls gets statistics and then puts all
+     * the results in a string. This returns data for all regions.
      * 
      * @return String
      */
     public String getStats()
     {
-        ICacheStats[] stats =  getStatistics();
+        ICacheStats[] stats = getStatistics();
         if ( stats == null )
         {
             return "NONE";
         }
-        
+
         // force the array elements into a string.
         StringBuffer buf = new StringBuffer();
         int statsLen = stats.length;
         for ( int i = 0; i < statsLen; i++ )
         {
-            buf.append( "\n---------------------------\n" ); 
+            buf.append( "\n---------------------------\n" );
             buf.append( stats[i] );
         }
         return buf.toString();
@@ -676,5 +695,4 @@
             shutdownObservers.remove( observer );
         }
     }
-
 }

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/event/ElementEventQueue.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/event/ElementEventQueue.java?rev=393321&r1=393320&r2=393321&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/event/ElementEventQueue.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/event/ElementEventQueue.java Tue Apr 11 15:24:52 2006
@@ -181,7 +181,6 @@
                 {
                     log.debug( "Something came into the Q" );
                 }
-
             }
 
             // we have the lock, and the list is not empty
@@ -344,9 +343,7 @@
         protected void doRun()
             throws IOException
         {
-
             hand.handleElementEvent( event );
         }
     }
-
 }

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/utils/threadpool/ThreadPoolManager.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/utils/threadpool/ThreadPoolManager.java?rev=393321&r1=393320&r2=393321&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/utils/threadpool/ThreadPoolManager.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/utils/threadpool/ThreadPoolManager.java Tue Apr 11 15:24:52 2006
@@ -52,16 +52,27 @@
  * If a value is not set for a particular pool, the hard coded defaults will be
  * used.
  * 
- * int boundarySize_DEFAULT = 75; int maximumPoolSize_DEFAULT = 150; int
- * minimumPoolSize_DEFAULT = 4; int keepAliveTime_DEFAULT = 1000 * 60 * 5;
- * boolean abortWhenBlocked = false; int startUpSize_DEFAULT = 4;
+ * <pre>
+ * int boundarySize_DEFAULT = 2000;
  * 
+ * int maximumPoolSize_DEFAULT = 150;
+ * 
+ * int minimumPoolSize_DEFAULT = 4;
+ * 
+ * int keepAliveTime_DEFAULT = 1000 * 60 * 5;
+ * 
+ * boolean abortWhenBlocked = false;
+ * 
+ * String whenBlockedPolicy_DEFAULT = IPoolConfiguration.POLICY_RUN;
+ * 
+ * int startUpSize_DEFAULT = 4;
+ * </pre>
  * 
  * You can configure default settings by specifying a default pool in the
  * properties, ie "cache.ccf"
  * 
  * @author Aaron Smuts
- *  
+ * 
  */
 public class ThreadPoolManager
 {
@@ -107,7 +118,7 @@
 
     /**
      * No instances please. This is a singleton.
-     *  
+     * 
      */
     private ThreadPoolManager()
     {
@@ -294,7 +305,7 @@
     /**
      * Intialize the ThreadPoolManager and create all the pools defined in the
      * configuration.
-     *  
+     * 
      */
     protected void configure()
     {
@@ -307,19 +318,19 @@
         {
             try
             {
-            props = PropertyLoader.loadProperties( propsFileName );
+                props = PropertyLoader.loadProperties( propsFileName );
 
-            if ( log.isDebugEnabled() )
-            {
-                log.debug( "File contained " + props.size() + " properties" );
-            }
+                if ( log.isDebugEnabled() )
+                {
+                    log.debug( "File contained " + props.size() + " properties" );
+                }
             }
-            catch( Exception e )
+            catch ( Exception e )
             {
                 log.error( "Problem loading properties. propsFileName [" + propsFileName + "]", e );
             }
         }
-        
+
         if ( props == null )
         {
             log.warn( "No configuration settings found.  Using hardcoded default values for all pools." );
@@ -338,9 +349,10 @@
 
     /**
      * Configures the default PoolConfiguration settings
+     * 
      * @param root
      * @return PoolConfiguration
-     *  
+     * 
      */
     protected PoolConfiguration loadConfig( String root )
     {
@@ -430,12 +442,11 @@
             }
         }
 
-        if ( log.isDebugEnabled() )
+        if ( log.isInfoEnabled() )
         {
-            log.debug( root + " PoolConfiguration = " + config );
+            log.info( root + " PoolConfiguration = " + config );
         }
 
         return config;
     }
-
 }



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