jmcnally    2002/06/05 22:27:47

  Modified:    src/java/org/apache/jcs/engine/control/group
                        GroupAttrName.java GroupCache.java GroupId.java
  Log:
  keeping the two parts of the GroupId key separate.
  
  using the GroupId in GroupAttrName instead of only part of it.
  
  made appropriate changes to GroupCache to account for the above changes.
  
  Revision  Changes    Path
  1.2       +14 -7     
jakarta-turbine-jcs/src/java/org/apache/jcs/engine/control/group/GroupAttrName.java
  
  Index: GroupAttrName.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/control/group/GroupAttrName.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GroupAttrName.java        7 Apr 2002 16:55:27 -0000       1.1
  +++ GroupAttrName.java        6 Jun 2002 05:27:46 -0000       1.2
  @@ -6,15 +6,16 @@
    * Description of the Class
    *
    * @author asmuts
  + * @author <a href="mailto:[EMAIL PROTECTED]";>John McNally</a>
    * @created January 15, 2002
    */
   public class GroupAttrName implements Serializable
   {
       //final GroupId groupId;
       /** Description of the Field */
  -    public final String groupId;
  -    final Object attrName;
  -
  +    public final GroupId groupId;
  +    public final Object attrName;
  +    private String toString;
   
       /**
        * Constructor for the GroupAttrName object
  @@ -22,15 +23,15 @@
        * @param groupId
        * @param attrName
        */
  -    public GroupAttrName( String groupId, Object attrName )
  +    public GroupAttrName( GroupId groupId, Object attrName )
       {
  -        //this.groupId = new GroupId(groupId);
           this.groupId = groupId;
           this.attrName = attrName;
   
           if ( groupId == null || attrName == null )
           {
  -            throw new IllegalArgumentException( "groupId " + groupId + " and 
attrName " + attrName + ", must not be null." );
  +            throw new IllegalArgumentException( "groupId " + groupId + 
  +                " and attrName " + attrName + ", must not be null." );
           }
       }
   
  @@ -57,7 +58,13 @@
       /** Description of the Method */
       public String toString()
       {
  -        return "[groupId=" + groupId + ", attrName=" + attrName + "]";
  +        if (toString == null) 
  +        {
  +            toString = "[GAN: groupId=" + groupId + 
  +                ", attrName=" + attrName + "]";
  +        }
  +        
  +        return toString;
       }
   
   }
  
  
  
  1.10      +23 -23    
jakarta-turbine-jcs/src/java/org/apache/jcs/engine/control/group/GroupCache.java
  
  Index: GroupCache.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/control/group/GroupCache.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- GroupCache.java   23 May 2002 15:55:28 -0000      1.9
  +++ GroupCache.java   6 Jun 2002 05:27:46 -0000       1.10
  @@ -231,7 +231,7 @@
   
           Object obj = null;
           // not necessary?, stops at getaux
  -        readLock( key.groupId );
  +        readLock( key.groupId.toString() );
           try
           {
               obj = super.get( key, invocation );
  @@ -239,7 +239,7 @@
           }
           finally
           {
  -            locker.done( key.groupId );
  +            locker.done( key.groupId.toString() );
           }
           return ( ICacheElement ) obj;
       }
  @@ -279,18 +279,18 @@
               }
           }
           Object obj = null;
  -        readLock( gid.key );
  +        readLock( gid.toString() );
           try
           {
               if ( invocation )
               {
                   // Invocation is NOT local
  -                obj = systemGroupIdCache.localGet( gid.key );
  +                obj = systemGroupIdCache.localGet( gid.toString() );
               }
               else
               {
                   // Invocation is local
  -                obj = systemGroupIdCache.get( gid.key );
  +                obj = systemGroupIdCache.get( gid.toString() );
               }
   
               if ( log.isDebugEnabled() )
  @@ -300,7 +300,7 @@
           }
           finally
           {
  -            locker.done( gid.key );
  +            locker.done( gid.toString() );
           }
   
           return ( ICacheElement ) obj;
  @@ -581,7 +581,7 @@
               log.debug( "in putGAN( gan,val,attr,boolean invocation) " );
           }
   
  -        writeLock( key.groupId );
  +        writeLock( key.toString() );
           try
           {
   
  @@ -598,9 +598,9 @@
               super.update( ce, localOnly );
   
               // UPDATE THE ATTRIBUTENAME LIST, get it first
  -            GroupId groupId = new GroupId( this.getCacheName(), key.groupId );
  +            GroupId groupId = key.groupId;
               HashSet attrNameSet = null;
  -            attrNameSet = ( HashSet ) systemGroupIdCache.get( groupId.key );
  +            attrNameSet = (HashSet)systemGroupIdCache.get(groupId.toString());
   
               if ( attrNameSet == null )
               {
  @@ -613,7 +613,7 @@
                   log.debug( "putGAN( gan,val,attr,boolean invocation) > 
attrNameSet.size()  = " + attrNameSet.size() );
               }
   
  -            CacheElement ceID = new CacheElement( this.getCacheName(), groupId.key, 
attrNameSet );
  +            CacheElement ceID = new CacheElement( this.getCacheName(), groupId, 
attrNameSet );
               ceID.setElementAttributes( attrE );
   
               // DO NOT SEND THE UPDATE LIST REMOTELY
  @@ -623,7 +623,7 @@
           }
           finally
           {
  -            locker.done( key.groupId );
  +            locker.done( key.toString() );
           }
       }
   
  @@ -642,7 +642,7 @@
           GroupId groupId = new GroupId( this.getCacheName(), group );
           HashSet attrNameSet = null;
   
  -        attrNameSet = ( HashSet ) systemGroupIdCache.get( groupId.key );
  +        attrNameSet = ( HashSet ) systemGroupIdCache.get( groupId.toString() );
   
           if ( attrNameSet == null )
           {
  @@ -654,7 +654,7 @@
           }
           try
           {
  -            CacheElement ceID = new CacheElement( this.getCacheName(), groupId.key, 
attrNameSet );
  +            CacheElement ceID = new CacheElement( this.getCacheName(), groupId, 
attrNameSet );
               ceID.setElementAttributes( attrE );
               //updateCaches(groupId.key, attrNameSet, attrE );
               //super.update( ceID, EXCLUDE_REMOTE_CACHE );
  @@ -807,19 +807,19 @@
   
           // 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 );
  +        GroupId groupId = key.groupId;
           HashSet attrNameSet = null;
           CacheElement ce = null;
   
           if ( invocation )
           {
               // Invocation is NOT local
  -            ce = ( CacheElement ) systemGroupIdCache.localGet( groupId.key );
  +            ce = ( CacheElement ) systemGroupIdCache.localGet( groupId.toString() );
           }
           else
           {
               // Invocation is local
  -            ce = ( CacheElement ) systemGroupIdCache.get( groupId.key );
  +            ce = ( CacheElement ) systemGroupIdCache.get( groupId.toString() );
           }
   
           // IF THE NAME SET IS FOUND
  @@ -854,7 +854,7 @@
   
                           CacheElement ceID
                               = new CacheElement( this.getCacheName(),
  -                                                groupId.key,
  +                                                groupId,
                                                   attrNameSet );
   
                           ceID.setElementAttributes( ce.attr );
  @@ -888,11 +888,11 @@
                       // unlike insertion, removal should go remote if locally invoked
                       if ( invocation )
                       {
  -                        systemGroupIdCache.localRemove( groupId.key );
  +                        systemGroupIdCache.localRemove( groupId.toString() );
                       }
                       else
                       {
  -                        systemGroupIdCache.remove( groupId.key );
  +                        systemGroupIdCache.remove( groupId.toString() );
                       }
                   }
               }
  @@ -936,24 +936,24 @@
   
           if ( !skipLock )
           {
  -            writeLock( groupId.key );
  +            writeLock( groupId.toString() );
           }
           try
           {
               if ( invocation )
               {
  -                ok = systemGroupIdCache.localRemove( groupId.key );
  +                ok = systemGroupIdCache.localRemove( groupId.toString() );
               }
               else
               {
  -                ok = systemGroupIdCache.remove( groupId.key );
  +                ok = systemGroupIdCache.remove( groupId.toString() );
               }
           }
           finally
           {
               if ( !skipLock )
               {
  -                locker.done( groupId.key );
  +                locker.done( groupId.toString() );
               }
           }
           return ok;
  
  
  
  1.2       +24 -15    
