asmuts      02/01/16 16:19:38

  Modified:    src/conf cache.ccf
               src/java/org/apache/stratum/jcs/access GroupCacheAccess.java
               src/java/org/apache/stratum/jcs/auxiliary/disk/jisp
                        JISPCache.java
               src/java/org/apache/stratum/jcs/auxiliary/remote
                        RemoteCacheListener.java
               src/java/org/apache/stratum/jcs/auxiliary/remote/group
                        RemoteGroupCacheListener.java
               src/java/org/apache/stratum/jcs/engine/control Cache.java
               src/java/org/apache/stratum/jcs/engine/group GroupCache.java
  Log:
  Cleaning up the GroupCache -- standardizing methods
  
  cache uses "updateRemote"  whereas gorupCache uses "isLocal"
  
  stuff gets passed up and the meaning changes!  Trying to prevent this.
  
  Almost done with this.
  
  tried to make jisp moe to an error file, not done
  
  Revision  Changes    Path
  1.3       +1 -1      jakarta-turbine-stratum/src/conf/cache.ccf
  
  Index: cache.ccf
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-stratum/src/conf/cache.ccf,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- cache.ccf 15 Jan 2002 17:59:03 -0000      1.2
  +++ cache.ccf 17 Jan 2002 00:19:37 -0000      1.3
  @@ -17,7 +17,7 @@
   ##############################################################
   ################## CACHE REGIONS AVAILABLE ###################
   # Regions preconfirgured for caching
  -jcs.region.testCache=JDC,RFailover
  +jcs.region.testCache=DC,RFailover
   
jcs.region.testCache.cacheattributes=org.apache.stratum.jcs.engine.CompositeCacheAttributes
   jcs.region.testCache.cacheattributes.MaxObjects=1000
   
