As a follow up:  The clustering does seem to work fine.  I've just done
some clustering tests with OJB and OSCache together (Using Orion Server,
JDK1.4.2, Linux).

IMPORTANT NOTE: You have to make sure that you use the
javagroups-all.jar that comes with OSCache.  I didn't even see it, so I
downloaded a newer version, and that won't work.

ALSO: In the OSCache webpage
(http://www.opensymphony.com/oscache/clustering.html) on clustering, the
Listener class is listed as:

cache.event.listeners=com.opensymphony.module.oscache.plugins.clustersupport.BroadcastingCacheEventListener

but it should acutall be:

cache.event.listeners=com.opensymphony.oscache.plugins.clustersupport.BroadcastingCacheEventListener


This is very cool, because now we have access to a good open source
clustered cache.  This gives us the ability to use the cache in
load-balanced/clustered environments.


Jason


On Wed, 2003-07-23 at 13:02, Jason McKerr wrote:
> OK, I've written a class that allows OSCache to work with OJB.  Here's a
> short how to:
> 
> (Thomas, you might add this to the Contrib with that other class I did
> for Tangosol caching.)
> 
> 
> 1) First, download OSCache and javagroups from the following links:
> 
> http://www.opensymphony.com/oscache/download.html
> http://www.javagroups.com/javagroupsnew/docs/index.html
> 
> 2) put oscache.jar and javagroups.jar in your classpath
> 
> 3) Add oscache.properties somewhere where it can be accessed (classpath,
> or WEB-INF/classes or whatever).  This file allows you different
> configurations (disk/memory caching, algorithms, etc). Please go to the
> following for more info on that:
> 
> http://www.opensymphony.com/oscache/
> 
> 4) Change the ObjectCacheClass value to ObjectCacheOSCacheImpl
> (you may want to change the package name if you add package level info
> to the class).
> 
> 5) add the Class that I've included to the proper package as described
> in step 4 (again you may want to change packages).
> 
> NOTES: This is somewhat tested. I ran about 20 different tests on it and
> it worked fine for a local cache.  But I haven't really kicked it too
> hard yet.
> 
> NOTES2: I have not yet gotten the cluster feature of OSCache working. 
> There is something wrong with one of the listeners, and I'm working on
> it. So the cache is working fine locally, but not clustered/distributed.
> 
> Let me know about questions/comments.
> 
> Jason
> 
> 
> ---------------------------HERE'S THAT CLASS----------------------------
> import org.apache.ojb.broker.Identity;
> import org.apache.ojb.broker.PersistenceBroker;
> import org.apache.ojb.broker.cache.ObjectCache;
> import org.apache.ojb.broker.cache.RuntimeCacheException;
> 
> import com.opensymphony.oscache.base.CacheEntry;
> import com.opensymphony.oscache.general.GeneralCacheAdministrator;
> 
> import java.util.Date;
> 
> 
> public class ObjectCacheOSCacheImpl implements ObjectCache {
> 
>   private GeneralCacheAdministrator admin;
>   private static final int NO_REFRESH_NEEDED =
> CacheEntry.INDEFINITE_EXPIRY;
> 
>   public ObjectCacheOSCacheImpl() {
>   }
> 
>   public ObjectCacheOSCacheImpl(PersistenceBroker broker) {
>       admin = new GeneralCacheAdministrator();
>   }
> 
>   public void cache(Identity oid, Object obj) {
>     try {
>       admin.putInCache(oid.toString(), obj);
>     }
>     catch (Exception e) {
>       throw new RuntimeCacheException(e.getMessage());
>     }
>   }
> 
>   public Object lookup(Identity oid) {
>     try {
>       return admin.getFromCache(oid.toString(), NO_REFRESH_NEEDED);
>     }
>     catch (Exception e) {
>       return null;
>     }
>   }
> 
>   public void remove(Identity oid) {
>     try {
>       admin.getCache().flushEntry(oid.toString());
>     }
>     catch (Exception e) {
>       throw new RuntimeCacheException(e.getMessage());
>     }
>   }
> 
>   public void clear() {
>     if (admin != null) {
>       try {
>         admin.flushAll(new Date());
>       }
>       catch (Exception e) {
>         throw new RuntimeCacheException(e);
>       }
>     }
>   }
> }
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


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

Reply via email to