[infinispan-dev] ISPN-359 and grouping entries for distribution

Manik Surtani manik at jboss.org
Mon Apr 12 08:36:15 EDT 2010

Re: subject (see https://jira.jboss.org/jira/browse/ISPN-359), there are a couple of approaches that could be taken:

1.  Don't use key.hashcode() as the seed in determining to which nodes an entry is mapped, but instead on a well-known method or annotated method (e.g., int getGroupID() or a method annotated with @GroupId).  The way I see it, this approach has:

+ Will work, no additional overheads of AtomicMaps
- Cost (reflection)
- Intrusive (what if users have no control over the key class, e.g., String keys?)

2.  Additional API methods on the cache - cache.put(K, V, G), cache.putAll(Map, G), etc.

+ Non-intrusive
- Overhead of AtomicMaps + additional entries for mappings
+ or - (depending on how you look at it) all keys in the group will be locked together, etc, a side-effect of using AtomicMaps

My pref is for approach #2.  In terms of implementation, here is what I have in mind:

* A GroupingInterceptor that intercepts the call early on if the call is a put(K, V, G) or something similar.  
* Breaks up the call to a put(K, G) and a getAtomicMap(G).put(K, V).  Wrapped in a tx to ensure atomicity.
* get(K), etc intercepted as well, replaced with getAtomicMap(get(K)).get(K)
* remove(K), etc intercepted with getAtomicMap(get(K)).remove(K)

One of the issues with the API approach is that it heavily pollutes the Cache API.  It will double the number of put() methods on Cache (currently 18 variants of put, including ones that take in lifespans and maxIdles, async versions that return futures, etc.)  Perhaps this could be in an additional sub-interface interface?  GroupedCache?  Or is this degree of method overloading not too confusing?

Manik Surtani
manik at jboss.org
Lead, Infinispan
Lead, JBoss Cache

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/infinispan-dev/attachments/20100412/662d7afc/attachment-0002.html 

More information about the infinispan-dev mailing list