You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by Aaron Smuts <AS...@therealm.com> on 2002/02/13 22:45:53 UTC

RE: cvs commit: jakarta-turbine-stratum/src/java/org/apache/strat um/jcs/engine/group GroupCache.java

Good idea.  I have some aspect code for tracing.  I don't want to move
toward aspectj for a while.  It is sort of a pain.  I'd rather get the
package more stable, then remove some of the tracing and then use more
aspectj over the next month or so.  

Aaron

> -----Original Message-----
> From: jtaylor@apache.org [mailto:jtaylor@apache.org]
> Sent: Wednesday, February 13, 2002 2:14 PM
> To: jakarta-turbine-stratum-cvs@apache.org
> Subject: cvs commit: jakarta-turbine-
> stratum/src/java/org/apache/stratum/jcs/engine/group GroupCache.java
> 
> jtaylor     02/02/13 11:14:00
> 
>   Modified:    .        build.xml default.properties deps.list
>                src/java/org/apache/stratum/jcs/engine Attributes.java
>                         CompositeCacheAttributes.java
>                src/java/org/apache/stratum/jcs/engine/control Cache.java
>                src/java/org/apache/stratum/jcs/engine/group
> GroupCache.java
>   Log:
>   Converted Cache and GroupCache to use commons-logging wrapper to log4j.
> Also,
>   completed removal of 'debug' variable and p() method for those classes.
> 
>   Many of the debug calls that were using that pattern ( and remain as
> calls to
>   log.isDebugEnabled / log.debug ) are just simple tracing calls.
> Specifically
>   method entries ( with params ) and exits. I believe the correct next
> step is
>   to remove those entirely and use aspectj to introduce tracing instead.
> This
>   will clean up the code signifigantly, and will have at least the
> performance
>   of using a static variable ( possibly better since instead of depending
> on the
>   compiler to optomize out those blocks, the code is never introduced ).
> 
>   I also cleaned up the toString methods of a few classes so they print on
> one
>   line, better for logging. I removed one place where the entire cached
> data
>   object is written to the log, and instead have it log the type of the
> object.
>   I was caching some very large strings and other data objects, and having
> the
>   entire toString output in the logs made them much less clear. This is
>   especially a problem since some of my data objects have long and
> meaningfull
>   toString methods for use in velocity templates.
> 
>   There is still a lot of style cleaning to be done in these classes, but
> I
>   wanted to get something in to give Aaron an example of how to use
>   commons-logging rather than log4j directly.
> 
>   Revision  Changes    Path
>   1.17      +1 -0      jakarta-turbine-stratum/build.xml
> 
>   Index: build.xml
>   ===================================================================
>   RCS file: /home/cvs/jakarta-turbine-stratum/build.xml,v
>   retrieving revision 1.16
>   retrieving revision 1.17
>   diff -u -r1.16 -r1.17
>   --- build.xml	12 Feb 2002 21:09:57 -0000	1.16
>   +++ build.xml	13 Feb 2002 19:13:59 -0000	1.17
>   @@ -16,6 +16,7 @@
>        <pathelement location="${commons-beanutils.jar}"/>
>        <pathelement location="${commons-collections.jar}"/>
>        <pathelement location="${commons-util.jar}"/>
>   +    <pathelement location="${commons-logging.jar}"/>
>        <pathelement location="${jgl.jar}"/>
>        <pathelement location="${jetty.jar}"/>
>        <pathelement location="${log4j.jar}"/>
> 
> 
> 
>   1.14      +1 -0      jakarta-turbine-stratum/default.properties
> 
>   Index: default.properties
>   ===================================================================
>   RCS file: /home/cvs/jakarta-turbine-stratum/default.properties,v
>   retrieving revision 1.13
>   retrieving revision 1.14
>   diff -u -r1.13 -r1.14
>   --- default.properties	13 Feb 2002 04:45:10 -0000	1.13
>   +++ default.properties	13 Feb 2002 19:13:59 -0000	1.14
>   @@ -33,6 +33,7 @@
>    commons-beanutils.jar = ${lib.repo}/commons-beanutils.jar
>    commons-collections.jar = ${lib.repo}/commons-collections.jar
>    commons-util.jar = ${lib.repo}/commons-util-0.1-dev.jar
>   +commons-logging.jar = ${lib.repo}/commons-logging.jar
>    dom4j.jar = ${lib.repo}/dom4j-1.1.jar
>    junit.jar = ${lib.repo}/junit-3.7.jar
> 
> 
> 
> 
>   1.7       +1 -0      jakarta-turbine-stratum/deps.list
> 
>   Index: deps.list
>   ===================================================================
>   RCS file: /home/cvs/jakarta-turbine-stratum/deps.list,v
>   retrieving revision 1.6
>   retrieving revision 1.7
>   diff -u -r1.6 -r1.7
>   --- deps.list	13 Feb 2002 19:07:51 -0000	1.6
>   +++ deps.list	13 Feb 2002 19:13:59 -0000	1.7
>   @@ -3,6 +3,7 @@
>    commons-collections.jar
>    commons-logging.jar
>    commons-util-0.1-dev.jar
>   +commons-logging.jar
>    concurrent.jar
>    dom4j-1.1.jar
>    junit-3.7.jar
> 
> 
> 
>   1.5       +11 -7     jakarta-turbine-
> stratum/src/java/org/apache/stratum/jcs/engine/Attributes.java
> 
>   Index: Attributes.java
>   ===================================================================
>   RCS file: /home/cvs/jakarta-turbine-
> stratum/src/java/org/apache/stratum/jcs/engine/Attributes.java,v
>   retrieving revision 1.4
>   retrieving revision 1.5
>   diff -u -r1.4 -r1.5
>   --- Attributes.java	19 Jan 2002 06:27:13 -0000	1.4
>   +++ Attributes.java	13 Feb 2002 19:13:59 -0000	1.5
>   @@ -431,18 +431,22 @@
>        public String toString()
>        {
>            StringBuffer dump = new StringBuffer();
>   -        dump.append( "\n IS_LATERAL = " + IS_LATERAL + "\n" );
>   +
>   +        dump.append( "[ IS_LATERAL = " ).append( IS_LATERAL  )
>   +            .append( ", IS_SPOOL = " ).append( IS_SPOOL )
>   +            .append( ", IS_REMOTE = " ).append( IS_REMOTE )
>   +            .append( ", IS_ETERNAL = " ).append( IS_ETERNAL )
>   +            .append( ", ttl = " ).append( String.valueOf( ttl ) )
>   +            .append( ", createTime = " ).append( String.valueOf(
> createTime ) )
>   +            .append( " ]" );
>   +
>   +        return dump.toString();
>   +
>            //dump.append( " IS_NOFLUSH = " + IS_NOFLUSH + "\n");
>            //dump.append( " IS_REPLY = " + IS_REPLY + "\n");
>            //dump.append( " IS_SYNCHRONIZE = " + IS_SYNCHRONIZE + "\n");
>   -        dump.append( " IS_SPOOL = " + IS_SPOOL + "\n" );
>            //dump.append( " IS_GROUP_TTL_DESTROY = " +
> IS_GROUP_TTL_DESTROY + "\n");
>            //dump.append( " IS_ORIGINAL = " + IS_ORIGINAL + "\n");
>   -        dump.append( " IS_REMOTE = " + IS_REMOTE + "\n" );
>   -        dump.append( " IS_ETERNAL = " + IS_ETERNAL + "\n" );
>   -        dump.append( " ttl = " + String.valueOf( ttl ) + "\n" );
>   -        dump.append( " createTime = " + String.valueOf( createTime ) +
> "\n" );
>   -        return dump.toString();
>        }
> 
> 
> 
> 
> 
>   1.4       +10 -7     jakarta-turbine-
> stratum/src/java/org/apache/stratum/jcs/engine/CompositeCacheAttributes.ja
> va
> 
>   Index: CompositeCacheAttributes.java
>   ===================================================================
>   RCS file: /home/cvs/jakarta-turbine-
> stratum/src/java/org/apache/stratum/jcs/engine/CompositeCacheAttributes.ja
> va,v
>   retrieving revision 1.3
>   retrieving revision 1.4
>   diff -u -r1.3 -r1.4
>   --- CompositeCacheAttributes.java	15 Jan 2002 21:33:33 -0000	1.3
>   +++ CompositeCacheAttributes.java	13 Feb 2002 19:13:59 -0000	1.4
>   @@ -208,13 +208,16 @@
>         */
>        public String toString()
>        {
>   -        StringBuffer info = new StringBuffer();
>   -        info.append( "\n" );
>   -        info.append( "useLateral = " + useLateral + "\n" );
>   -        info.append( "useRemote = " + useRemote + "\n" );
>   -        info.append( "useDisk = " + useDisk + "\n" );
>   -        info.append( "maxObjs = " + maxObjs + "\n" );
>   -        return info.toString();
>   +        StringBuffer dump = new StringBuffer();
>   +
>   +        dump.append( "[ " )
>   +            .append( "useLateral = " ).append( useLateral )
>   +            .append( ", useRemote = " ).append( useRemote )
>   +            .append( ", useDisk = " ).append( useDisk )
>   +            .append( ", maxObjs = " ).append( maxObjs )
>   +            .append( " ]" );
>   +
>   +        return dump.toString();
>        }
> 
>    }
> 
> 
> 
>   1.12      +56 -91    jakarta-turbine-
> stratum/src/java/org/apache/stratum/jcs/engine/control/Cache.java
> 
>   Index: Cache.java
>   ===================================================================
>   RCS file: /home/cvs/jakarta-turbine-
> stratum/src/java/org/apache/stratum/jcs/engine/control/Cache.java,v
>   retrieving revision 1.11
>   retrieving revision 1.12
>   diff -u -r1.11 -r1.12
>   --- Cache.java	13 Feb 2002 04:45:05 -0000	1.11
>   +++ Cache.java	13 Feb 2002 19:13:59 -0000	1.12
>   @@ -77,8 +77,8 @@
>    import org.apache.stratum.jcs.engine.memory.behavior.IMemoryCache;
>    import org.apache.stratum.jcs.engine.memory.lru.LRUMemoryCache;
> 
>   -import org.apache.log4j.Category;
>   -import org.apache.log4j.Priority;
>   +import org.apache.commons.logging.Log;
>   +import org.apache.commons.logging.LogSource;
> 
>    //////////////////////////////////////////////////////
>    /**
>   @@ -88,17 +88,11 @@
>     *@author     asmuts
>     *@created    January 15, 2002
>     */
>   -public class Cache implements ICacheHub, ICache, ICompositeCache,
> Serializable
>   +public class Cache
>   +    implements ICacheHub, ICache, ICompositeCache, Serializable
>    {
>   -
>   -    /**
>   -     *  Development debugging parameters. Calls should be removed by
> the
>   -     *  compiler. TODO: limit and replace with a less intrusive logging
> at a
>   -     *  later stage.
>   -     */
>   -    private final static boolean debugcmd = false;//true;
>   -    private final static boolean debugR = false;//true;
>   -
>   +    private static final Log log = LogSource.getInstance( Cache.class
> );
>   +
>        /**
>         *  Description of the Field
>         */
>   @@ -125,11 +119,6 @@
> 
>        private String source_id =
> "org.apache.stratum.jcs.engine.control.Cache";
> 
>   -    /**
>   -     *  log4j
>   -     */
>   -    protected final Category log;
>   -
>        // statistics
>        private static int numInstances;
>        private int ramHit;
>   @@ -180,26 +169,19 @@
>            this.attr = attr;
>            this.cacheAttr = cattr;
> 
>   -        log = Category.getInstance( Cache.class );
>   -
>   -        if ( debugcmd )
>   -        {
>   -            log.setPriority( Priority.DEBUG );
>   -        }
>   -
>            createMemoryCache( cattr );
> 
>            if ( log.isDebugEnabled() )
>            {
>   -            log.debug( "******************* Constructing cache " +
> cacheName );
>   -        }
>   -        if ( debugcmd )
>   +            log.debug( "Constructed cache with name " + cacheName +
>   +                       " and cache attributes: " + cattr );
>   +        }
>   +        else if ( log.isInfoEnabled() )
>            {
>   -            p( "contructed cache " + cacheName + " cattr = " + cattr );
>   +            log.info( "Constructed cache with name: " + cacheName );
>            }
>        }
> 
>   -
> 
> //////////////////////////////////////////////////////////////////////////
> ////
>        /**
>         *  Description of the Method
>   @@ -252,20 +234,25 @@
>            //if ( this.get( key ) != null ) {
>            //  throw new ObjectExistsException( "Object exists for key " +
> key );
>            //}
>   +
>            if ( key == null || val == null )
>            {
>   -            NullPointerException ex = new NullPointerException( "key="
> + key + " and val=" + val
>   -                 + " must not be null." );
>   -            log.error( ex );
>   -            throw ex;
>   +            NullPointerException npe =
>   +                new NullPointerException( "key=" + key + " and val=" +
> val +
>   +                                          " must not be null." );
>   +
>   +            log.error( "Key or value was null. Exception will be
> thrown", npe );
>   +
>   +            throw npe;
>            }
>   +
>            try
>            {
>                updateCaches( key, val, attr );
>            }
>            catch ( IOException ioe )
>            {
>   -            log.error( ioe );
>   +            log.error( "Failed updating caches", ioe );
>            }
>            return;
>        }
>   @@ -283,9 +270,11 @@
>        protected synchronized void updateCaches( Serializable key,
> Serializable val, Attributes attr )
>            throws IOException
>        {
>   -        if ( debugcmd )
>   +        // FIXME: Replace with tracing aspects
>   +
>   +        if ( log.isDebugEnabled() )
>            {
>   -            p( "updateCaches(key,val,attr) >
> ICache.INCLUDE_REMOTE_CACHE= " + ICache.INCLUDE_REMOTE_CACHE + " key = " +
> key );
>   +            log.debug( "updateCaches(key,val,attr) >
> ICache.INCLUDE_REMOTE_CACHE= " + ICache.INCLUDE_REMOTE_CACHE + " key = " +
> key );
>            }
> 
>            updateCaches( key, val, attr, ICache.INCLUDE_REMOTE_CACHE );
>   @@ -306,10 +295,11 @@
>        protected synchronized void updateCaches( Serializable key,
> Serializable val, Attributes attr, boolean updateRemoteCache )
>            throws IOException
>        {
>   -
>   -        if ( debugcmd )
>   +        // FIXME: Replace with tracing aspects
>   +
>   +        if ( log.isDebugEnabled() )
>            {
>   -            p( "updateCaches(key,val,attr,updateRemoteCache) >
> updateRemoteCache= " + updateRemoteCache + " key = " + key );
>   +            log.debug( "updateCaches(key,val,attr,updateRemoteCache) >
> updateRemoteCache= " + updateRemoteCache + " key = " + key );
>            }
> 
>            CacheElement ce = new CacheElement( cacheName, key, val );
>   @@ -328,9 +318,11 @@
>        public synchronized void update( ICacheElement ce )
>            throws IOException
>        {
>   -        if ( debugcmd )
>   +        // FIXME: Replace with tracing aspects
>   +
>   +        if ( log.isDebugEnabled() )
>            {
>   -            p( "update(ce) > ICache.INCLUDE_REMOTE_CACHE= " +
> ICache.INCLUDE_REMOTE_CACHE + " key = " + ce.getKey() );
>   +            log.debug( "update(ce) > ICache.INCLUDE_REMOTE_CACHE= " +
> ICache.INCLUDE_REMOTE_CACHE + " key = " + ce.getKey() );
>            }
>            update( ce, ICache.INCLUDE_REMOTE_CACHE );
>        }
>   @@ -367,24 +359,20 @@
>                throw new IllegalArgumentException(
>                    "key must not end with " + NAME_COMPONENT_DELIMITER + "
> for a put operation" );
>            }
>   +
>   +        // FIXME: Replace with tracing aspects
> 
>            if ( log.isDebugEnabled() )
>   -        {
>   -            StringBuffer params = new StringBuffer();
>   -            params.append( "Cache.updateExclude(ce,updateRemoteCache) >
> updateRemoteCache = " + updateRemoteCache + " key=" + ce.getKey() + ",
> val=" + ce.getVal() + ", " + ce.getAttributes().toString() );
>   -            log.debug( params.toString() );
>   -        }
>   -        if ( debugcmd )
>   -        {
>   -            p( "updateExclude(ce,updadateRemoteCache) > update
> updateRemoteCache = " + updateRemoteCache + " key = " + ce.getKey() + ",
> updateRemoteCache = " + updateRemoteCache );
>   +        {
>   +            log.debug( "Cache.updateExclude(ce,updateRemoteCache) >
> updateRemoteCache = " + updateRemoteCache + " key=" + ce.getKey() + ",
> value type=" + ce.getVal().getClass().getName() + ", " +
> ce.getAttributes().toString() );
> 
>                if ( updateRemoteCache == ICache.INCLUDE_REMOTE_CACHE )
>                {
>   -                p( "updateRemoteCache is TRUE " + updateRemoteCache );
>   +                log.debug( "updateRemoteCache is TRUE " +
> updateRemoteCache );
>                }
>                else
>                {
>   -                p( "updateRemoteCache is FALSE " + updateRemoteCache );
>   +                log.debug( "updateRemoteCache is FALSE " +
> updateRemoteCache );
>                }
>            }
> 
>   @@ -404,10 +392,10 @@
>            for ( int i = 0; i < auxCaches.length; i++ )
>            {
>                ICache aux = auxCaches[i];
>   -
>   -            if ( debugcmd )
>   +
>   +            if ( log.isDebugEnabled() )
>                {
>   -                p( "aux.getCacheType() = " + aux.getCacheType() );
>   +                log.debug( "aux.getCacheType() = " + aux.getCacheType()
> );
>                }
> 
>                // SEND TO REMOTE STORE
>   @@ -443,10 +431,10 @@
>                {
>                    // lateral can't do the checking since it is dependent
> on the cache region
>                    // restrictions
>   -                if ( debugcmd )
>   +                if ( log.isDebugEnabled() )
>                    {
>   -                    p( "lateralcache in aux list" );
>   -                    p( "cattr " + cacheAttr.getUseLateral() );
>   +                    log.debug( "lateralcache in aux list: cattr " +
>   +                               cacheAttr.getUseLateral() );
>                    }
>                    if ( cacheAttr.getUseLateral() &&
> ce.getAttributes().IS_LATERAL && updateRemoteCache )
>                    {
>   @@ -569,10 +557,9 @@
>         */
>        public Serializable get( Serializable key, boolean container,
> boolean invocation )
>        {
>   -
>   -        if ( debugcmd )
>   +        if ( log.isDebugEnabled() )
>            {
>   -            p( "in cache get(key,container)" );
>   +            log.debug( "in cache get(key,container)" );
>            }
> 
>            ICacheElement ce = null;
>   @@ -603,9 +590,9 @@
> 
>                            if ( ( invocation == this.LOCAL_INVOKATION ) ||
> aux.getCacheType() == aux.DISK_CACHE )
>                            {
>   -                            if ( debugcmd )
>   +                            if ( log.isDebugEnabled() )
>                                {
>   -                                p( "get(key,container,invocation) > in
> local block, aux.getCacheType() = " + aux.getCacheType() );
>   +                                log.debug(
> "get(key,container,invocation) > in local block, aux.getCacheType() = " +
> aux.getCacheType() );
>                                }
> 
>                                try
>   @@ -618,9 +605,9 @@
>                                }
>                            }
> 
>   -                        if ( debugcmd )
>   +                        if ( log.isDebugEnabled() )
>                            {
>   -                            p( "ce = " + ce );
>   +                            log.debug( "ce = " + ce );
>                            }
> 
>                            if ( ce != null )
>   @@ -629,12 +616,6 @@
>                                // Item found in one of the auxiliary
> caches.
>                                auxHit[i]++;
> 
>   -                            if ( debugcmd )
>   -                            {
>   -                                p( cacheName + " -- AUX[" + i + "]-HIT
> for " + key );
>   -                                p( "ce.getKey() = " + ce.getKey() );
>   -                                p( "ce.getVal() = " + ce.getVal() );
>   -                            }
>                                if ( log.isDebugEnabled() )
>                                {
>                                    log.debug( cacheName + " -- AUX[" + i +
> "]-HIT for " + key );
>   @@ -698,15 +679,11 @@
>                // Don't we also want to remove it from the cache ?
>                if ( !ce.getAttributes().IS_ETERNAL && ( (
> System.currentTimeMillis() - ce.getAttributes().createTime ) > (
> ce.getAttributes().ttl * 1000 ) ) )
>                {
>   -                // Item expired.
>   -                //if ( log.logLevel >= log.INFO )
>   -                //{
>   -                log.info( ce.getKey() + " expired" );
>   -                //}
>   -                if ( debugcmd )
>   +                if ( log.isInfoEnabled() )
>                    {
>   -                    p( ce.getKey() + " expired" );
>   -                }
>   +                    log.info( ce.getKey() + " expired" );
>   +                }
>   +
>                    this.remove( key );
>                    //throw new ObjectNotFoundException( key + " expired
> from cache" );
>                    return null;
>   @@ -954,7 +931,7 @@
>                    }
>                }
>            }
>   -        p( "Disposed of cache " + cacheName );
>   +
>            log.warn( "Called close for " + cacheName );
> 
>        }
>   @@ -1177,17 +1154,5 @@
>    //  public void dumpCacheEntries() {
>    //    memCache.dumpCacheEntries();
>    //  }
>   -
>   -    ///////////////////////////////////////////////
>   -    /**
>   -     *  Description of the Method
>   -     *
>   -     *@param  s  Description of the Parameter
>   -     */
>   -    public void p( String s )
>   -    {
>   -        //System.out.println( "Cache: " + s );
>   -        log.debug( "Cache: " + s );
>   -    }
> 
>    }
> 
> 
> 
>   1.9       +95 -133   jakarta-turbine-
> stratum/src/java/org/apache/stratum/jcs/engine/group/GroupCache.java
> 
>   Index: GroupCache.java
>   ===================================================================
>   RCS file: /home/cvs/jakarta-turbine-
> stratum/src/java/org/apache/stratum/jcs/engine/group/GroupCache.java,v
>   retrieving revision 1.8
>   retrieving revision 1.9
>   diff -u -r1.8 -r1.9
>   --- GroupCache.java	13 Feb 2002 04:45:05 -0000	1.8
>   +++ GroupCache.java	13 Feb 2002 19:13:59 -0000	1.9
>   @@ -79,6 +79,9 @@
> 
>    import org.apache.stratum.jcs.utils.reuse.ReadWriteLockManager;
> 
>   +import org.apache.commons.logging.Log;
>   +import org.apache.commons.logging.LogSource;
>   +
>    /**
>     *  Group cache is basically a composite cache with the additional
> capability of
>     *  providing automatic and safe attribute name list update for each
>   @@ -95,14 +98,8 @@
>     */
>    public class GroupCache extends Cache implements ICompositeCache
>    {
>   -    //////////////// debug MUST BE SET TO false in production!
> ///////////////////
>   -    /**
>   -     * Development debugging parameters.  Calls should be removed by
> the compiler.
>   -     * TODO: limit and replace with a less intrusive logging at a later
> stage.
>   -     */
>   -    private final static boolean debug =  false;//true;
>   -    private final static boolean debuggan = false;//true;
>   -
>   +    private static final Log log = LogSource.getInstance(
> GroupCache.class );
>   +
>        /**
>         * Manages locking for group item manipulation.
>         */
>   @@ -150,9 +147,10 @@
>        public GroupCache( String cacheName, ICache[] auxCaches,
> ICompositeCacheAttributes cattr, Attributes attr )
>        {
>            super( cacheName, auxCaches, cattr, attr );
>   -        if ( debug )
>   +
>   +        if ( log.isDebugEnabled() )
>            {
>   -            p( "constructed groupcache " + cacheName + " from super" );
>   +            log.debug( "constructed groupcache " + cacheName + " from
> super" );
>            }
>            //ICompositeCache systemGroupIdCache =
> (ICompositeCache)systemCaches.get( "groupIdCache" );
>        }
>   @@ -171,9 +169,9 @@
>        public GroupCache( String cacheName, ICache[] auxCaches,
> ICompositeCacheAttributes cattr, Attributes attr, ICompositeCache
> systemGroupIdCache )
>        {
>            super( cacheName, auxCaches, cattr, attr );
>   -        if ( debug )
>   +        if ( log.isDebugEnabled() )
>            {
>   -            p( "constructed (2) groupcache " + cacheName + " from
> super" );
>   +            log.debug( "constructed (2) groupcache " + cacheName + "
> from super" );
>            }
>            this.systemGroupIdCache = systemGroupIdCache;
>        }
>   @@ -227,14 +225,14 @@
>            {
>                return getGI( ( GroupId ) key, container );
>            }
>   -        if ( debug )
>   +        if ( log.isDebugEnabled() )
>            {
>   -            p( this.getCacheName() + " getting " + key + " from super "
> );
>   +            log.debug( this.getCacheName() + " getting " + key + " from
> super " );
>                if ( invocation == ICache.LOCAL_INVOKATION )
>                {
>   -              p( "invokation is LOCAL" );
>   +              log.debug( "invokation is LOCAL" );
>                } else {
>   -              p( "invokation is NOT Local" );
>   +              log.debug( "invokation is NOT Local" );
>                }
>            }
> 
>   @@ -266,13 +264,13 @@
>         */
>        public Serializable getGAN( GroupAttrName key, boolean container,
> boolean invocation )
>        {
>   -        if ( debug )
>   +        if ( log.isDebugEnabled() )
>            {
>                if ( invocation == ICache.LOCAL_INVOKATION )
>                {
>   -              p( "invokation is LOCAL" );
>   +              log.debug( "invokation is LOCAL" );
>                } else {
>   -              p( "invokation is NOT Local" );
>   +              log.debug( "invokation is NOT Local" );
>                }
>            }
> 
>   @@ -316,14 +314,14 @@
>         */
>        public Serializable getGI( GroupId gid, boolean container, boolean
> invocation )
>        {
>   -        if ( debug )
>   +        if ( log.isDebugEnabled() )
>            {
>   -            p( "getGi(gid,container,invocation)" );
>   +            log.debug( "getGi(gid,container,invocation)" );
>                if ( invocation == ICache.LOCAL_INVOKATION )
>                {
>   -              p( "invocation is LOCAL" );
>   +              log.debug( "invocation is LOCAL" );
>                } else {
>   -              p( "invocation is NOT Local" );
>   +              log.debug( "invocation is NOT Local" );
>                }
>            }
>            Object obj = null;
>   @@ -332,9 +330,9 @@
>            {
>                //obj = super.get(gid.key, container);
>                obj = systemGroupIdCache.get( gid.key, container,
> invocation );
>   -            if ( debug )
>   +            if ( log.isDebugEnabled() )
>                {
>   -                p( "getGi(gid,container,invocation) > got obj in getGi
> " + obj );
>   +                log.debug( "getGi(gid,container,invocation) > got obj
> in getGi " + obj );
>                }
>            }
>            catch ( IOException ioeg )
>   @@ -360,21 +358,16 @@
>            {
>                locker.readLock( id );
>            }
>   -        catch ( InterruptedException ex )
>   +        catch ( InterruptedException e )
>            {
>   -            // should never happen.
>   -            ex.printStackTrace();
>   -            //////////////// debug MUST BE SET TO false in production!
> ///////////////////
>   -            if ( debug )
>   -            {
>   -                try
>   -                {
>   -                    System.in.read();
>   -                }
>   -                catch ( IOException ignore )
>   -                {}
>   -            }
>   -            throw new IllegalStateException( ex.getMessage() );
>   +            // This previously would wait for console input before
>   +            // continuing if the debug flag was set. I consider this
>   +            // a BAD IDEA since it could introduce signifigant
>   +            // confusion. ( There are other ways to accomplish this,
>   +            // introduction or using a debugger (breakpoints) come to
>   +            // mind. [james@jamestaylor.org]
>   +
>   +            log.error( "Was interrupted while acquiring read lock", e
> );
>            }
>        }
> 
>   @@ -391,21 +384,11 @@
>            {
>                locker.writeLock( id );
>            }
>   -        catch ( InterruptedException ex )
>   +        catch ( InterruptedException e )
>            {
>   -            // should never happen.
>   -            ex.printStackTrace();
>   -            //////////////// debug MUST BE SET TO false in production!
> ///////////////////
>   -            if ( debug )
>   -            {
>   -                try
>   -                {
>   -                    System.in.read();
>   -                }
>   -                catch ( IOException ignore )
>   -                {}
>   -            }
>   -            throw new IllegalStateException( ex.getMessage() );
>   +            // See note in readLock()
>   +
>   +            log.error( "Was interrupted while acquiring read lock", e
> );
>            }
>        }
> 
>   @@ -425,9 +408,9 @@
>            {
>                try
>                {
>   -                if ( debug )
>   +                if ( log.isDebugEnabled() )
>                    {
>   -                    p( "putting via putGAN((GroupAttrName)key, val,
> attr) method" );
>   +                    log.debug( "putting via putGAN((GroupAttrName)key,
> val, attr) method" );
>                    }
>                    putGAN( ( GroupAttrName ) key, val, attr );
>                }
>   @@ -435,9 +418,9 @@
>                {}
>                return;
>            }
>   -        if ( debug )
>   +        if ( log.isDebugEnabled() )
>            {
>   -            p( "put(key,val,attr) > updating " + key + " via super
> method, attr.IS_REMOTE = " + attr.IS_REMOTE );
>   +            log.debug( "put(key,val,attr) > updating " + key + " via
> super method, attr.IS_REMOTE = " + attr.IS_REMOTE );
>            }
> 
>            // NOT GROUP RELATED
>   @@ -471,9 +454,9 @@
>            {
>                try
>                {
>   -                if ( debug )
>   +                if ( log.isDebugEnabled() )
>                    {
>   -                    p( "putting via putGAN((GroupAttrName)key, val)
> method" );
>   +                    log.debug( "putting via putGAN((GroupAttrName)key,
> val) method" );
>                    }
>                    putGAN( ( GroupAttrName ) key, val );
>                }
>   @@ -481,9 +464,10 @@
>                {}
>                return;
>            }
>   -        if ( debug )
>   +
>   +        if ( log.isDebugEnabled() )
>            {
>   -            p( "put(key,value) -- updating " + key + " via super
> method" );
>   +            log.debug( "put(key,value) -- updating " + key + " via
> super method" );
>            }
> 
>            //super.put(key, val);
>   @@ -518,9 +502,9 @@
>            {
>                try
>                {
>   -                if ( debug )
>   +                if ( log.isDebugEnabled() )
>                    {
>   -                    p( "update(ce) > putting via
> putGAN((GroupAttrName)key, val) method" );
>   +                    log.debug( "update(ce) > putting via
> putGAN((GroupAttrName)key, val) method" );
>                    }
>                    putGAN( ( GroupAttrName )ce.getKey(), ce.getVal() );
>                }
>   @@ -528,9 +512,9 @@
>                {}
>                return;
>            }
>   -        if ( debug )
>   +        if ( log.isDebugEnabled() )
>            {
>   -            p( "update(ce) > updating " + ce.getKey() + " via super
> method" );
>   +            log.debug( "update(ce) > updating " + ce.getKey() + " via
> super method" );
>            }
> 
>            try
>   @@ -564,14 +548,14 @@
>            {
>                try
>                {
>   -                if ( debug )
>   +                if ( log.isDebugEnabled() )
>                    {
>   -                    p( "update(ce,invocation) >putting via ga method"
> );
>   +                    log.debug( "update(ce,invocation) >putting via ga
> method" );
>                        if ( invocation == ICache.LOCAL_INVOKATION )
>                        {
>   -                      p( "invocation is LOCAL" );
>   +                      log.debug( "invocation is LOCAL" );
>                        } else {
>   -                      p( "invocation is NOT Local" );
>   +                      log.debug( "invocation is NOT Local" );
>                        }
>                    }
>                    Attributes attrE = ( Attributes ) this.attr.copy();
>   @@ -581,9 +565,9 @@
>                {}
>                return;
>            }
>   -        if ( debug )
>   +        if ( log.isDebugEnabled() )
>            {
>   -            p( "update(ce,invocation) > updating " + key + " via super
> method" );
>   +            log.debug( "update(ce,invocation) > updating " + key + "
> via super method" );
>            }
> 
>            // TODO: what about id? not possible here?
>   @@ -624,9 +608,9 @@
>        public void putGAN( GroupAttrName key, Serializable val )
>            throws IOException
>        {
>   -        if ( debug )
>   +        if ( log.isDebugEnabled() )
>            {
>   -            p( "in putGAN(GroupAttrName key, Serializable val) method"
> );
>   +            log.debug( "in putGAN(GroupAttrName key, Serializable val)
> method" );
>            }
>            if ( key == null || val == null )
>            {
>   @@ -656,10 +640,8 @@
>        private void putGAN( GroupAttrName key, Serializable val,
> Attributes attrE )
>            throws IOException
>        {
>   -        if ( debug )
>   -        {
>   -            p( "in putGAN( gan,val,attr) " );
>   -        }
>   +        log.debug( "in putGAN( gan,val,attr) " );
>   +
>            putGAN( key, val, attrE, ICache.LOCAL_INVOKATION );
>        }
> 
>   @@ -678,15 +660,15 @@
>            throws IOException
>        {
> 
>   -        if ( debug )
>   +        if ( log.isDebugEnabled() )
>            {
>                //p( "in putGAN( gan,val,attr,boolean updateRemote) " );
>   -            p( "in putGAN( gan,val,attr,boolean invocation) " );
>   +            log.debug( "in putGAN( gan,val,attr,boolean invocation) "
> );
>                if ( invocation == ICache.LOCAL_INVOKATION )
>                {
>   -              p( "invocation is LOCAL" );
>   +              log.debug( "invocation is LOCAL" );
>                } else {
>   -              p( "invocation is NOT Local" );
>   +              log.debug( "invocation is NOT Local" );
>                }
>            }
> 
>   @@ -699,10 +681,12 @@
>                //updateCaches(key, val, attrE, INCLUDE_REMOTE_CACHE);
>                CacheElement ce = new CacheElement( this.getCacheName(),
> key, val );
>                ce.setAttributes( attrE );
>   -            if ( debuggan )
>   +
>   +            if ( log.isDebugEnabled() )
>                {
>   -                p( "putGAN( gan,val,attr,boolean invocation) > updating
> group attribute via super" );
>   +                log.debug( "putGAN( gan,val,attr,boolean invocation) >
> updating group attribute via super" );
>                }
>   +
>                // SEND THE ELEMENT IF THE INVOCATION WAS LOCAL
>                // decide what to do with this item
>                boolean updateRemote = false;
>   @@ -725,9 +709,9 @@
>                }
>                attrNameSet.add( key.attrName );
> 
>   -            if ( debuggan )
>   +            if ( log.isDebugEnabled() )
>                {
>   -                p( "putGAN( gan,val,attr,boolean invocation) >
> attrNameSet.size()  = " + attrNameSet.size() );
>   +                log.debug( "putGAN( gan,val,attr,boolean invocation) >
> attrNameSet.size()  = " + attrNameSet.size() );
>                }
> 
>                CacheElement ceID = new CacheElement( this.getCacheName(),
> groupId.key, attrNameSet );
>   @@ -814,10 +798,8 @@
>         */
>        public boolean remove( Serializable key )
>        {
>   -        if ( debug )
>   -        {
>   -            p( "in basic remove" );
>   -        }
>   +        log.debug( "in basic remove" );
>   +
>            // if expired super will call remove and we can't have a lock
>            // need a third method
>            return remove( key, ICache.LOCAL_INVOKATION );
>   @@ -839,14 +821,14 @@
>            // THIS IS A GROUP ELEMENT
>            if ( key instanceof GroupAttrName )
>            {
>   -            if ( debug )
>   +            if ( log.isDebugEnabled() )
>                {
>   -                p( "calling removeGAN" );
>   +                log.debug( "calling removeGAN" );
>                    if ( invocation == ICache.LOCAL_INVOKATION )
>                    {
>   -                  p( "invokation is LOCAL" );
>   +                  log.debug( "invokation is LOCAL" );
>                    } else {
>   -                  p( "invokation is NOT Local" );
>   +                  log.debug( "invokation is NOT Local" );
>                    }
>                }
>                return removeGAN( ( GroupAttrName ) key, invocation );
>   @@ -855,28 +837,28 @@
>            // THIS IS A GROUP ID
>            if ( key instanceof GroupId )
>            {
>   -            if ( debug )
>   +            if ( log.isDebugEnabled() )
>                {
>   -                p( "call removeGI" );
>   +                log.debug( "call removeGI" );
>                    if ( invocation == ICache.LOCAL_INVOKATION )
>                    {
>   -                  p( "invokation is LOCAL" );
>   +                  log.debug( "invokation is LOCAL" );
>                    } else {
>   -                  p( "invokation is NOT Local" );
>   +                  log.debug( "invokation is NOT Local" );
>                    }
>                }
>                return removeGI( ( GroupId ) key, invocation );
>            }
> 
>            // NOT GROUP RELATED
>   -        if ( debug )
>   +        if ( log.isDebugEnabled() )
>            {
>   -            p( "call super.remove, " + invocation + " for " + key );
>   +            log.debug( "call super.remove, " + invocation + " for " +
> key );
>                if ( invocation == ICache.LOCAL_INVOKATION )
>                {
>   -              p( "invokation is LOCAL" );
>   +              log.debug( "invokation is LOCAL" );
>                } else {
>   -              p( "invokation is NOT Local" );
>   +              log.debug( "invokation is NOT Local" );
>                }
>            }
>            return super.remove( key, invocation );
>   @@ -903,14 +885,14 @@
>        {
> 
>            boolean ret;
>   -        if ( debug )
>   +        if ( log.isDebugEnabled() )
>            {
>   -            p( "in removeGAN" );
>   +            log.debug( "in removeGAN" );
>                if ( invocation == ICache.LOCAL_INVOKATION )
>                {
>   -              p( "invocation is LOCAL" );
>   +              log.debug( "invocation is LOCAL" );
>                } else {
>   -              p( "invocation is NOT Local" );
>   +              log.debug( "invocation is NOT Local" );
>                }
> 
>            }
>   @@ -995,9 +977,9 @@
> 
>                            CacheElement ceID = new CacheElement(
> this.getCacheName(), groupId.key, attrNameSet );
>                            ceID.setAttributes( ce.attr );
>   -                        if ( debug )
>   +                        if ( log.isDebugEnabled() )
>                            {
>   -                            p(
> "updateGroupAttrNameSet((groupAttrname)key,invocation,remove) > calling
> systemGroupIdCache.update( ceID, EXCLUDE_REMOTE_CACHE )" );
>   +                            log.debug(
> "updateGroupAttrNameSet((groupAttrname)key,invocation,remove) > calling
> systemGroupIdCache.update( ceID, EXCLUDE_REMOTE_CACHE )" );
>                            }
>                            // ALWAYS EXCLUDE THE REMOTE CACHE
>                            // TODO: should this be configurable? no
>   @@ -1016,9 +998,9 @@
>                        //removeGI(groupId, invokation, true );
>                        try
>                        {
>   -                        if ( debug )
>   +                        if ( log.isDebugEnabled() )
>                            {
>   -                            p( "calling systemGroupIdCache.remove(
> groupId.key, EXCLUDE_REMOTE_CACHE )" );
>   +                            log.debug( "calling
> systemGroupIdCache.remove( groupId.key, EXCLUDE_REMOTE_CACHE )" );
>                            }
>                            // unlike insertion, removal should go remote
> if locally invoked
>                            boolean updateRemote = false;
>   @@ -1048,10 +1030,8 @@
>         */
>        public void removeGI( GroupId groupId )
>        {
>   -        if ( debug )
>   -        {
>   -            p( "removeGI" );
>   -        }
>   +        log.debug( "removeGI" );
>   +
>            removeGI( groupId, ICache.LOCAL_INVOKATION );
>        }
> 
>   @@ -1089,10 +1069,8 @@
>            // problem with removing expired while getting!
>            skipLock = false;
> 
>   -        if ( debug )
>   -        {
>   -            p( "in removeGI" );
>   -        }
>   +        log.debug( "in removeGI" );
>   +
>            if ( !skipLock )
>            {
>                writeLock( groupId.key );
>   @@ -1145,21 +1123,5 @@
>            }
>            return ce.getAttributes();
>        }
>   -
>   -
>   -    ////////////////////////////////////////
>   -    /**
>   -     *  Easy method for printing to system out for
>   -     *  development debugging.  All of these should be
>   -     *  removed by the compiler since they are in
>   -     *  if blocks controlled by a static final variable.
>   -     *
>   -     *@param  s  Description of the Parameter
>   -     */
>   -    public void p( String s )
>   -    {
>   -        System.out.println( "GroupCache: " + s );
>   -    }
>   -
>    }
> 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:turbine-dev-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:turbine-dev-
> help@jakarta.apache.org>

RE: cvs commit: jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/group GroupCache.java

Posted by Aaron Smuts <aa...@verizon.net>.
Great!  I'll write some more.  There is so much that could be
documented.  Is there a project that has especially good documentation
that follows a format or cover certain areas that I should consider?

Aaron

> -----Original Message-----
> From: Pete Kazmier [mailto:pete@kazmier.com]
> Sent: Thursday, February 14, 2002 10:12 PM
> To: 'Turbine Developers List'
> Subject: Re: cvs commit: jakarta-turbine-
> stratum/src/java/org/apache/stratum/jcs/engine/group GroupCache.java
> 
> Well, I'm just going to convert all of the jcs html docs that are
> located in the stratum docs/jcs directory.  If you have any more jcs
> docs that need to be converted, please put them into CVS or mail them
to
> me.  I'll post back to the list after I've converted all of them.
> 
> pete
> 
> On Thu, Feb 14, 2002 at 05:04:12AM -0500, Pete Kazmier wrote:
> > This is something I can help you with.  If you have docs that just
need
> > to be formatted in xdoc style, I'd be more than happy to do that for
> > you.  Please let me know if you want some assistance.
> 
> > On Wed, Feb 13, 2002 at 09:25:05PM -0500, Aaron Smuts wrote:
> > > Is there anything specific you would like documented?  I still
need to
> > > format the few docs I put in.  I just haven't had time.  Sorry.
> 
> --
> To unsubscribe, e-mail:   <mailto:turbine-dev-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:turbine-dev-
> help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/group GroupCache.java

Posted by Pete Kazmier <pe...@kazmier.com>.
Well, I'm just going to convert all of the jcs html docs that are
located in the stratum docs/jcs directory.  If you have any more jcs
docs that need to be converted, please put them into CVS or mail them to
me.  I'll post back to the list after I've converted all of them.

pete

On Thu, Feb 14, 2002 at 05:04:12AM -0500, Pete Kazmier wrote:
> This is something I can help you with.  If you have docs that just need
> to be formatted in xdoc style, I'd be more than happy to do that for
> you.  Please let me know if you want some assistance.

> On Wed, Feb 13, 2002 at 09:25:05PM -0500, Aaron Smuts wrote:
> > Is there anything specific you would like documented?  I still need to
> > format the few docs I put in.  I just haven't had time.  Sorry.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/group GroupCache.java

Posted by Pete Kazmier <pe...@kazmier.com>.
Aaron,

This is something I can help you with.  If you have docs that just need
to be formatted in xdoc style, I'd be more than happy to do that for
you.  Please let me know if you want some assistance.

Thanks,
Pete

On Wed, Feb 13, 2002 at 09:25:05PM -0500, Aaron Smuts wrote:
> Is there anything specific you would like documented?  I still need to
> format the few docs I put in.  I just haven't had time.  Sorry.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: cvs commit: jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/group GroupCache.java

Posted by Aaron Smuts <aa...@verizon.net>.
Is there anything specific you would like documented?  I still need to
format the few docs I put in.  I just haven't had time.  Sorry.

Aaron

> -----Original Message-----
> From: James Taylor [mailto:jtaylor@4lane.com]
> Sent: Wednesday, February 13, 2002 8:06 PM
> To: Turbine Developers List
> Subject: RE: cvs commit: jakarta-turbine-
> stratum/src/java/org/apache/stratum/jcs/engine/group GroupCache.java
> 
> > Good idea.  I have some aspect code for tracing.  I don't want to
move
> > toward aspectj for a while.  It is sort of a pain.  I'd rather get
the
> > package more stable, then remove some of the tracing and then use
more
> > aspectj over the next month or so.
> 
> Well, I'd already started with aspectj. It shouldn't have to be hard,
I
> want to get it seamlessly integrated with the build process.
> 
> I agree that getting it more stable should be the first priority, but
> since I don't yet have a good handle on what problems need fixing,
> working on logging, documentation, and tests is useful for me. And
good
> clean logging helps me (and I suspect others) to understand and trust
> the package. Same for documentation =]
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:turbine-dev-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:turbine-dev-
> help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: cvs commit: jakarta-turbine-stratum/src/java/org/apache/strat um/jcs/engine/group GroupCache.java

Posted by James Taylor <jt...@4lane.com>.
> Good idea.  I have some aspect code for tracing.  I don't want to move
> toward aspectj for a while.  It is sort of a pain.  I'd rather get the
> package more stable, then remove some of the tracing and then use more
> aspectj over the next month or so.  

Well, I'd already started with aspectj. It shouldn't have to be hard, I
want to get it seamlessly integrated with the build process.

I agree that getting it more stable should be the first priority, but
since I don't yet have a good handle on what problems need fixing,
working on logging, documentation, and tests is useful for me. And good
clean logging helps me (and I suspect others) to understand and trust
the package. Same for documentation =]


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>