jakarta-turbine-jcs/src/java/org/apache/jcs/engine/control/group/GroupId.java
  
  Index: GroupId.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/control/group/GroupId.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GroupId.java      7 Apr 2002 16:55:27 -0000       1.1
  +++ GroupId.java      6 Jun 2002 05:27:46 -0000       1.2
  @@ -7,54 +7,63 @@
    * cache items in the same cache.
    *
    * @author asmuts
  + * @author <a href="mailto:[EMAIL PROTECTED]";>John McNally</a>
    * @created January 15, 2002
    */
   public class GroupId implements Serializable
   {
  -
       /** Description of the Field */
  -    public final String key;
  -
  +    public final String groupName;
  +    public final String cacheName;
  +    private String toString;
   
       /**
        * Constructor for the GroupId object
        *
        * @param cacheName
  -     * @param key
  +     * @param groupName
        */
  -    public GroupId( String cacheName, String key )
  +    public GroupId( String cacheName, String groupName )
       {
  -        this.key = cacheName + key;
  +        this.cacheName = cacheName;
  +        this.groupName = groupName;
   
  -        if ( key == null )
  +        if ( cacheName == null )
  +        {
  +            throw new IllegalArgumentException("cacheName must not be null.");
  +        }
  +        if ( groupName == null )
           {
  -            throw new IllegalArgumentException( "key must not be null." );
  +            throw new IllegalArgumentException("groupName must not be null.");
           }
       }
   
  -
       /** Description of the Method */
       public boolean equals( Object obj )
       {
  -        if ( obj == null || !( obj instanceof GroupId ) )
  +        if ( obj == null || !(obj instanceof GroupId) )
           {
               return false;
           }
  -        GroupId to = ( GroupId ) obj;
  -        return key.equals( to.key );
  +        GroupId g = (GroupId)obj;
  +        return cacheName.equals(g.cacheName) && groupName.equals(g.groupName);
       }
   
   
       /** Description of the Method */
       public int hashCode()
       {
  -        return key.hashCode();
  +        return cacheName.hashCode() + groupName.hashCode();
       }
   
  -
       /** Description of the Method */
       public String toString()
       {
  -        return "[grouId=" + key + "]";
  +        if (toString == null) 
  +        {
  +            toString = "[groupId=" + cacheName + ", " + groupName + ']';
  +        }
  +        
  +        return toString;
       }
   }
  
  
  

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

Reply via email to