jmcnally 2002/07/26 23:39:51
Modified: src/java/org/apache/jcs JCS.java
src/java/org/apache/jcs/access GroupCacheAccess.java
src/java/org/apache/jcs/access/behavior
IGroupCacheAccess.java
src/java/org/apache/jcs/access/monitor MonitorAccess.java
src/java/org/apache/jcs/auxiliary AuxiliaryCache.java
src/java/org/apache/jcs/auxiliary/disk
AbstractDiskCache.java
src/java/org/apache/jcs/auxiliary/disk/hsql HSQLCache.java
src/java/org/apache/jcs/auxiliary/disk/indexed
IndexedDiskCache.java
src/java/org/apache/jcs/auxiliary/disk/jisp JISPCache.java
src/java/org/apache/jcs/auxiliary/lateral LateralCache.java
LateralCacheNoWait.java
LateralCacheNoWaitFacade.java
ZombieLateralCacheService.java
src/java/org/apache/jcs/auxiliary/lateral/behavior
ILateralCacheService.java
src/java/org/apache/jcs/auxiliary/lateral/socket/tcp
LateralTCPService.java
src/java/org/apache/jcs/auxiliary/remote RemoteCache.java
RemoteCacheManager.java RemoteCacheNoWait.java
RemoteCacheNoWaitFacade.java
ZombieRemoteCacheService.java
src/java/org/apache/jcs/auxiliary/remote/behavior
IRemoteCacheService.java
src/java/org/apache/jcs/auxiliary/remote/server
RemoteCacheServer.java
src/java/org/apache/jcs/engine/control CompositeCache.java
src/java/org/apache/jcs/engine/memory
AbstractMemoryCache.java MemoryCache.java
src/java/org/apache/jcs/engine/memory/mru
MRUMemoryCache.java
src/java/org/apache/jcs/utils/servlet/session
DistSession.java
Removed: src/java/org/apache/jcs/engine/control/group GroupCache.java
GroupCacheHub.java
Log:
removed the GroupCache and GroupCacheHub and implemented the
ability to get all the keys in a group or invalidate a group within each
type of cache (a few do not support groups). The invalidation follows
the model used by the special character in a String type of keys.
Revision Changes Path
1.6 +5 -6 jakarta-turbine-jcs/src/java/org/apache/jcs/JCS.java
Index: JCS.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/JCS.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JCS.java 23 May 2002 15:22:22 -0000 1.5
+++ JCS.java 27 Jul 2002 06:39:49 -0000 1.6
@@ -59,7 +59,6 @@
import org.apache.jcs.engine.behavior.ICompositeCacheAttributes;
import org.apache.jcs.engine.control.CompositeCache;
import org.apache.jcs.engine.control.CompositeCacheManager;
-import org.apache.jcs.engine.control.group.GroupCacheHub;
/**
* Simple class for using JCS. To use JCS in your application, you can use the
@@ -122,9 +121,9 @@
}
/**
- * Gets an instance of GroupCacheHub and stores it in the cacheMgr class
+ * Gets an instance of CompositeCacheManager and stores it in the cacheMgr class
* field, if it is not already set. Unlike the implementation in
- * CacheAccess, the cache manager is a GroupCacheHub. NOTE: This can
+ * CacheAccess, the cache manager is a CompositeCacheManager. NOTE: This can
* will be moved up into GroupCacheAccess.
*/
protected static synchronized void ensureCacheManager()
@@ -133,11 +132,11 @@
{
if ( configFilename == null )
{
- cacheMgr = GroupCacheHub.getInstance();
+ cacheMgr = CompositeCacheManager.getInstance();
}
else
{
- cacheMgr = GroupCacheHub.getUnconfiguredInstance();
+ cacheMgr = CompositeCacheManager.getUnconfiguredInstance();
cacheMgr.configure( configFilename );
}
1.8 +11 -146
jakarta-turbine-jcs/src/java/org/apache/jcs/access/GroupCacheAccess.java
Index: GroupCacheAccess.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/access/GroupCacheAccess.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- GroupCacheAccess.java 6 Jun 2002 05:31:11 -0000 1.7
+++ GroupCacheAccess.java 27 Jul 2002 06:39:50 -0000 1.8
@@ -71,7 +71,6 @@
import org.apache.jcs.engine.control.CompositeCache;
import org.apache.jcs.engine.control.CompositeCacheManager;
import org.apache.jcs.engine.control.group.GroupAttrName;
-import org.apache.jcs.engine.control.group.GroupCacheHub;
import org.apache.jcs.engine.control.group.GroupId;
/**
@@ -86,9 +85,6 @@
private final static Log log =
LogFactory.getLog( GroupCacheAccess.class );
- private static boolean SET_ATTR_INVOCATION = true;
- private static boolean REMOVE_ATTR_INVOCATION = false;
-
private static CompositeCacheManager cacheMgr;
/**
@@ -115,7 +111,7 @@
{
if ( cacheMgr == null )
{
- cacheMgr = GroupCacheHub.getInstance();
+ cacheMgr = CompositeCacheManager.getInstance();
}
}
}
@@ -136,7 +132,7 @@
{
if ( cacheMgr == null )
{
- cacheMgr = GroupCacheHub.getInstance();
+ cacheMgr = CompositeCacheManager.getInstance();
}
}
}
@@ -167,99 +163,6 @@
}
/**
- * DefineGroup is used to create a new group object. Attributes may be set
- * on the group. If no attributes are specified, the attributes of the
- * region or group the new group is associated with are used. If group is
- * specified the new group will be associated with the group specified.
- *
- * @param name Name of the gorup.
- */
- public void defineGroup( String name )
- throws CacheException
- {
- defineGroup(name, null);
- }
-
- /**
- * Description of the Method
- *
- * @param name Name of the group
- * @param attr Default attributes for the group.
- */
- public void defineGroup( String name, IElementAttributes attr )
- throws CacheException
- {
- // update the attribute name set.
- GroupId groupId = new GroupId( cacheControl.getCacheName(), name );
- if ( get(groupId) != null )
- {
- throw new CacheException( "group " + name + " already exists " );
- }
-
- // TODO: revisit and verify that this works
- // not sure it will, need special id putting
- if (attr == null)
- {
- put( groupId, new HashSet() );
- }
- else
- {
- put( groupId, new HashSet(), attr );
- }
- }
-
- /**
- * Gets the groupAttributes attribute of the GroupCacheAccess object.
- * Slighly confusing since the other method conside an "attribute" to be an
- * element of the cache and not the parameters governing an element.
- *
- * @return The Element Attributes for the group
- */
- public IElementAttributes getGroupAttributes( String name )
- throws CacheException
- {
- IElementAttributes attr = null;
- try
- {
- attr = cacheControl.getElementAttributes( ( Serializable ) name );
- }
- catch ( IOException ioe )
- {
- throw new CacheException(
- "Failure getting element attributes due to ", ioe );
- }
- return attr;
- }
-
- /**
- * Gets the attributeNames attribute of the GroupCacheAccess object
- *
- * @return The attributeNames value
- */
- public Enumeration getAttributeNames( String group_name )
- {
- //Set s = getAttributeNameSet( name );
- //p( s.toString() );
- //return Collections.enumeration(s);
- return Collections.enumeration( getAttributeNameSet( group_name ) );
- }
-
- /**
- * Gets the attributeNameSet attribute of the GroupCacheAccess object
- *
- * @return The attributeNameSet value
- */
- public Set getAttributeNameSet( String groupName )
- {
- Object obj = get(new GroupId(cacheControl.getCacheName(), groupName));
- if ( obj == null || !( obj instanceof Set ) )
- {
- return new HashSet();
- }
- return (Set) obj;
- }
-
- /**
* Allows the user to put an object into a group within a particular cache
* region. This method sets the object's attributes to the default for the
* region.
@@ -288,16 +191,8 @@
IElementAttributes attr )
throws CacheException
{
- Set group = (Set)
- get(new GroupId(cacheControl.getCacheName(), groupName));
- if (group == null)
- {
- throw new CacheException(
- "Group must be defined prior to being used.");
- }
-
// unbind object first if any.
- boolean isPreviousObj = remove( name, groupName, false);
+ remove( name, groupName);
if (attr == null)
{
@@ -307,57 +202,27 @@
{
put( getGroupAttrName(groupName, name), value, attr );
}
-
- if (!isPreviousObj)
- {
- group.add(name);
- }
}
/** Description of the Method */
public void remove( Object name, String group )
{
- remove( name, group, true );
+ GroupAttrName key = getGroupAttrName( group, name );
+ cacheControl.remove(key);
}
- /** Description of the Method */
- private boolean remove( Object name, String groupName,
- boolean removeFromGroup )
+ /**
+ * Gets the set of keys of objects currently in the group
+ */
+ public Set getGroupKeys(String group)
{
- GroupAttrName key = getGroupAttrName( groupName, name );
- // Needs to retrieve the attribute so as to do object unbinding,
- // if necessary.
- boolean isPreviousObj = cacheControl.get(key) != null;
- if (isPreviousObj)
- {
- cacheControl.remove(key);
- }
- if (removeFromGroup)
- {
- Set group = getAttributeNameSet(groupName);
- group.remove(name);
- }
- return isPreviousObj;
+ return cacheControl.getGroupKeys(group);
}
+
/** Invalidates a group */
public void invalidateGroup( String group )
{
- // Removes all the attributes and attribute names from the Cache.
- // In doing so, need to unbind any object associated with the session.
- // need a static list not dependent on the current state of the source
- // remove each item, may want to try using partial delete here
- // move to gorupcache?
- Set set = getAttributeNameSet( group );
- Object[] ar = set.toArray();
- int arS = ar.length;
- for ( int i = 0; i < arS; i++ )
- {
- remove( ar[i], group, false );
- }
-
- // get into concurrent modification problems here.
- // could make the removal of the ID invalidate the list?
cacheControl.remove(new GroupId( cacheControl.getCacheName(), group ));
}
}
1.3 +6 -27
jakarta-turbine-jcs/src/java/org/apache/jcs/access/behavior/IGroupCacheAccess.java
Index: IGroupCacheAccess.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/access/behavior/IGroupCacheAccess.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- IGroupCacheAccess.java 6 Jun 2002 05:31:11 -0000 1.2
+++ IGroupCacheAccess.java 27 Jul 2002 06:39:50 -0000 1.3
@@ -53,7 +53,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-import java.util.Enumeration;
+import java.util.Set;
import org.apache.jcs.access.exception.CacheException;
@@ -84,35 +84,14 @@
void putInGroup( Object key, String group, Object obj, IElementAttributes attr )
throws CacheException;
-
- /**
- * DefineGroup is used to create a new group object. IElementAttributes may be
set
- * on the group. If no attributes are specified, the attributes of the
- * region or group the new group is associated with are used. If group is
- * specified the new group will be associated with the group specified.
- */
- void defineGroup( String name )
- throws CacheException;
-
-
/** Description of the Method */
- void defineGroup( String name, IElementAttributes attr )
- throws CacheException;
-
+ public void remove( Object name, String group );
/**
- * Gets the groupAttributes attribute of the IGroupCacheAccess object
- *
- * @return The groupAttributes value
+ * Gets the set of keys of objects currently in the group
*/
- IElementAttributes getGroupAttributes( String name )
- throws CacheException;
-
+ public Set getGroupKeys(String group);
- /**
- * Gets the attributeNames attribute of the IGroupCacheAccess object
- *
- * @return The attributeNames value
- */
- Enumeration getAttributeNames( String name );
+ /** Invalidates a group */
+ public void invalidateGroup( String group );
}
1.6 +1 -2
jakarta-turbine-jcs/src/java/org/apache/jcs/access/monitor/MonitorAccess.java
Index: MonitorAccess.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/access/monitor/MonitorAccess.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- MonitorAccess.java 23 May 2002 15:22:22 -0000 1.5
+++ MonitorAccess.java 27 Jul 2002 06:39:50 -0000 1.6
@@ -11,7 +11,6 @@
import org.apache.jcs.access.GroupCacheAccess;
import org.apache.jcs.engine.behavior.ICache;
import org.apache.jcs.engine.control.CompositeCacheManager;
-import org.apache.jcs.engine.control.group.GroupCacheHub;
import org.apache.jcs.engine.CacheConstants;
/**
@@ -38,7 +37,7 @@
{
if ( cacheMgr == null )
{
- cacheMgr = GroupCacheHub.getInstance();
+ cacheMgr = CompositeCacheManager.getInstance();
}
}
}
1.2 +7 -1
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/AuxiliaryCache.java
Index: AuxiliaryCache.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/AuxiliaryCache.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AuxiliaryCache.java 10 Apr 2002 15:00:59 -0000 1.1
+++ AuxiliaryCache.java 27 Jul 2002 06:39:50 -0000 1.2
@@ -2,6 +2,7 @@
import java.io.IOException;
import java.io.Serializable;
+import java.util.Set;
import org.apache.jcs.engine.behavior.ICache;
import org.apache.jcs.engine.behavior.ICacheElement;
@@ -42,4 +43,9 @@
/** Returns the cache name. */
public String getCacheName();
+
+ /**
+ * Gets the set of keys of objects currently in the group
+ */
+ public Set getGroupKeys(String group);
}
1.15 +4 -2
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java
Index: AbstractDiskCache.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- AbstractDiskCache.java 14 May 2002 22:04:08 -0000 1.14
+++ AbstractDiskCache.java 27 Jul 2002 06:39:50 -0000 1.15
@@ -57,6 +57,7 @@
import java.io.IOException;
import java.io.Serializable;
import java.util.Hashtable;
+import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -252,6 +253,8 @@
return null;
}
+ public abstract Set getGroupKeys(String groupName);
+
/**
* @see org.apache.jcs.engine.behavior.ICache#remove
*/
@@ -260,7 +263,6 @@
String keyAsString = key.toString();
writeLock( keyAsString );
-
try
{
// Remove element from purgatory if it is there
1.4 +10 -0
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/hsql/HSQLCache.java
Index: HSQLCache.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/hsql/HSQLCache.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HSQLCache.java 10 Apr 2002 15:00:59 -0000 1.3
+++ HSQLCache.java 27 Jul 2002 06:39:50 -0000 1.4
@@ -68,6 +68,7 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
+import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -80,6 +81,7 @@
* HSQLDB Based Local Persistence.
*
* <b>VERY EXPERIMENTAL, and only partially implemented</b>
+ * Requires String keys and does not work with groups.
*
* @author Aaron Smuts
* @created January 15, 2002
@@ -498,6 +500,14 @@
return baos.toByteArray();
}
+ public Set getGroupKeys(String groupName)
+ {
+ if (true)
+ {
+ throw new UnsupportedOperationException("Groups not implemented.");
+ }
+ return null;
+ }
}
1.5 +56 -2
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
Index: IndexedDiskCache.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- IndexedDiskCache.java 14 May 2002 21:48:53 -0000 1.4
+++ IndexedDiskCache.java 27 Jul 2002 06:39:50 -0000 1.5
@@ -60,6 +60,8 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import java.util.Set;
+import java.util.HashSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -69,6 +71,8 @@
import org.apache.jcs.engine.CacheElement;
import org.apache.jcs.engine.behavior.ICacheElement;
import org.apache.jcs.utils.locking.ReadWriteLock;
+import org.apache.jcs.engine.control.group.GroupId;
+import org.apache.jcs.engine.control.group.GroupAttrName;
/**
* Disk cache that uses a RandomAccessFile with keys stored in memory
@@ -359,6 +363,39 @@
return object;
}
+ public Set getGroupKeys(String groupName)
+ {
+ GroupId groupId = new GroupId(cacheName, groupName);
+ HashSet keys = new HashSet();
+ try
+ {
+ storageLock.readLock();
+
+ for (Iterator itr = keyHash.keySet().iterator(); itr.hasNext();)
+ {
+ //Map.Entry entry = (Map.Entry) itr.next();
+ //Object k = entry.getKey();
+ Object k = itr.next();
+ if ( k instanceof GroupAttrName
+ && ((GroupAttrName)k).groupId.equals(groupId) )
+ {
+ keys.add(((GroupAttrName)k).attrName);
+ }
+ }
+ }
+ catch ( Exception e )
+ {
+ log.error( "Failure getting from disk, cacheName: " + cacheName +
+ ", group = " + groupName, e );
+ }
+ finally
+ {
+ storageLock.done();
+ }
+
+ return keys;
+ }
+
/**
* Returns true if the removal was succesful; or false if there is nothing
* to remove. Current implementation always result in a disk orphan.
@@ -368,6 +405,7 @@
*/
public boolean doRemove( Serializable key )
{
+ boolean removed = false;
try
{
storageLock.writeLock();
@@ -376,7 +414,6 @@
&& key.toString().endsWith(
CacheConstants.NAME_COMPONENT_DELIMITER ) )
{
// remove all keys of the same name group.
- boolean removed = false;
Iterator iter = keyHash.entrySet().iterator();
@@ -394,6 +431,23 @@
}
}
return removed;
+ }
+ else if ( key instanceof GroupId )
+ {
+ // remove all keys of the same name hierarchy.
+ Iterator iter = keyHash.entrySet().iterator();
+ while ( iter.hasNext() )
+ {
+ Map.Entry entry = (Map.Entry) iter.next();
+ Object k = entry.getKey();
+
+ if ( k instanceof GroupAttrName
+ && ((GroupAttrName)k).groupId.equals(key) )
+ {
+ iter.remove();
+ removed = true;
+ }
+ }
}
else
{
1.5 +11 -0
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/jisp/JISPCache.java
Index: JISPCache.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/jisp/JISPCache.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JISPCache.java 10 Apr 2002 15:00:59 -0000 1.4
+++ JISPCache.java 27 Jul 2002 06:39:50 -0000 1.5
@@ -57,6 +57,7 @@
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
+import java.util.Set;
import com.coyotegulch.jisp.BTreeIndex;
import com.coyotegulch.jisp.IndexedObjectDatabase;
@@ -71,6 +72,7 @@
* JISP disk cache implementation. Slow as hell with this type of key.
*
* <b>VERY EXPERIMENTAL, and only partially implemented</b>
+ * Does not work with groups.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Aaron Smuts</a>
* @created January 15, 2002
@@ -276,6 +278,15 @@
}
return element;
+ }
+
+ public Set getGroupKeys(String groupName)
+ {
+ if (true)
+ {
+ throw new UnsupportedOperationException("Groups not implemented.");
+ }
+ return null;
}
/**
1.4 +6 -0
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/lateral/LateralCache.java
Index: LateralCache.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/lateral/LateralCache.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LateralCache.java 10 Apr 2002 15:01:00 -0000 1.3
+++ LateralCache.java 27 Jul 2002 06:39:50 -0000 1.4
@@ -4,6 +4,7 @@
import java.io.Serializable;
import java.util.HashMap;
+import java.util.Set;
import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheAttributes;
import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheService;
@@ -130,6 +131,11 @@
}
}
return obj;
+ }
+
+ public Set getGroupKeys(String groupName)
+ {
+ return lateral.getGroupKeys(cacheName, groupName);
}
1.4 +7 -0
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWait.java
Index: LateralCacheNoWait.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWait.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LateralCacheNoWait.java 10 Apr 2002 15:01:00 -0000 1.3
+++ LateralCacheNoWait.java 27 Jul 2002 06:39:50 -0000 1.4
@@ -3,6 +3,7 @@
import java.io.IOException;
import java.io.Serializable;
import java.rmi.UnmarshalException;
+import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -93,6 +94,12 @@
}
return null;
}
+
+ public Set getGroupKeys(String groupName)
+ {
+ return cache.getGroupKeys(groupName);
+ }
+
/** Adds a remove request to the lateral cache. */
public boolean remove( Serializable key )
1.4 +19 -0
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWaitFacade.java
Index: LateralCacheNoWaitFacade.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWaitFacade.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LateralCacheNoWaitFacade.java 17 May 2002 14:12:52 -0000 1.3
+++ LateralCacheNoWaitFacade.java 27 Jul 2002 06:39:50 -0000 1.4
@@ -2,6 +2,8 @@
import java.io.IOException;
import java.io.Serializable;
+import java.util.Set;
+import java.util.HashSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -86,6 +88,23 @@
return null;
}
return null;
+ }
+
+ /**
+ * Gets the set of keys of objects currently in the group
+ */
+ public Set getGroupKeys(String group)
+ {
+ HashSet allKeys = new HashSet();
+ for ( int i = 0; i < noWaits.length; i++ )
+ {
+ AuxiliaryCache aux = noWaits[i];
+ if ( aux != null )
+ {
+ allKeys.addAll(aux.getGroupKeys(group));
+ }
+ }
+ return allKeys;
}
/** Adds a remove request to the lateral cache. */
1.2 +6 -0
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/lateral/ZombieLateralCacheService.java
Index: ZombieLateralCacheService.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/lateral/ZombieLateralCacheService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ZombieLateralCacheService.java 7 Apr 2002 16:55:23 -0000 1.1
+++ ZombieLateralCacheService.java 27 Jul 2002 06:39:50 -0000 1.2
@@ -1,6 +1,8 @@
package org.apache.jcs.auxiliary.lateral;
import java.io.Serializable;
+import java.util.Set;
+import java.util.Collections;
import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheService;
@@ -28,4 +30,8 @@
/** Description of the Method */
public void removeAll( String cacheName, byte listenerId ) { }
+ public Set getGroupKeys(String cacheName, String groupName)
+ {
+ return Collections.EMPTY_SET;
+ }
}
1.2 +2 -0
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/lateral/behavior/ILateralCacheService.java
Index: ILateralCacheService.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/lateral/behavior/ILateralCacheService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ILateralCacheService.java 7 Apr 2002 16:55:23 -0000 1.1
+++ ILateralCacheService.java 27 Jul 2002 06:39:50 -0000 1.2
@@ -2,6 +2,7 @@
import java.io.IOException;
import java.io.Serializable;
+import java.util.Set;
import org.apache.jcs.engine.behavior.ICacheElement;
import org.apache.jcs.engine.behavior.ICacheService;
@@ -29,4 +30,5 @@
public void removeAll( String cacheName, byte requesterId )
throws IOException;
+ public Set getGroupKeys(String cacheName, String groupName);
}
1.3 +16 -1
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java
Index: LateralTCPService.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LateralTCPService.java 10 Apr 2002 15:01:00 -0000 1.2
+++ LateralTCPService.java 27 Jul 2002 06:39:50 -0000 1.3
@@ -60,6 +60,7 @@
import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
+import java.util.Set;
import org.apache.jcs.auxiliary.lateral.LateralCacheAttributes;
import org.apache.jcs.auxiliary.lateral.LateralCacheInfo;
@@ -79,6 +80,7 @@
/**
* A lateral cache service implementation.
+ * Does not implement getGroupKey
*
* @author <a href="mailto:[EMAIL PROTECTED]">Aaron Smuts</a>
* @created January 15, 2002
@@ -194,6 +196,19 @@
return sender.sendAndReceive( led );
//return null;
// nothing needs to be done
+ }
+
+ /**
+ * Gets the set of keys of objects currently in the group
+ * throws UnsupportedOperationException
+ */
+ public Set getGroupKeys(String cacheName, String group)
+ {
+ if (true)
+ {
+ throw new UnsupportedOperationException("Groups not implemented.");
+ }
+ return null;
}
/** */
1.4 +5 -0
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/RemoteCache.java
Index: RemoteCache.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/RemoteCache.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RemoteCache.java 10 Apr 2002 15:01:00 -0000 1.3
+++ RemoteCache.java 27 Jul 2002 06:39:50 -0000 1.4
@@ -4,6 +4,7 @@
import java.io.Serializable;
import java.util.HashMap;
+import java.util.Set;
import org.apache.jcs.access.exception.ObjectNotFoundException;
@@ -161,6 +162,10 @@
}
}
+ public Set getGroupKeys(String groupName)
+ {
+ return remote.getGroupKeys(cacheName, groupName);
+ }
/**
* Wraps a non JDK object into a MarshalledObject, so that we can avoid
1.3 +2 -3
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheManager.java
Index: RemoteCacheManager.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheManager.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RemoteCacheManager.java 10 Apr 2002 15:01:01 -0000 1.2
+++ RemoteCacheManager.java 27 Jul 2002 06:39:50 -0000 1.3
@@ -26,7 +26,6 @@
import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheListener;
import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheObserver;
import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheService;
-import org.apache.jcs.auxiliary.remote.group.RemoteGroupCacheListener;
import org.apache.jcs.engine.CacheWatchRepairable;
@@ -247,10 +246,10 @@
{
// Remote cache manager can handle this by gettign the type formt he
listener
//if ( cattr.getRemoteType() == cattr.CLUSTER ) {
- // addRemoteCacheListener( cattr,
RemoteGroupCacheListener.getInstance( cattr ) );
+ // addRemoteCacheListener( cattr, RemoteCacheListener.getInstance(
cattr ) );
//} else
//if ( cattr.getRemoteType() == cattr.LOCAL ) {
- addRemoteCacheListener( cattr, RemoteGroupCacheListener.getInstance(
cattr ) );
+ addRemoteCacheListener( cattr, RemoteCacheListener.getInstance( cattr )
);
//}
}
catch ( IOException ioe )
1.4 +6 -0
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWait.java
Index: RemoteCacheNoWait.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWait.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RemoteCacheNoWait.java 10 Apr 2002 15:01:01 -0000 1.3
+++ RemoteCacheNoWait.java 27 Jul 2002 06:39:50 -0000 1.4
@@ -2,6 +2,7 @@
import java.io.IOException;
import java.io.Serializable;
+import java.util.Set;
import java.rmi.UnmarshalException;
import org.apache.commons.logging.Log;
@@ -89,6 +90,11 @@
throw ex;
}
return null;
+ }
+
+ public Set getGroupKeys(String groupName)
+ {
+ return cache.getGroupKeys(groupName);
}
/** Adds a remove request to the remote cache. */
1.4 +20 -0
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWaitFacade.java
Index: RemoteCacheNoWaitFacade.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWaitFacade.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RemoteCacheNoWaitFacade.java 10 Apr 2002 15:01:01 -0000 1.3
+++ RemoteCacheNoWaitFacade.java 27 Jul 2002 06:39:50 -0000 1.4
@@ -2,6 +2,8 @@
import java.io.IOException;
import java.io.Serializable;
+import java.util.Set;
+import java.util.HashSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -126,6 +128,24 @@
}
return null;
}
+
+ /**
+ * Gets the set of keys of objects currently in the group
+ */
+ public Set getGroupKeys(String group)
+ {
+ HashSet allKeys = new HashSet();
+ for ( int i = 0; i < noWaits.length; i++ )
+ {
+ AuxiliaryCache aux = noWaits[i];
+ if ( aux != null )
+ {
+ allKeys.addAll(aux.getGroupKeys(group));
+ }
+ }
+ return allKeys;
+ }
+
/** Adds a remove request to the lateral cache. */
public boolean remove( Serializable key )
1.2 +6 -0
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/ZombieRemoteCacheService.java
Index: ZombieRemoteCacheService.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/ZombieRemoteCacheService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ZombieRemoteCacheService.java 7 Apr 2002 16:55:25 -0000 1.1
+++ ZombieRemoteCacheService.java 27 Jul 2002 06:39:50 -0000 1.2
@@ -1,6 +1,8 @@
package org.apache.jcs.auxiliary.remote;
import java.io.Serializable;
+import java.util.Set;
+import java.util.Collections;
import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheService;
@@ -28,4 +30,8 @@
/** Description of the Method */
public void removeAll( String cacheName, byte listenerId ) { }
+ public Set getGroupKeys(String cacheName, String groupName)
+ {
+ return Collections.EMPTY_SET;
+ }
}
1.2 +2 -0
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/behavior/IRemoteCacheService.java
Index: IRemoteCacheService.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/behavior/IRemoteCacheService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- IRemoteCacheService.java 7 Apr 2002 16:55:25 -0000 1.1
+++ IRemoteCacheService.java 27 Jul 2002 06:39:51 -0000 1.2
@@ -2,6 +2,7 @@
import java.io.IOException;
import java.io.Serializable;
+import java.util.Set;
import java.rmi.Remote;
@@ -33,4 +34,5 @@
public void removeAll( String cacheName, byte requesterId )
throws IOException;
+ public Set getGroupKeys(String cacheName, String groupName);
}
1.9 +26 -0
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java
Index: RemoteCacheServer.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- RemoteCacheServer.java 23 May 2002 15:55:27 -0000 1.8
+++ RemoteCacheServer.java 27 Jul 2002 06:39:51 -0000 1.9
@@ -15,6 +15,7 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
+import java.util.Collections;
import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes;
import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheListener;
@@ -417,6 +418,31 @@
}
}
+ /**
+ * Gets the set of keys of objects currently in the group
+ */
+ public Set getGroupKeys(String cacheName, String group)
+ {
+ CacheListeners cacheDesc = null;
+ try
+ {
+ cacheDesc = getCacheListeners( cacheName );
+ }
+ catch ( Exception e )
+ {
+ log.error( e );
+ }
+
+ if ( cacheDesc == null )
+ {
+ return Collections.EMPTY_SET;
+ }
+ else
+ {
+ CompositeCache c = ( CompositeCache ) cacheDesc.cache;
+ return c.getGroupKeys(group);
+ }
+ }
/** Removes the given key from the specified remote cache. */
public void remove( String cacheName, Serializable key )
1.6 +30 -1
jakarta-turbine-jcs/src/java/org/apache/jcs/engine/control/CompositeCache.java
Index: CompositeCache.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/control/CompositeCache.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CompositeCache.java 24 Jul 2002 15:48:01 -0000 1.5
+++ CompositeCache.java 27 Jul 2002 06:39:51 -0000 1.6
@@ -58,6 +58,8 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
+import java.util.Set;
+import java.util.HashSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -81,6 +83,7 @@
import org.apache.jcs.engine.control.event.behavior.IElementEventConstants;
import org.apache.jcs.engine.control.event.behavior.IElementEventQueue;
import org.apache.jcs.engine.control.event.ElementEventQueue;
+import org.apache.jcs.engine.control.group.GroupId;
/**
* This is the primary hub for a single cache/region. It control the flow of
@@ -225,6 +228,11 @@
+ CacheConstants.NAME_COMPONENT_DELIMITER
+ " for a put operation" );
}
+ else if ( ce.getKey() instanceof GroupId )
+ {
+ throw new IllegalArgumentException( "key cannot be a GroupId "
+ + " for a put operation" );
+ }
log.debug( "Updating memory cache" );
@@ -438,6 +446,7 @@
return get( key, true );
}
+
/**
* Description of the Method
*
@@ -650,6 +659,26 @@
return false;
}
+
+
+ /**
+ * Gets the set of keys of objects currently in the group
+ */
+ public Set getGroupKeys(String group)
+ {
+ HashSet allKeys = new HashSet();
+ allKeys.addAll(memCache.getGroupKeys(group));
+ for ( int i = 0; i < auxCaches.length; i++ )
+ {
+ AuxiliaryCache aux = auxCaches[i];
+ if ( aux != null )
+ {
+ allKeys.addAll(aux.getGroupKeys(group));
+ }
+ }
+ return allKeys;
+ }
+
/**
* @see ICache#remove
1.2 +24 -1
jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/AbstractMemoryCache.java
Index: AbstractMemoryCache.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/AbstractMemoryCache.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractMemoryCache.java 6 Jun 2002 05:35:02 -0000 1.1
+++ AbstractMemoryCache.java 27 Jul 2002 06:39:51 -0000 1.2
@@ -6,6 +6,8 @@
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
+import java.util.Set;
+import java.util.HashSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -260,5 +262,26 @@
public CompositeCache getCompositeCache()
{
return this.cache;
+ }
+
+ public Set getGroupKeys(String groupName)
+ {
+ GroupId groupId = new GroupId(getCacheName(), groupName);
+ HashSet keys = new HashSet();
+ synchronized ( map )
+ {
+ for (Iterator itr = map.entrySet().iterator(); itr.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry) itr.next();
+ Object k = entry.getKey();
+
+ if ( k instanceof GroupAttrName
+ && ((GroupAttrName)k).groupId.equals(groupId) )
+ {
+ keys.add(((GroupAttrName)k).attrName);
+ }
+ }
+ }
+ return keys;
}
}
1.9 +6 -1
jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/MemoryCache.java
Index: MemoryCache.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/MemoryCache.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- MemoryCache.java 23 May 2002 15:55:28 -0000 1.8
+++ MemoryCache.java 27 Jul 2002 06:39:51 -0000 1.9
@@ -3,6 +3,7 @@
import java.io.IOException;
import java.io.Serializable;
import java.util.Iterator;
+import java.util.Set;
import org.apache.jcs.engine.behavior.ICacheElement;
import org.apache.jcs.engine.behavior.ICompositeCacheAttributes;
@@ -135,4 +136,8 @@
*/
public CompositeCache getCompositeCache();
+ /**
+ * Gets the set of keys of objects currently in the group
+ */
+ public Set getGroupKeys(String group);
}
1.10 +23 -1
jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/mru/MRUMemoryCache.java
Index: MRUMemoryCache.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/mru/MRUMemoryCache.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- MRUMemoryCache.java 6 Jun 2002 05:35:02 -0000 1.9
+++ MRUMemoryCache.java 27 Jul 2002 06:39:51 -0000 1.10
@@ -17,6 +17,8 @@
import org.apache.jcs.engine.control.CompositeCache;
import org.apache.jcs.engine.memory.MemoryCache;
import org.apache.jcs.engine.memory.AbstractMemoryCache;
+import org.apache.jcs.engine.control.group.GroupId;
+import org.apache.jcs.engine.control.group.GroupAttrName;
/**
* A SLOW AS HELL reference management system. The most recently used items move
@@ -307,6 +309,26 @@
Serializable keyR = ( ICacheElement ) entry.getKey();
map.remove( keyR );
mrulist.remove( keyR );
+ removed = true;
+ }
+ }
+ }
+ }
+ else if ( key instanceof GroupId )
+ {
+ // remove all keys of the same name hierarchy.
+ synchronized ( map )
+ {
+ for (Iterator itr = map.entrySet().iterator(); itr.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry) itr.next();
+ Object k = entry.getKey();
+
+ if ( k instanceof GroupAttrName
+ && ((GroupAttrName)k).groupId.equals(key) )
+ {
+ itr.remove();
+ mrulist.remove(k);
removed = true;
}
}
1.3 +4 -2
jakarta-turbine-jcs/src/java/org/apache/jcs/utils/servlet/session/DistSession.java
Index: DistSession.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/utils/servlet/session/DistSession.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DistSession.java 6 Jun 2002 05:31:11 -0000 1.2
+++ DistSession.java 27 Jul 2002 06:39:51 -0000 1.3
@@ -4,6 +4,7 @@
import java.util.Enumeration;
import java.util.Set;
+import java.util.Collections;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
@@ -161,7 +162,7 @@
*/
public Enumeration getAttributeNames()
{
- return sessCache.getAttributeNames( session_id );
+ return Collections.enumeration(sessCache.getGroupKeys(session_id));
}
@@ -255,7 +256,8 @@
*/
public String[] getValueNames()
{
- return ( String[] ) sessCache.getAttributeNameSet( session_id ).toArray(
new String[0] );
+ return (String[]) sessCache
+ .getGroupKeys(session_id).toArray( new String[0] );
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>