jcs.region.testCache.cacheattributes.MemoryCacheName=org.apache.stratum.jcs.engine.memory.lru.LRUMemoryCache
  
  
  
  1.7       +3 -1      
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/access/GroupCacheAccess.java
  
  Index: GroupCacheAccess.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/access/GroupCacheAccess.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- GroupCacheAccess.java     16 Jan 2002 17:04:47 -0000      1.6
  +++ GroupCacheAccess.java     17 Jan 2002 00:19:37 -0000      1.7
  @@ -301,6 +301,8 @@
           try
           {
               //cache_control.put((Serializable)groupId, (Serializable)attrNameSet, 
attr );
  +            // TODO: revisit and verify that this works
  +            // not sure it will, need special id putting
               cache_control.put( groupId, ( Serializable ) attrNameSet, attr );
           }
           catch ( Exception ioe )
  @@ -472,7 +474,7 @@
       ///////////////////////////////////////////////
   
       /**
  -     *  Description of the Method
  +     *  Removes an element from the group
        *
        *@param  name   Description of the Parameter
        *@param  group  Description of the Parameter
  
  
  
  1.5       +23 -2     
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/disk/jisp/JISPCache.java
  
  Index: JISPCache.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/disk/jisp/JISPCache.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JISPCache.java    15 Jan 2002 21:33:30 -0000      1.4
  +++ JISPCache.java    17 Jan 2002 00:19:37 -0000      1.5
  @@ -151,7 +151,14 @@
                   setupTABLE();
               }
   
  -            createDB( cattr.getClearOnStart() );
  +            try
  +            {
  +              createDB( cattr.getClearOnStart() );
  +            } catch ( Exception e ) {
  +              log.error(e);
  +              reset();
  +            }
  +
   
               isAlive = true;
   
  @@ -515,7 +522,21 @@
           }
           catch ( Exception e )
           {
  -            log.error( e );
  +            //log.error( e );
  +            log.warn( "Trying to create error files, two programs must be using the 
same JISP directory" );
  +            // Move to error directory, someone else must be using the file.
  +            try
  +            {
  +              this.jispDataFileName   += ".error";
  +              this.jispIndexFileName  += ".error";
  +              setupTABLE();
  +              createDB( true );
  +            }
  +            catch ( Exception e2 )
  +            {
  +                log.error( e2, "Could not create error files!" );
  +
  +            }
           }
       }
       // end reset
  
  
  
  1.4       +7 -17     
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/remote/RemoteCacheListener.java
  
  Index: RemoteCacheListener.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/remote/RemoteCacheListener.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RemoteCacheListener.java  15 Jan 2002 21:33:32 -0000      1.3
  +++ RemoteCacheListener.java  17 Jan 2002 00:19:37 -0000      1.4
  @@ -32,7 +32,8 @@
   
   ///////////////////////////////////////////////////////////////////////
   /**
  - *  Description of the Class
  + *  Registered with RemoteCache server.  The server updates the local caches via
  + *  this class.
    *
    *@author     asmuts
    *@created    January 15, 2002
  @@ -259,22 +260,13 @@
   
               getCacheManager();
               ICompositeCache cache = ( ICompositeCache ) cacheMgr.getCache( 
cb.getCacheName() );
  -            cache.update( cb, false );
  +            cache.update( cb, ICache.EXCLUDE_REMOTE_CACHE );
  +
  +
  +         }
   
  -            /*
  -             * ICompositeCache cache = 
(ICompositeCache)cacheMgr.getCache(irca.getCacheName());
  -             * / copy the element to avoid the remote reference, may need to do a 
deep copy
  -             * ICacheElement ce = new CacheElement( cb.getCacheName(), cb.getKey(), 
cb.getVal() );
  -             * ce.setAttributes( cb.getAttributes().copy() );
  -             * try {
  -             * cache.update( ce, false );
  -             * } catch( Exception e ) {
  -             * / strange marshalling exception encountered
  -             * log.error( e );
  -             * }
  -             */
  -        }
           return;
  +
       }
   
   
  @@ -308,8 +300,6 @@
           }
   
           getCacheManager();
  -        // interface limitation here
  -
           Cache cache = ( Cache ) cacheMgr.getCache( cacheName );
           cache.remove( key, cache.REMOTE_INVOKATION );
       }
  
  
  
  1.4       +3 -15     
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/remote/group/RemoteGroupCacheListener.java
  
  Index: RemoteGroupCacheListener.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/remote/group/RemoteGroupCacheListener.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RemoteGroupCacheListener.java     15 Jan 2002 21:33:33 -0000      1.3
  +++ RemoteGroupCacheListener.java     17 Jan 2002 00:19:37 -0000      1.4
  @@ -131,7 +131,7 @@
                       {
                           p( "cache = " + cache );
                       }
  -                    cache.updateGroupAttrNameSet( ( GroupAttrName ) cb.getKey(), 
cache.REMOTE_INVOKATION, false );
  +                    cache.updateGroupAttrNameSet( ( GroupAttrName ) cb.getKey(), 
ICache.REMOTE_INVOKATION, false );
                       if ( debugcmd )
                       {
                           p( "Adding to attrNameSet " );
  @@ -155,21 +155,9 @@
   
                       getCacheManager();
                       ICompositeCache cache = ( ICompositeCache ) cacheMgr.getCache( 
irca.getCacheName() );
  -                    cache.update( cb, false );
  +                    cache.update( cb, ICache.REMOTE_INVOKATION );
   
  -                    /*
  -                     * ICompositeCache cache = 
(ICompositeCache)cacheMgr.getCache(irca.getCacheName());
  -                     * / copy the element to avoid the remote reference, may need 
to do a deep copy
  -                     * ICacheElement ce = new CacheElement( cb.getCacheName(), 
cb.getKey(), cb.getVal() );
  -                     * ce.setAttributes( cb.getAttributes().copy() );
  -                     * try {
  -                     * cache.update( ce, false );
  -                     * } catch( Exception e ) {
  -                     * / strange marshalling exception encountered
  -                     * log.error( e );
  -                     * }
  -                     */
  -                }
  +                 }
   
               }
               else
  
  
  
  1.4       +31 -13    
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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Cache.java        15 Jan 2002 21:33:35 -0000      1.3
  +++ Cache.java        17 Jan 2002 00:19:38 -0000      1.4
  @@ -5,7 +5,6 @@
   
   import java.util.Iterator;
   import java.util.Map;
  -
   import java.util.Map.Entry;
   
   import org.apache.stratum.jcs.access.exception.CacheException;
  @@ -22,19 +21,18 @@
   import org.apache.stratum.jcs.engine.behavior.ICompositeCacheAttributes;
   
   import org.apache.stratum.jcs.engine.memory.MemoryElementDescriptor;
  -
   import org.apache.stratum.jcs.engine.memory.behavior.IMemoryCache;
  -
   import org.apache.stratum.jcs.engine.memory.lru.LRUMemoryCache;
   
   import org.apache.stratum.jcs.utils.log.Logger;
   import org.apache.stratum.jcs.utils.log.LoggerManager;
   
  -// TODO: make configurable
  +
   
   //////////////////////////////////////////////////////
   /**
  - *  Description of the Class
  + *  This is the primary cache hub.  It control the flow of items through the
  + *  cache.  The auxiliary and memory caches are plugged in here.
    *
    *@author     asmuts
    *@created    January 15, 2002
  @@ -42,10 +40,8 @@
   public class Cache implements ICacheHub, ICache, ICompositeCache, Serializable
   {
   
  -    private final static boolean debugcmd = false;
  -    //true;
  -    // removal
  -    private final static boolean debugR = true;
  +    private final static boolean debugcmd = false;//true;
  +    private final static boolean debugR = false;//true;
   
       /**
        *  Description of the Field
  @@ -236,9 +232,14 @@
       protected synchronized void updateCaches( Serializable key, Serializable val, 
Attributes attr )
           throws IOException
       {
  +        if ( debugcmd )
  +        {
  +            p( "updateCaches(key,val,attr) > ICache.INCLUDE_REMOTE_CACHE= " + 
ICache.INCLUDE_REMOTE_CACHE + " key = " + key  );
  +         }
  +
           CacheElement ce = new CacheElement( cacheName, key, val );
           ce.setAttributes( attr );
  -        update( ce, true );
  +        update( ce, ICache.INCLUDE_REMOTE_CACHE );
       }
   
   
  @@ -255,6 +256,12 @@
       protected synchronized void updateCaches( Serializable key, Serializable val, 
Attributes attr, boolean updateRemoteCache )
           throws IOException
       {
  +
  +        if ( debugcmd )
  +        {
  +            p( "updateCaches(key,val,attr,updateRemoteCache) > updateRemoteCache= " 
+ updateRemoteCache + " key = " + key  );
  +         }
  +
           CacheElement ce = new CacheElement( cacheName, key, val );
           ce.setAttributes( attr );
           update( ce, updateRemoteCache );
  @@ -271,7 +278,11 @@
       public synchronized void update( ICacheElement ce )
           throws IOException
       {
  -        update( ce, true );
  +        if ( debugcmd )
  +        {
  +            p( "update(ce) > ICache.INCLUDE_REMOTE_CACHE= " + 
ICache.INCLUDE_REMOTE_CACHE + " key = " + ce.getKey()  );
  +         }
  +        update( ce, ICache.INCLUDE_REMOTE_CACHE );
       }
   
       ///////////////////////////////////////////////////////////
  @@ -296,12 +307,19 @@
           if ( log.logLevel >= log.DEBUG )
           {
               StringBuffer params = new StringBuffer();
  -            params.append( "update> key=" + ce.getKey() + ", val=" + ce.getVal() + 
", " + ce.getAttributes().toString() );
  +            params.append( "Cache.update(ce,updateRemoteCache) > updateRemoteCache 
= " + updateRemoteCache + " key=" + ce.getKey() + ", val=" + ce.getVal() + ", " + 
ce.getAttributes().toString() );
               log.debug( params.toString() );
           }
           if ( debugcmd )
           {
  -            p( "update key = " + ce.getKey() + ", updateRemoteCache = " + 
updateRemoteCache );
  +            p( "update(ce,updadateRemoteCache) > update updateRemoteCache = " + 
updateRemoteCache + " key = " + ce.getKey() + ", updateRemoteCache = " + 
updateRemoteCache );
  +
  +            if ( updateRemoteCache == ICache.INCLUDE_REMOTE_CACHE )
  +            {
  +              p( "updateRemoteCache is TRUE " + updateRemoteCache  );
  +            } else {
  +              p( "updateRemoteCache is FALSE " + updateRemoteCache );
  +            }
           }
   
           memCache.update( ce );
  
  
  
  1.5       +247 -107  
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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- GroupCache.java   16 Jan 2002 05:32:47 -0000      1.4
  +++ GroupCache.java   17 Jan 2002 00:19:38 -0000      1.5
  @@ -27,7 +27,9 @@
   /**
    *  Group cache is basically a composite cache with the additional capability of
    *  providing automatic and safe attribute name list update for each
  - *  GroupAttrName cache item. TODO: reduce the number of methods or describe
  + *  GroupAttrName cache item.
  + *
  + *  TODO: WORKING ON THIS NOW -- reduce the number of methods or describe
    *  them better. The complexity of this points to group design problems. I need
    *  to fix the locking and the maintenance of the remote list. The list can be
    *  infered fromt he contents of the cache. Iterating through the hashtable
  @@ -40,15 +42,23 @@
   {
       //////////////// debug MUST BE SET TO false in production! ///////////////////
   
  -    private final static boolean debug = false;//true;
  -    //true;
  +    private final static boolean debug =  false;//true;
       private final static boolean debuggan = false;//true;
  +
       private ReadWriteLockManager locker = GroupRWLockManager.getInstance();
   
       private String source_id = "org.apache.stratum.jcs.engine.group.GroupCache";
   
  -    // declare a group_id cache here, so ids and elements don't compete
  -    // for first
  +    /**
  +     * Declare a group_id cache here, so ids and elements don't compete
  +     * for first with the list.
  +     * The systemGroupIdCache will have different remote behavior.
  +     * Local removal of the list will propagate to the remote, but
  +     * the list will not move back and forth.
  +     * The list can be maintained locally but the elements themselves
  +     * need not be.
  +     *
  +     */
       ICompositeCache systemGroupIdCache;
   
   
  @@ -68,10 +78,10 @@
       /**
        *  Constructor for the GroupCache object
        *
  -     *@param  cacheName  Description of the Parameter
  -     *@param  auxCaches  Description of the Parameter
  -     *@param  cattr      Description of the Parameter
  -     *@param  attr       Description of the Parameter
  +     *@param  cacheName  The name of the region
  +     *@param  auxCaches  The auxiliary caches to be used by this region
  +     *@param  cattr      The cache attribute
  +     *@param  attr       The default element attributes
        */
       public GroupCache( String cacheName, ICache[] auxCaches, 
ICompositeCacheAttributes cattr, Attributes attr )
       {
  @@ -88,11 +98,11 @@
       /**
        *  Constructor for the GroupCache object
        *
  -     *@param  cacheName           Description of the Parameter
  -     *@param  auxCaches           Description of the Parameter
  -     *@param  cattr               Description of the Parameter
  -     *@param  attr                Description of the Parameter
  -     *@param  systemGroupIdCache  Description of the Parameter
  +     *@param  cacheName           The name of the region
  +     *@param  auxCaches           The auxiliary caches to be used by this region
  +     *@param  cattr               The cache attribute
  +     *@param  attr                The default element attributes
  +     *@param  systemGroupIdCache  The systemGroupIdCache
        */
       public GroupCache( String cacheName, ICache[] auxCaches, 
ICompositeCacheAttributes cattr, Attributes attr, ICompositeCache systemGroupIdCache )
       {
  @@ -142,18 +152,29 @@
       public Serializable get( Serializable key, boolean container, boolean 
invocation )
       {
   
  +        // GETTING GROUP ELEMENT
           if ( key instanceof GroupAttrName )
           {
               return getGAN( ( GroupAttrName ) key, container );
           }
  +
  +        // GROUP ID
           if ( key instanceof GroupId )
           {
               return getGI( ( GroupId ) key, container );
           }
           if ( debug )
           {
  -            p( this.getCacheName() + " getting " + key + " from super, invocation = 
" + invocation );
  +            p( this.getCacheName() + " getting " + key + " from super " );
  +            if ( invocation == ICache.LOCAL_INVOKATION )
  +            {
  +              p( "invokation is LOCAL" );
  +            } else {
  +              p( "invokation is NOT Local" );
  +            }
           }
  +
  +        // GETTING NON GROUP RELATED ITEM
           return super.get( key, container, invocation );
       }
   
  @@ -183,8 +204,14 @@
       {
           if ( debug )
           {
  -            p( "in getGAN, invocation = " + invocation );
  +            if ( invocation == ICache.LOCAL_INVOKATION )
  +            {
  +              p( "invokation is LOCAL" );
  +            } else {
  +              p( "invokation is NOT Local" );
  +            }
           }
  +
           Object obj = null;
           // not necessary?, stops at getaux
           readLock( key.groupId );
  @@ -214,11 +241,9 @@
           return getGI( gid, container, this.LOCAL_INVOKATION );
       }
   
  -    // stay local if this is a remote operation
   
  -    // removal of a group element will call this to get the list to edit
       /**
  -     *  Gets the gI attribute of the GroupCache object
  +     *  removal of a group element will call this to get the list to edit.
        *
        *@param  gid         Description of the Parameter
        *@param  container   Description of the Parameter
  @@ -230,6 +255,12 @@
           if ( debug )
           {
               p( "in getGi" );
  +            if ( invocation == ICache.LOCAL_INVOKATION )
  +            {
  +              p( "invocation is LOCAL" );
  +            } else {
  +              p( "invocation is NOT Local" );
  +            }
           }
           Object obj = null;
           readLock( gid.key );
  @@ -342,12 +373,17 @@
           }
           if ( debug )
           {
  -            p( "updating " + key + " via super method" );
  +            p( "put(key,val,attr) > updating " + key + " via super method, 
attr.IS_REMOTE = " + attr.IS_REMOTE );
           }
  -        //super.put(key, val);
  +
  +        // NOT GROUP RELATED
           try
           {
  -            updateCaches( key, val, attr );
  +            //updateCaches( key, val, attr );
  +            CacheElement ce = new CacheElement( this.getCacheName(), key, val );
  +            ce.setAttributes( attr );
  +            super.update( ce, ICache.INCLUDE_REMOTE_CACHE ) ;
  +
           }
           catch ( IOException ioe )
           {}
  @@ -383,13 +419,19 @@
           }
           if ( debug )
           {
  -            p( "updating " + key + " via super method" );
  +            p( "put(key,value) -- updating " + key + " via super method" );
           }
  +
           //super.put(key, val);
           Attributes attrE = ( Attributes ) this.attr.copy();
           try
           {
  -            updateCaches( key, val, attrE );
  +            // must make sure you call the sure here
  +            // updateCaches( key, val, attrE, ICache.INCLUDE_REMOTE_CACHE );
  +            // problem super calls back up and the last instruction gets confused
  +            CacheElement ce = new CacheElement( this.getCacheName(), key, val );
  +            ce.setAttributes( attrE );
  +            super.update( ce, ICache.INCLUDE_REMOTE_CACHE ) ;
           }
           catch ( IOException ioe )
           {}
  @@ -407,7 +449,36 @@
       public synchronized void update( ICacheElement ce )
           throws IOException
       {
  -        update( ce, true );
  +        //update( ce, ICache.LATERAL_INVOKATION );
  +        if ( ce.getKey() instanceof GroupAttrName )
  +        {
  +            try
  +            {
  +                if ( debug )
  +                {
  +                    p( "putting via putGAN((GroupAttrName)key, val) method" );
  +                }
  +                putGAN( ( GroupAttrName )ce.getKey(), ce.getVal() );
  +            }
  +            catch ( IOException ioe )
  +            {}
  +            return;
  +        }
  +        if ( debug )
  +        {
  +            p( "update(ce) -- updating " + ce.getKey() + " via super method" );
  +        }
  +
  +        try
  +        {
  +            // must make sure you call the sure here
  +            // updateCaches( key, val, attrE, ICache.INCLUDE_REMOTE_CACHE );
  +            // problem super calls back up and the last instruction gets confused
  +            super.update( ce, ICache.INCLUDE_REMOTE_CACHE ) ;
  +        }
  +        catch ( IOException ioe )
  +        {}
  +        return;
       }
   
       ///////////////////////////////////////////////////////////
  @@ -419,9 +490,11 @@
        *@param  localInvocation  Description of the Parameter
        *@exception  IOException  Description of the Exception
        */
  -    public synchronized void update( ICacheElement ce, boolean localInvocation )
  +     // PROBLEM CACHE HAS THE SAME METHOD AND THE 2nd arg is updaDateRemote
  +    public synchronized void updateGroup( ICacheElement ce, boolean invocation )
           throws IOException
       {
  +
           Object key = ce.getKey();
           if ( key instanceof GroupAttrName )
           {
  @@ -430,8 +503,15 @@
                   if ( debug )
                   {
                       p( "putting via ga method" );
  +                    if ( invocation == ICache.LOCAL_INVOKATION )
  +                    {
  +                      p( "invocation is LOCAL" );
  +                    } else {
  +                      p( "invocation is NOT Local" );
  +                    }
                   }
  -                putGAN( ( GroupAttrName ) key, ce.getVal() );
  +                Attributes attrE = ( Attributes ) this.attr.copy();
  +                putGAN( ( GroupAttrName ) key, ce.getVal(), attrE, invocation );
               }
               catch ( IOException ioe )
               {}
  @@ -439,13 +519,31 @@
           }
           if ( debug )
           {
  -            p( "updating " + key + " via super method" );
  +            p( "update(ce,invocation) > updating " + key + " via super method" );
           }
  -        //super.put(key, val);
  +
  +        // TODO: what about id? not possible here?
  +        // GROUP ID
  +        //if ( key instanceof GroupId )
  +        //{
  +        //
  +        //}
  +
  +
  +
           Attributes attrE = ( Attributes ) this.attr.copy();
           try
           {
  -            super.update( ce, localInvocation );
  +            // update should go remote if locally invoked
  +            boolean updateRemote = false;
  +            // DECIDE WHAT TO DO WITH THE LIST
  +            if ( invocation == ICache.LOCAL_INVOKATION )
  +            {
  +              updateRemote = ICache.INCLUDE_REMOTE_CACHE;
  +            } else {
  +              updateRemote = ICache.EXCLUDE_REMOTE_CACHE;
  +            }
  +            super.update( ce, updateRemote );
           }
           catch ( IOException ioe )
           {}
  @@ -499,7 +597,7 @@
           {
               p( "in putGAN( gan,val,attr) " );
           }
  -        putGAN( key, val, attrE, true );
  +        putGAN( key, val, attrE, ICache.LOCAL_INVOKATION );
       }
   
   
  @@ -512,13 +610,24 @@
        *@param  updateRemote     Description of the Parameter
        *@exception  IOException  Description of the Exception
        */
  -    public void putGAN( GroupAttrName key, Serializable val, Attributes attrE, 
boolean updateRemote )
  +    //public void putGAN( GroupAttrName key, Serializable val, Attributes attrE, 
boolean updateRemote )
  +    public void putGAN( GroupAttrName key, Serializable val, Attributes attrE, 
boolean invocation )
           throws IOException
       {
  +
           if ( debug )
           {
  -            p( "in putGAN( gan,val,attr,boolean updateRemote) " );
  +            //p( "in putGAN( gan,val,attr,boolean updateRemote) " );
  +            p( "in putGAN( gan,val,attr,boolean invocation) " );
  +            if ( invocation == ICache.LOCAL_INVOKATION )
  +            {
  +              p( "invocation is LOCAL" );
  +            } else {
  +              p( "invocation is NOT Local" );
  +            }
           }
  +
  +
           writeLock( key.groupId );
           try
           {
  @@ -529,43 +638,42 @@
               ce.setAttributes( attrE );
               if ( debuggan )
               {
  -                p( "updating group attribute via super, updateRemote = " + 
updateRemote );
  +                p( "updating group attribute via super" );
  +            }
  +            // SEND THE ELEMENT IF THE INVOCATION WAS LOCAL
  +            // decide what to do with this item
  +            boolean updateRemote = false;
  +            if ( invocation == ICache.LOCAL_INVOKATION )
  +            {
  +              updateRemote = ICache.INCLUDE_REMOTE_CACHE;
  +            } else {
  +              updateRemote = ICache.EXCLUDE_REMOTE_CACHE;
               }
               super.update( ce, updateRemote );
  -            //updateCaches(key, val, attrE, updateRemote);
  -
  -            // update the attribute name set.
  -            // Note: use super.get to avoid read lock.
  -            //GroupId groupId = key.groupId;//new GroupId(key.groupId);
   
  +            // UPDATE THE ATTRIBUTENAME LIST, get it first
               GroupId groupId = new GroupId( this.getCacheName(), key.groupId );
               HashSet attrNameSet = null;
  -
  -            // avoid lock of getGI, call super
  -            //attrNameSet = (HashSet)super.get(groupId.key, false);
               attrNameSet = ( HashSet ) systemGroupIdCache.get( groupId.key, false );
   
               if ( attrNameSet == null )
               {
  -                //p( "couldn't find group attrnameSet" );
  -                attrNameSet = new HashSet();
  +                 attrNameSet = new HashSet();
               }
               attrNameSet.add( key.attrName );
  +
               if ( debuggan )
               {
                   p( "attrNameSet.size()  = " + attrNameSet.size() );
               }
  -            // problem, this sets the group attr to the item
  -            // maintain the core list ont he remote.
  -            //updateCaches(groupId.key, attrNameSet, attrE, EXCLUDE_REMOTE_CACHE );
   
               CacheElement ceID = new CacheElement( this.getCacheName(), groupId.key, 
attrNameSet );
               ceID.setAttributes( attrE );
  -            //super.update( ceID, EXCLUDE_REMOTE_CACHE );
  -            //updateCaches(groupId.key, attrNameSet, attrE, EXCLUDE_REMOTE_CACHE );
   
  +            // DO NOT SEND THE UPDATE LIST REMOTELY
  +            // THE ELEMENT WILL BE SENT AND THE LIST MAINTAINED REMOTELY
               systemGroupIdCache.update( ceID, EXCLUDE_REMOTE_CACHE );
  -            //systemGroupIdCache.update( ceID, !EXCLUDE_REMOTE_CACHE  );
  +            // could use the updateGroupAttr method?
   
           }
           finally
  @@ -650,7 +758,8 @@
           // if expired super will call remove and we can't have a lock
           // need a third method
           return remove( key, ICache.LOCAL_INVOKATION );
  -    }
  +
  +    }  // rmove
   
   
       /**
  @@ -663,28 +772,53 @@
        */
       public boolean remove( Serializable key, boolean invocation )
       {
  +
  +        // THIS IS A GROUP ELEMENT
           if ( key instanceof GroupAttrName )
           {
               if ( debug )
               {
  -                p( "calling removeGAN, invocation = " + invocation );
  +                p( "calling removeGAN" );
  +                if ( invocation == ICache.LOCAL_INVOKATION )
  +                {
  +                  p( "invokation is LOCAL" );
  +                } else {
  +                  p( "invokation is NOT Local" );
  +                }
               }
               return removeGAN( ( GroupAttrName ) key, invocation );
           }
  +
  +        // THIS IS A GROUP ID
           if ( key instanceof GroupId )
           {
               if ( debug )
               {
                   p( "call removeGI" );
  +                if ( invocation == ICache.LOCAL_INVOKATION )
  +                {
  +                  p( "invokation is LOCAL" );
  +                } else {
  +                  p( "invokation is NOT Local" );
  +                }
               }
               return removeGI( ( GroupId ) key, invocation );
           }
  +
  +        // NOT GROUP RELATED
           if ( debug )
           {
               p( "call super.remove, " + invocation + " for " + key );
  +            if ( invocation == ICache.LOCAL_INVOKATION )
  +            {
  +              p( "invokation is LOCAL" );
  +            } else {
  +              p( "invokation is NOT Local" );
  +            }
           }
           return super.remove( key, invocation );
  -    }
  +
  +    } // end remove
   
   
       /**
  @@ -702,21 +836,32 @@
        *@param  invokation  Description of the Parameter
        *@return             Description of the Return Value
        */
  -    public boolean removeGAN( GroupAttrName key, boolean invokation )
  +    public boolean removeGAN( GroupAttrName key, boolean invocation )
       {
  +
           boolean ret;
           if ( debug )
           {
  -            p( "in removeGAN, invokation = " + invokation );
  +            p( "in removeGAN" );
  +            if ( invocation == ICache.LOCAL_INVOKATION )
  +            {
  +              p( "invocation is LOCAL" );
  +            } else {
  +              p( "invocation is NOT Local" );
  +            }
  +
           }
  +
  +        // TODO: fix locking, got too nested and confusing
           //writeLock(key.groupId);
           try
           {
  -            // remove the attribute.
  -            //ret = remove(key, LOCAL_INVOKATION);
   
  -            ret = super.remove( key, invokation );
  -            updateGroupAttrNameSet( key, invokation, true );
  +            // REMOVE THE ELEMENT
  +            ret = super.remove( key, invocation );
  +
  +            // UPDATE THE LIST, remove item -- 3rd arg
  +            updateGroupAttrNameSet( key, invocation, true );
   
           }
           finally
  @@ -735,36 +880,36 @@
        *  configuration. This saves on local cache space and keeps the list up to
        *  date.
        *
  -     *@param  key         Description of the Parameter
  -     *@param  invokation  Description of the Parameter
  -     *@param  remove      Description of the Parameter
  +     *@param  key         The key for the group element
  +     *@param  invocation  The source of the call
  +     *@param  remove      Is this a remove request
        */
  -    public void updateGroupAttrNameSet( GroupAttrName key, boolean invokation, 
boolean remove )
  +    public void updateGroupAttrNameSet( GroupAttrName key, boolean invocation, 
boolean remove )
       {
  +
           // update the attribute name set.
           // Note: necessary to use super.get to avoid read lock within the current 
write lock.
           GroupId groupId = new GroupId( this.getCacheName(), key.groupId );
           HashSet attrNameSet = null;
           CacheElement ce = null;
   
  -        //ce = (CacheElement)get(groupId.key, true );
  -        //attrNameSet = (HashSet)systemGroupIdCache.get(groupId.key);
           try
           {
  -            //ce = (CacheElement)systemGroupIdCache.get(groupId.key, true, 
invokation );
  -            //p( "systemGroupIdCache = " + systemGroupIdCache );
  -            //p( "groupId.key " + groupId.key );
  -            //p( "this.cacheAttr.getCacheName() = " + this.cacheAttr.getCacheName() 
);
  -            ce = ( CacheElement ) systemGroupIdCache.get( groupId.key, true, 
invokation );
  +             ce = ( CacheElement ) systemGroupIdCache.get( groupId.key, true, 
invocation );
           }
           catch ( IOException ioe )
           {}
   
  +        // IF THE NAME SET IS FOUND
  +        // TODO: move -- INITIAL INSERTION IS CURRENTLY DONE BY THE PUT
           if ( ce != null )
           {
               attrNameSet = ( HashSet ) ce.val;
  +
  +            // HANDLE NON REMOVAL SCENARIOS
               if ( attrNameSet != null || !remove )
               {
  +                // THE GROUP HAS BEEN CREATED BUT NOTHING IS IN IT
                   if ( attrNameSet == null )
                   {
                       attrNameSet = new HashSet();
  @@ -784,17 +929,6 @@
                       // update the changed name set.
                       try
                       {
  -                        //nonLocal = true
  -                        // last arg her is whether to update the remote
  -                        // shouldn't update remote if not local
  -                        // LOCAL_INVOKATION = false
  -
  -                        // remove gi list for now if it the element is remotely 
changed
  -                        // otherwsie it will lack elements, since they are not moved
  -                        // with the items.  Otherwise add the keys on the
  -                        // remote listener handlePut method.  ya that's better.
  -                        //boolean updateRemote = !invokation;
  -                        //updateCaches(groupId.key, attrNameSet, ce.attr, 
updateRemote );
   
                           CacheElement ceID = new CacheElement( this.getCacheName(), 
groupId.key, attrNameSet );
                           ceID.setAttributes( ce.attr );
  @@ -802,12 +936,16 @@
                           {
                               p( "calling systemGroupIdCache.update( ceID, 
EXCLUDE_REMOTE_CACHE )" );
                           }
  +                        // ALWAYS EXCLUDE THE REMOTE CACHE
  +                        // TODO: should this be configurable? no
                           systemGroupIdCache.update( ceID, EXCLUDE_REMOTE_CACHE );
   
                       }
                       catch ( IOException ioe )
                       {}
                   }
  +
  +                // HANDLE REMOVAL SCENARIOS
                   else if ( remove )
                   {
                       // no more attribute, so remove the name set all together, 
skipLock = true.
  @@ -819,9 +957,16 @@
                           {
                               p( "calling systemGroupIdCache.remove( groupId.key, 
EXCLUDE_REMOTE_CACHE )" );
                           }
  -                        // removal should go remote
  -                        //systemGroupIdCache.remove( groupId.key, 
EXCLUDE_REMOTE_CACHE );
  -                        systemGroupIdCache.remove( groupId.key, 
this.INCLUDE_REMOTE_CACHE );
  +                        // unlike insertion, removal should go remote if locally 
invoked
  +                        boolean updateRemote = false;
  +                        // DECIDE WHAT TO DO WITH THE LIST
  +                        if ( invocation == ICache.LOCAL_INVOKATION )
  +                        {
  +                          updateRemote = ICache.INCLUDE_REMOTE_CACHE;
  +                        } else {
  +                          updateRemote = ICache.EXCLUDE_REMOTE_CACHE;
  +                        }
  +                        systemGroupIdCache.remove( groupId.key, updateRemote );
                       }
                       catch ( IOException ioe )
                       {}
  @@ -844,7 +989,7 @@
           {
               p( "removeGI" );
           }
  -        removeGI( groupId, false );
  +        removeGI( groupId, ICache.LOCAL_INVOKATION );
       }
   
   
  @@ -855,34 +1000,29 @@
        *  groupaccess.
        *
        *@param  groupId   Description of the Parameter
  -     *@param  nonLocal  Description of the Parameter
  +     *@param  invocation  Description of the Parameter
        *@return           Description of the Return Value
        */
  -    protected boolean removeGI( GroupId groupId, boolean nonLocal )
  +    protected boolean removeGI( GroupId groupId, boolean invocation )
       {
  -        return removeGI( groupId, nonLocal, false );
  +        return removeGI( groupId, invocation, false );
       }
   
   
       /**
  -     *  Description of the Method
  +     *  Removes the group id.  Low level method.  We need a higher level
  +     *  for invalidating the group.
        *
        *@param  groupId   Description of the Parameter
        *@param  nonLocal  Description of the Parameter
        *@param  skipLock  Description of the Parameter
        *@return           Description of the Return Value
        */
  -    protected boolean removeGI( GroupId groupId, boolean nonLocal, boolean skipLock 
)
  +    protected boolean removeGI( GroupId groupId, boolean invocation, boolean 
skipLock )
       {
   
           boolean ok = false;
   
  -        // loop back, shouldn't of go here
  -        //if (!(key instanceof GroupId)) {
  -        //  ok = super.remove( (GroupId)groupId, nonLocal );
  -        //  return ok;
  -        //}
  -
           // problem with removing expired while getting!
           skipLock = false;
   
  @@ -897,17 +1037,17 @@
           try
           {
   
  -            // remove the items
  -            // groupid cache should be remote, but the lsit should not
  -            // be propagated
  -
  -            //ok = super.remove(groupId.key, nonLocal);
  -            //ok = systemGroupIdCache.remove( groupId.key, nonLocal );
  -            // TODO: make sure that an update tot he list does not propagate
  -            // the list to the remote cache.  Orders to delete the item should
  -            // propagate.
  -            // A removal of the list should propagate.
  -            ok = systemGroupIdCache.remove( groupId.key, this.INCLUDE_REMOTE_CACHE 
);
  +            // unlike insertion, removal should go remote if locally invoked
  +            boolean updateRemote = false;
  +            // DECIDE WHAT TO DO WITH THE LIST
  +            if ( invocation == ICache.LOCAL_INVOKATION )
  +            {
  +              updateRemote = ICache.INCLUDE_REMOTE_CACHE;
  +            } else {
  +              updateRemote = ICache.EXCLUDE_REMOTE_CACHE;
  +            }
  +            ok = systemGroupIdCache.remove( groupId.key, updateRemote );
  +
           }
           catch ( IOException ioeg )
           {
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to