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?
what about using an Flag-like api?
cache.inGroup("groupName").put(...).
or an "parametrized" flag:
cache.withFlag(Flags.getColocateFlag("grouName").put(...)
as long as we can create "parametrized" flags as bellow, I like the second
approach
Cheers,
--
Manik Surtani
manik(a)jboss.org
Lead, Infinispan
Lead, JBoss Cache
http://www.infinispan.org
http://www.jbosscache.org
_______________________________________________
infinispan-dev mailing list
infinispan-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/infinispan-dev